Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 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. L10:
  30. br L9
  31. L9:
  32. br L6
  33. L6:
  34. br i1 1, label L8, label L5
  35. L8:
  36. %m.u1 = load i64, i64* %l
  37. %m.u2 = load i64, i64* @k
  38. %m.u3 = mul i64 %m.u1, %m.u2
  39. store i64 %m.u3, i64* %f
  40. br L6
  41. L5:
  42. br L4
  43. L4:
  44. %m.u4 = load i64, i64* %f
  45. ret i64 %m.u4
  46. }
  47. define i64 @main()
  48. {
  49. %a = alloca i64
  50. %b = alloca i64
  51. %h = alloca i64
  52. %i = alloca i64
  53. %j = alloca i64
  54. L27:
  55. br L26
  56. L26:
  57. br L25
  58. L25:
  59. %m.u5 = load i64, i64* @k
  60. %m.u6 = icmp sgt i64 %m.u5, 0
  61. br i1 %m.u6, label L17, label L24
  62. L17:
  63. ret i64 0
  64. L15:
  65. %m.u7 = add i64 1, 1
  66. store i64 %m.u7, i64* %a
  67. br L13
  68. L13:
  69. ret i64 0
  70. L24:
  71. br L23
  72. L23:
  73. br i1 0, label L20, label L22
  74. L20:
  75. %m.u8 = load i64, i64* @k
  76. ret i64 %m.u8
  77. L18:
  78. br L15
  79. L22:
  80. %m.u9 = and i64 1, 0
  81. ret i64 %m.u9
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement