Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 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. %.k = alloca i64
  29. %.l = alloca i64
  30. L4:
  31. %u1 = load i64, i64* %.f
  32. ret i64 %u1
  33. br L2
  34. }
  35. define %struct.A* @f(i64 %i, %struct.B* %j)
  36. {
  37. %.f = alloca i64
  38. %.k = alloca i64
  39. %.l = alloca i64
  40. L4:
  41. %u1 = load i64, i64* %.f
  42. ret i64 %u1
  43. br L2
  44. }
  45. define i64 @main()
  46. {
  47. %.a = alloca i64
  48. %.b = alloca i64
  49. %.h = alloca i64
  50. %.i = alloca i64
  51. %.j = alloca i64
  52. %.k = alloca i64
  53. L15:
  54. br L14
  55. L14:
  56. br L13
  57. L13:
  58. %u2 = load i64, i64* %.k
  59. %u3 = icmp sgt i64 %u2, 0
  60. br i1 %u3, label L11, label L12
  61. L11:
  62. ret i64 0
  63. br L9
  64. L9:
  65. %u4 = add i64 1, 1
  66. store i64 %u4, i64* %.a
  67. br L7
  68. L7:
  69. ret i64 0
  70. br L2
  71. L12:
  72. br L9
  73. L9:
  74. %u5 = add i64 1, 1
  75. store i64 %u5, i64* %.a
  76. br L7
  77. L7:
  78. ret i64 0
  79. br L2
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement