Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. ; MINI ENVIRONMENT
  2. declare i8* @malloc(i64)
  3. declare void @free(i8*)
  4. declare i32 @printf(i8*, ...)
  5. declare i32 @scanf(i8*, ...)
  6. @.println = private unnamed_addr constant [5 x i8] c"%ld\0A\00", align 1
  7. @.print = private unnamed_addr constant [5 x i8] c"%ld \00", align 1
  8. @.read = private unnamed_addr constant [4 x i8] c"%ld\00", align 1
  9. @.read_scratch = common global i64 0, align 8
  10.  
  11. ; PROGRAM STRUCTS
  12. %struct.A = type {i64, i64, i64, %struct.A*}
  13. %struct.B = type {%struct.A*}
  14.  
  15. ; PROGRAM GLOBALS
  16. @i = common global i64 0, align 8
  17. @j = common global i64 0, align 8
  18. @k = common global i64 0, align 8
  19. @b = common global %struct.B* null, align 8
  20. @bb = common global %struct.B* null, align 8
  21. @bbb = common global %struct.B* null, align 8
  22. @bob = common global i64 0, align 8
  23.  
  24. ; FUNCTION DEFINITIONS
  25. define %struct.A* @f(i64 %i, %struct.B* %j)
  26. {
  27. %f = alloca i64
  28. %l = alloca i64
  29. L12:
  30. br L11
  31. L11:
  32. %m.u1 = mul i64 999, -1
  33. store i64 %m.u1, i64* %l
  34. br L6
  35. L6:
  36. %m.u2 = load i64, i64* %l
  37. %m.u3 = icmp sgt i64 %m.u2, 101
  38. %m.u4 = xor i64 %m.u3, 1
  39. br i1 %m.u4, label L9, label L5
  40. L9:
  41. %m.u5 = load i64, i64* %l
  42. %m.u6 = load i64, i64* @k
  43. %m.u7 = mul i64 %m.u5, %m.u6
  44. store i64 %m.u7, i64* %f
  45. %m.u8 = load i64, i64* %l
  46. %m.u9 = add i64 %m.u8, 2
  47. store i64 %m.u9, i64* %l
  48. br L6
  49. L5:
  50. br L4
  51. L4:
  52. %m.u10 = load i64, i64* %f
  53. ret i64 %m.u10
  54. }
  55. define i64 @main()
  56. {
  57. %a = alloca i64
  58. %b = alloca i64
  59. %h = alloca i64
  60. %i = alloca i64
  61. %j = alloca i64
  62. L29:
  63. br L28
  64. L28:
  65. br L27
  66. L27:
  67. %m.u11 = load i64, i64* @k
  68. %m.u12 = icmp sgt i64 %m.u11, 0
  69. br i1 %m.u12, label L19, label L26
  70. L19:
  71. ret i64 0
  72. L17:
  73. %m.u13 = add i64 1, 1
  74. store i64 %m.u13, i64* %a
  75. br L15
  76. L15:
  77. ret i64 0
  78. L26:
  79. br L25
  80. L25:
  81. br i1 0, label L22, label L24
  82. L22:
  83. %m.u14 = load i64, i64* @k
  84. ret i64 %m.u14
  85. L20:
  86. br L17
  87. L24:
  88. %m.u15 = and i64 1, 0
  89. ret i64 %m.u15
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement