Advertisement
amitsp21

Untitled

Dec 19th, 2018
2,774
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LLVM 45.76 KB | None | 0 0
  1. ; ModuleID = 'AP_PlusPlus'
  2. source_filename = "AP_PlusPlus"
  3.  
  4. @fmt = private unnamed_addr constant [4 x i8] c"%d\0A\00"
  5. @fmt.1 = private unnamed_addr constant [4 x i8] c"%g\0A\00"
  6. @fmt.2 = private unnamed_addr constant [4 x i8] c"%s\0A\00"
  7. @fmt.3 = private unnamed_addr constant [4 x i8] c"%d\0A\00"
  8. @fmt.4 = private unnamed_addr constant [4 x i8] c"%g\0A\00"
  9. @fmt.5 = private unnamed_addr constant [4 x i8] c"%s\0A\00"
  10.  
  11. declare i32 @printf(i8*, ...)
  12.  
  13. define i1 @list_getbool({ i32*, i1* }*, i32) {
  14. entry:
  15.   %list_ptr_alloc = alloca { i32*, i1* }*
  16.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  17.   %idx_alloc = alloca i32
  18.   store i32 %1, i32* %idx_alloc
  19.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  20.   %list_array_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 1
  21.   %array_load = load i1*, i1** %list_array_ptr
  22.   %idx_load = load i32, i32* %idx_alloc
  23.   %list_arry_element_ptr = getelementptr i1, i1* %array_load, i32 %idx_load
  24.   %list_array_element_ptr = load i1, i1* %list_arry_element_ptr
  25.   ret i1 %list_array_element_ptr
  26. }
  27.  
  28. define i32 @list_getint({ i32*, i32* }*, i32) {
  29. entry:
  30.   %list_ptr_alloc = alloca { i32*, i32* }*
  31.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  32.   %idx_alloc = alloca i32
  33.   store i32 %1, i32* %idx_alloc
  34.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  35.   %list_array_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 1
  36.   %array_load = load i32*, i32** %list_array_ptr
  37.   %idx_load = load i32, i32* %idx_alloc
  38.   %list_arry_element_ptr = getelementptr i32, i32* %array_load, i32 %idx_load
  39.   %list_array_element_ptr = load i32, i32* %list_arry_element_ptr
  40.   ret i32 %list_array_element_ptr
  41. }
  42.  
  43. define double @list_getfloat({ i32*, double* }*, i32) {
  44. entry:
  45.   %list_ptr_alloc = alloca { i32*, double* }*
  46.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  47.   %idx_alloc = alloca i32
  48.   store i32 %1, i32* %idx_alloc
  49.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  50.   %list_array_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 1
  51.   %array_load = load double*, double** %list_array_ptr
  52.   %idx_load = load i32, i32* %idx_alloc
  53.   %list_arry_element_ptr = getelementptr double, double* %array_load, i32 %idx_load
  54.   %list_array_element_ptr = load double, double* %list_arry_element_ptr
  55.   ret double %list_array_element_ptr
  56. }
  57.  
  58. define i8* @list_getstr({ i32*, i8** }*, i32) {
  59. entry:
  60.   %list_ptr_alloc = alloca { i32*, i8** }*
  61.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  62.   %idx_alloc = alloca i32
  63.   store i32 %1, i32* %idx_alloc
  64.   %list_load = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  65.   %list_array_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 1
  66.   %array_load = load i8**, i8*** %list_array_ptr
  67.   %idx_load = load i32, i32* %idx_alloc
  68.   %list_arry_element_ptr = getelementptr i8*, i8** %array_load, i32 %idx_load
  69.   %list_array_element_ptr = load i8*, i8** %list_arry_element_ptr
  70.   ret i8* %list_array_element_ptr
  71. }
  72.  
  73. define void @list_setbool({ i32*, i1* }*, i32, i1) {
  74. entry:
  75.   %list_ptr_alloc = alloca { i32*, i1* }*
  76.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  77.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  78.   %list_array_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 1
  79.   %list_array_load = load i1*, i1** %list_array_ptr
  80.   %list_arry_next_element_ptr = getelementptr i1, i1* %list_array_load, i32 %1
  81.   store i1 %2, i1* %list_arry_next_element_ptr
  82.   ret void
  83. }
  84.  
  85. define void @list_setint({ i32*, i32* }*, i32, i32) {
  86. entry:
  87.   %list_ptr_alloc = alloca { i32*, i32* }*
  88.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  89.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  90.   %list_array_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 1
  91.   %list_array_load = load i32*, i32** %list_array_ptr
  92.   %list_arry_next_element_ptr = getelementptr i32, i32* %list_array_load, i32 %1
  93.   store i32 %2, i32* %list_arry_next_element_ptr
  94.   ret void
  95. }
  96.  
  97. define void @list_setfloat({ i32*, double* }*, i32, double) {
  98. entry:
  99.   %list_ptr_alloc = alloca { i32*, double* }*
  100.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  101.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  102.   %list_array_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 1
  103.   %list_array_load = load double*, double** %list_array_ptr
  104.   %list_arry_next_element_ptr = getelementptr double, double* %list_array_load, i32 %1
  105.   store double %2, double* %list_arry_next_element_ptr
  106.   ret void
  107. }
  108.  
  109. define void @list_setstr({ i32*, i8** }*, i32, i8*) {
  110. entry:
  111.   %list_ptr_alloc = alloca { i32*, i8** }*
  112.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  113.   %list_load = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  114.   %list_array_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 1
  115.   %list_array_load = load i8**, i8*** %list_array_ptr
  116.   %list_arry_next_element_ptr = getelementptr i8*, i8** %list_array_load, i32 %1
  117.   store i8* %2, i8** %list_arry_next_element_ptr
  118.   ret void
  119. }
  120.  
  121. define void @list_pushbool({ i32*, i1* }*, i1) {
  122. entry:
  123.   %list_ptr_alloc = alloca { i32*, i1* }*
  124.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  125.   %val_alloc = alloca i1
  126.   store i1 %1, i1* %val_alloc
  127.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  128.   %list_array_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 1
  129.   %list_array_load = load i1*, i1** %list_array_ptr
  130.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  131.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  132.   %list_size = load i32, i32* %list_size_ptr
  133.   %list_arry_next_element_ptr = getelementptr i1, i1* %list_array_load, i32 %list_size
  134.   %inc_size = add i32 %list_size, 1
  135.   store i32 %inc_size, i32* %list_size_ptr
  136.   %val = load i1, i1* %val_alloc
  137.   store i1 %val, i1* %list_arry_next_element_ptr
  138.   ret void
  139. }
  140.  
  141. define void @list_pushint({ i32*, i32* }*, i32) {
  142. entry:
  143.   %list_ptr_alloc = alloca { i32*, i32* }*
  144.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  145.   %val_alloc = alloca i32
  146.   store i32 %1, i32* %val_alloc
  147.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  148.   %list_array_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 1
  149.   %list_array_load = load i32*, i32** %list_array_ptr
  150.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  151.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  152.   %list_size = load i32, i32* %list_size_ptr
  153.   %list_arry_next_element_ptr = getelementptr i32, i32* %list_array_load, i32 %list_size
  154.   %inc_size = add i32 %list_size, 1
  155.   store i32 %inc_size, i32* %list_size_ptr
  156.   %val = load i32, i32* %val_alloc
  157.   store i32 %val, i32* %list_arry_next_element_ptr
  158.   ret void
  159. }
  160.  
  161. define void @list_pushfloat({ i32*, double* }*, double) {
  162. entry:
  163.   %list_ptr_alloc = alloca { i32*, double* }*
  164.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  165.   %val_alloc = alloca double
  166.   store double %1, double* %val_alloc
  167.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  168.   %list_array_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 1
  169.   %list_array_load = load double*, double** %list_array_ptr
  170.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  171.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  172.   %list_size = load i32, i32* %list_size_ptr
  173.   %list_arry_next_element_ptr = getelementptr double, double* %list_array_load, i32 %list_size
  174.   %inc_size = add i32 %list_size, 1
  175.   store i32 %inc_size, i32* %list_size_ptr
  176.   %val = load double, double* %val_alloc
  177.   store double %val, double* %list_arry_next_element_ptr
  178.   ret void
  179. }
  180.  
  181. define void @list_pushstr({ i32*, i8** }*, i8*) {
  182. entry:
  183.   %list_ptr_alloc = alloca { i32*, i8** }*
  184.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  185.   %val_alloc = alloca i8*
  186.   store i8* %1, i8** %val_alloc
  187.   %list_load = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  188.   %list_array_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 1
  189.   %list_array_load = load i8**, i8*** %list_array_ptr
  190.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 0
  191.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  192.   %list_size = load i32, i32* %list_size_ptr
  193.   %list_arry_next_element_ptr = getelementptr i8*, i8** %list_array_load, i32 %list_size
  194.   %inc_size = add i32 %list_size, 1
  195.   store i32 %inc_size, i32* %list_size_ptr
  196.   %val = load i8*, i8** %val_alloc
  197.   store i8* %val, i8** %list_arry_next_element_ptr
  198.   ret void
  199. }
  200.  
  201. define i1 @list_popbool({ i32*, i1* }*) {
  202. entry:
  203.   %list_ptr_alloc = alloca { i32*, i1* }*
  204.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  205.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  206.   %list_array_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 1
  207.   %list_array_load = load i1*, i1** %list_array_ptr
  208.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  209.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  210.   %list_size = load i32, i32* %list_size_ptr
  211.   %dec_size = sub i32 %list_size, 1
  212.   %list_arry_next_element_ptr = getelementptr i1, i1* %list_array_load, i32 %dec_size
  213.   %list_arry_next_element = load i1, i1* %list_arry_next_element_ptr
  214.   store i32 %dec_size, i32* %list_size_ptr
  215.   ret i1 %list_arry_next_element
  216. }
  217.  
  218. define i32 @list_popint({ i32*, i32* }*) {
  219. entry:
  220.   %list_ptr_alloc = alloca { i32*, i32* }*
  221.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  222.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  223.   %list_array_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 1
  224.   %list_array_load = load i32*, i32** %list_array_ptr
  225.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  226.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  227.   %list_size = load i32, i32* %list_size_ptr
  228.   %dec_size = sub i32 %list_size, 1
  229.   %list_arry_next_element_ptr = getelementptr i32, i32* %list_array_load, i32 %dec_size
  230.   %list_arry_next_element = load i32, i32* %list_arry_next_element_ptr
  231.   store i32 %dec_size, i32* %list_size_ptr
  232.   ret i32 %list_arry_next_element
  233. }
  234.  
  235. define double @list_popfloat({ i32*, double* }*) {
  236. entry:
  237.   %list_ptr_alloc = alloca { i32*, double* }*
  238.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  239.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  240.   %list_array_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 1
  241.   %list_array_load = load double*, double** %list_array_ptr
  242.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  243.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  244.   %list_size = load i32, i32* %list_size_ptr
  245.   %dec_size = sub i32 %list_size, 1
  246.   %list_arry_next_element_ptr = getelementptr double, double* %list_array_load, i32 %dec_size
  247.   %list_arry_next_element = load double, double* %list_arry_next_element_ptr
  248.   store i32 %dec_size, i32* %list_size_ptr
  249.   ret double %list_arry_next_element
  250. }
  251.  
  252. define i8* @list_popstr({ i32*, i8** }*) {
  253. entry:
  254.   %list_ptr_alloc = alloca { i32*, i8** }*
  255.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  256.   %list_load = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  257.   %list_array_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 1
  258.   %list_array_load = load i8**, i8*** %list_array_ptr
  259.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 0
  260.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  261.   %list_size = load i32, i32* %list_size_ptr
  262.   %dec_size = sub i32 %list_size, 1
  263.   %list_arry_next_element_ptr = getelementptr i8*, i8** %list_array_load, i32 %dec_size
  264.   %list_arry_next_element = load i8*, i8** %list_arry_next_element_ptr
  265.   store i32 %dec_size, i32* %list_size_ptr
  266.   ret i8* %list_arry_next_element
  267. }
  268.  
  269. define i32 @list_sizebool({ i32*, i1* }*) {
  270. entry:
  271.   %list_ptr_alloc = alloca { i32*, i1* }*
  272.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  273.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  274.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  275.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  276.   %list_size = load i32, i32* %list_size_ptr
  277.   ret i32 %list_size
  278. }
  279.  
  280. define i32 @list_sizeint({ i32*, i32* }*) {
  281. entry:
  282.   %list_ptr_alloc = alloca { i32*, i32* }*
  283.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  284.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  285.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  286.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  287.   %list_size = load i32, i32* %list_size_ptr
  288.   ret i32 %list_size
  289. }
  290.  
  291. define i32 @list_sizefloat({ i32*, double* }*) {
  292. entry:
  293.   %list_ptr_alloc = alloca { i32*, double* }*
  294.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  295.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  296.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  297.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  298.   %list_size = load i32, i32* %list_size_ptr
  299.   ret i32 %list_size
  300. }
  301.  
  302. define i32 @list_sizestr({ i32*, i8** }*) {
  303. entry:
  304.   %list_ptr_alloc = alloca { i32*, i8** }*
  305.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  306.   %list_load = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  307.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i8** }, { i32*, i8** }* %list_load, i32 0, i32 0
  308.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  309.   %list_size = load i32, i32* %list_size_ptr
  310.   ret i32 %list_size
  311. }
  312.  
  313. define void @list_slicebool({ i32*, i1* }*, { i32*, i1* }*, i32, i32) {
  314. entry:
  315.   %list_ptr_alloc = alloca { i32*, i1* }*
  316.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  317.   %list_ptr_ptr = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  318.   %list_ptr_alloc2 = alloca { i32*, i1* }*
  319.   store { i32*, i1* }* %1, { i32*, i1* }** %list_ptr_alloc2
  320.   %list_ptr_ptr2 = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc2
  321.   %idx_alloc = alloca i32
  322.   store i32 %2, i32* %idx_alloc
  323.   %idx_load = load i32, i32* %idx_alloc
  324.   %idx_alloc1 = alloca i32
  325.   store i32 %3, i32* %idx_alloc1
  326.   %idx_load2 = load i32, i32* %idx_alloc1
  327.   %loop_cnt = alloca i32
  328.   store i32 0, i32* %loop_cnt
  329.   %loop_upper_bound = sub i32 %idx_load2, %idx_load
  330.   br label %while
  331.  
  332. while:                                            ; preds = %while_body, %entry
  333.   %loop_cnt4 = load i32, i32* %loop_cnt
  334.   %loop_cond = icmp sle i32 %loop_cnt4, %loop_upper_bound
  335.   br i1 %loop_cond, label %while_body, label %merge
  336.  
  337. while_body:                                       ; preds = %while
  338.   %to_idx = load i32, i32* %loop_cnt
  339.   %from_idx = add i32 %to_idx, %idx_load
  340.   %list_get = call i1 @list_getbool({ i32*, i1* }* %list_ptr_ptr, i32 %from_idx)
  341.   call void @list_pushbool({ i32*, i1* }* %list_ptr_ptr2, i1 %list_get)
  342.   %loop_cnt3 = load i32, i32* %loop_cnt
  343.   %loop_itr = add i32 %loop_cnt3, 1
  344.   store i32 %loop_itr, i32* %loop_cnt
  345.   br label %while
  346.  
  347. merge:                                            ; preds = %while
  348.   ret void
  349. }
  350.  
  351. define void @list_sliceint({ i32*, i32* }*, { i32*, i32* }*, i32, i32) {
  352. entry:
  353.   %list_ptr_alloc = alloca { i32*, i32* }*
  354.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  355.   %list_ptr_ptr = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  356.   %list_ptr_alloc2 = alloca { i32*, i32* }*
  357.   store { i32*, i32* }* %1, { i32*, i32* }** %list_ptr_alloc2
  358.   %list_ptr_ptr2 = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc2
  359.   %idx_alloc = alloca i32
  360.   store i32 %2, i32* %idx_alloc
  361.   %idx_load = load i32, i32* %idx_alloc
  362.   %idx_alloc1 = alloca i32
  363.   store i32 %3, i32* %idx_alloc1
  364.   %idx_load2 = load i32, i32* %idx_alloc1
  365.   %loop_cnt = alloca i32
  366.   store i32 0, i32* %loop_cnt
  367.   %loop_upper_bound = sub i32 %idx_load2, %idx_load
  368.   br label %while
  369.  
  370. while:                                            ; preds = %while_body, %entry
  371.   %loop_cnt4 = load i32, i32* %loop_cnt
  372.   %loop_cond = icmp sle i32 %loop_cnt4, %loop_upper_bound
  373.   br i1 %loop_cond, label %while_body, label %merge
  374.  
  375. while_body:                                       ; preds = %while
  376.   %to_idx = load i32, i32* %loop_cnt
  377.   %from_idx = add i32 %to_idx, %idx_load
  378.   %list_get = call i32 @list_getint({ i32*, i32* }* %list_ptr_ptr, i32 %from_idx)
  379.   call void @list_pushint({ i32*, i32* }* %list_ptr_ptr2, i32 %list_get)
  380.   %loop_cnt3 = load i32, i32* %loop_cnt
  381.   %loop_itr = add i32 %loop_cnt3, 1
  382.   store i32 %loop_itr, i32* %loop_cnt
  383.   br label %while
  384.  
  385. merge:                                            ; preds = %while
  386.   ret void
  387. }
  388.  
  389. define void @list_slicefloat({ i32*, double* }*, { i32*, double* }*, i32, i32) {
  390. entry:
  391.   %list_ptr_alloc = alloca { i32*, double* }*
  392.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  393.   %list_ptr_ptr = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  394.   %list_ptr_alloc2 = alloca { i32*, double* }*
  395.   store { i32*, double* }* %1, { i32*, double* }** %list_ptr_alloc2
  396.   %list_ptr_ptr2 = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc2
  397.   %idx_alloc = alloca i32
  398.   store i32 %2, i32* %idx_alloc
  399.   %idx_load = load i32, i32* %idx_alloc
  400.   %idx_alloc1 = alloca i32
  401.   store i32 %3, i32* %idx_alloc1
  402.   %idx_load2 = load i32, i32* %idx_alloc1
  403.   %loop_cnt = alloca i32
  404.   store i32 0, i32* %loop_cnt
  405.   %loop_upper_bound = sub i32 %idx_load2, %idx_load
  406.   br label %while
  407.  
  408. while:                                            ; preds = %while_body, %entry
  409.   %loop_cnt4 = load i32, i32* %loop_cnt
  410.   %loop_cond = icmp sle i32 %loop_cnt4, %loop_upper_bound
  411.   br i1 %loop_cond, label %while_body, label %merge
  412.  
  413. while_body:                                       ; preds = %while
  414.   %to_idx = load i32, i32* %loop_cnt
  415.   %from_idx = add i32 %to_idx, %idx_load
  416.   %list_get = call double @list_getfloat({ i32*, double* }* %list_ptr_ptr, i32 %from_idx)
  417.   call void @list_pushfloat({ i32*, double* }* %list_ptr_ptr2, double %list_get)
  418.   %loop_cnt3 = load i32, i32* %loop_cnt
  419.   %loop_itr = add i32 %loop_cnt3, 1
  420.   store i32 %loop_itr, i32* %loop_cnt
  421.   br label %while
  422.  
  423. merge:                                            ; preds = %while
  424.   ret void
  425. }
  426.  
  427. define void @list_slicestr({ i32*, i8** }*, { i32*, i8** }*, i32, i32) {
  428. entry:
  429.   %list_ptr_alloc = alloca { i32*, i8** }*
  430.   store { i32*, i8** }* %0, { i32*, i8** }** %list_ptr_alloc
  431.   %list_ptr_ptr = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc
  432.   %list_ptr_alloc2 = alloca { i32*, i8** }*
  433.   store { i32*, i8** }* %1, { i32*, i8** }** %list_ptr_alloc2
  434.   %list_ptr_ptr2 = load { i32*, i8** }*, { i32*, i8** }** %list_ptr_alloc2
  435.   %idx_alloc = alloca i32
  436.   store i32 %2, i32* %idx_alloc
  437.   %idx_load = load i32, i32* %idx_alloc
  438.   %idx_alloc1 = alloca i32
  439.   store i32 %3, i32* %idx_alloc1
  440.   %idx_load2 = load i32, i32* %idx_alloc1
  441.   %loop_cnt = alloca i32
  442.   store i32 0, i32* %loop_cnt
  443.   %loop_upper_bound = sub i32 %idx_load2, %idx_load
  444.   br label %while
  445.  
  446. while:                                            ; preds = %while_body, %entry
  447.   %loop_cnt4 = load i32, i32* %loop_cnt
  448.   %loop_cond = icmp sle i32 %loop_cnt4, %loop_upper_bound
  449.   br i1 %loop_cond, label %while_body, label %merge
  450.  
  451. while_body:                                       ; preds = %while
  452.   %to_idx = load i32, i32* %loop_cnt
  453.   %from_idx = add i32 %to_idx, %idx_load
  454.   %list_get = call i8* @list_getstr({ i32*, i8** }* %list_ptr_ptr, i32 %from_idx)
  455.   call void @list_pushstr({ i32*, i8** }* %list_ptr_ptr2, i8* %list_get)
  456.   %loop_cnt3 = load i32, i32* %loop_cnt
  457.   %loop_itr = add i32 %loop_cnt3, 1
  458.   store i32 %loop_itr, i32* %loop_cnt
  459.   br label %while
  460.  
  461. merge:                                            ; preds = %while
  462.   ret void
  463. }
  464.  
  465. define i32 @list_findbool({ i32*, i1* }*, i1) {
  466. entry:
  467.   %list_ptr_alloc = alloca { i32*, i1* }*
  468.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  469.   %find_val_alloc = alloca i1
  470.   store i1 %1, i1* %find_val_alloc
  471.   %find_val = load i1, i1* %find_val_alloc
  472.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  473.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  474.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  475.   %list_size = load i32, i32* %list_size_ptr
  476.   %loop_cnt = alloca i32
  477.   store i32 0, i32* %loop_cnt
  478.   br label %while
  479.  
  480. while:                                            ; preds = %merge, %entry
  481.   %loop_iter_cnt = load i32, i32* %loop_cnt
  482.   %loop_cond = icmp slt i32 %loop_iter_cnt, %list_size
  483.   br i1 %loop_cond, label %while_body, label %merge1
  484.  
  485. while_body:                                       ; preds = %while
  486.   %to_idx = load i32, i32* %loop_cnt
  487.   %list_get = call i1 @list_getbool({ i32*, i1* }* %list_load, i32 %to_idx)
  488.   %if_cond = icmp eq i1 %list_get, %find_val
  489.   br i1 %if_cond, label %then, label %else
  490.  
  491. merge:                                            ; preds = %else
  492.   %loop_idx = load i32, i32* %loop_cnt
  493.   %loop_itr = add i32 %loop_idx, 1
  494.   store i32 %loop_itr, i32* %loop_cnt
  495.   br label %while
  496.  
  497. then:                                             ; preds = %while_body
  498.   ret i32 %to_idx
  499.  
  500. else:                                             ; preds = %while_body
  501.   br label %merge
  502.  
  503. merge1:                                           ; preds = %while
  504.   ret i32 -1
  505. }
  506.  
  507. define i32 @list_findint({ i32*, i32* }*, i32) {
  508. entry:
  509.   %list_ptr_alloc = alloca { i32*, i32* }*
  510.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  511.   %find_val_alloc = alloca i32
  512.   store i32 %1, i32* %find_val_alloc
  513.   %find_val = load i32, i32* %find_val_alloc
  514.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  515.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  516.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  517.   %list_size = load i32, i32* %list_size_ptr
  518.   %loop_cnt = alloca i32
  519.   store i32 0, i32* %loop_cnt
  520.   br label %while
  521.  
  522. while:                                            ; preds = %merge, %entry
  523.   %loop_iter_cnt = load i32, i32* %loop_cnt
  524.   %loop_cond = icmp slt i32 %loop_iter_cnt, %list_size
  525.   br i1 %loop_cond, label %while_body, label %merge1
  526.  
  527. while_body:                                       ; preds = %while
  528.   %to_idx = load i32, i32* %loop_cnt
  529.   %list_get = call i32 @list_getint({ i32*, i32* }* %list_load, i32 %to_idx)
  530.   %if_cond = icmp eq i32 %list_get, %find_val
  531.   br i1 %if_cond, label %then, label %else
  532.  
  533. merge:                                            ; preds = %else
  534.   %loop_idx = load i32, i32* %loop_cnt
  535.   %loop_itr = add i32 %loop_idx, 1
  536.   store i32 %loop_itr, i32* %loop_cnt
  537.   br label %while
  538.  
  539. then:                                             ; preds = %while_body
  540.   ret i32 %to_idx
  541.  
  542. else:                                             ; preds = %while_body
  543.   br label %merge
  544.  
  545. merge1:                                           ; preds = %while
  546.   ret i32 -1
  547. }
  548.  
  549. define i32 @list_findfloat({ i32*, double* }*, double) {
  550. entry:
  551.   %list_ptr_alloc = alloca { i32*, double* }*
  552.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  553.   %find_val_alloc = alloca double
  554.   store double %1, double* %find_val_alloc
  555.   %find_val = load double, double* %find_val_alloc
  556.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  557.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  558.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  559.   %list_size = load i32, i32* %list_size_ptr
  560.   %loop_cnt = alloca i32
  561.   store i32 0, i32* %loop_cnt
  562.   br label %while
  563.  
  564. while:                                            ; preds = %merge, %entry
  565.   %loop_iter_cnt = load i32, i32* %loop_cnt
  566.   %loop_cond = icmp slt i32 %loop_iter_cnt, %list_size
  567.   br i1 %loop_cond, label %while_body, label %merge1
  568.  
  569. while_body:                                       ; preds = %while
  570.   %to_idx = load i32, i32* %loop_cnt
  571.   %list_get = call double @list_getfloat({ i32*, double* }* %list_load, i32 %to_idx)
  572.   %if_cond = fcmp oeq double %list_get, %find_val
  573.   br i1 %if_cond, label %then, label %else
  574.  
  575. merge:                                            ; preds = %else
  576.   %loop_idx = load i32, i32* %loop_cnt
  577.   %loop_itr = add i32 %loop_idx, 1
  578.   store i32 %loop_itr, i32* %loop_cnt
  579.   br label %while
  580.  
  581. then:                                             ; preds = %while_body
  582.   ret i32 %to_idx
  583.  
  584. else:                                             ; preds = %while_body
  585.   br label %merge
  586.  
  587. merge1:                                           ; preds = %while
  588.   ret i32 -1
  589. }
  590.  
  591. define void @list_removebool({ i32*, i1* }*, i1) {
  592. entry:
  593.   %list_ptr_alloc = alloca { i32*, i1* }*
  594.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  595.   %rem_val_ptr = alloca i1
  596.   store i1 %1, i1* %rem_val_ptr
  597.   %rem_val = load i1, i1* %rem_val_ptr
  598.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  599.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  600.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  601.   %list_size = load i32, i32* %list_size_ptr
  602.   %list_find = call i32 @list_findbool({ i32*, i1* }* %list_load, i1 %rem_val)
  603.   %loop_cond = icmp sge i32 %list_find, 0
  604.   br i1 %loop_cond, label %then, label %else
  605.  
  606. merge:                                            ; preds = %else
  607.   ret void
  608.  
  609. then:                                             ; preds = %entry
  610.   %loop_cnt_ptr = alloca i32
  611.   %loop_start_idx = add i32 %list_find, 1
  612.   store i32 %loop_start_idx, i32* %loop_cnt_ptr
  613.   br label %while
  614.  
  615. while:                                            ; preds = %while_body, %then
  616.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  617.   %loop_cond1 = icmp slt i32 %loop_cnt, %list_size
  618.   br i1 %loop_cond1, label %while_body, label %merge2
  619.  
  620. while_body:                                       ; preds = %while
  621.   %cur_idx = load i32, i32* %loop_cnt_ptr
  622.   %shift_to_idx = sub i32 %cur_idx, 1
  623.   %list_get = call i1 @list_getbool({ i32*, i1* }* %list_load, i32 %cur_idx)
  624.   call void @list_setbool({ i32*, i1* }* %list_load, i32 %shift_to_idx, i1 %list_get)
  625.   %loop_itr = add i32 %cur_idx, 1
  626.   store i32 %loop_itr, i32* %loop_cnt_ptr
  627.   br label %while
  628.  
  629. merge2:                                           ; preds = %while
  630.   %size_dec = sub i32 %list_size, 1
  631.   store i32 %size_dec, i32* %list_size_ptr
  632.   ret void
  633.  
  634. else:                                             ; preds = %entry
  635.   br label %merge
  636. }
  637.  
  638. define void @list_removeint({ i32*, i32* }*, i32) {
  639. entry:
  640.   %list_ptr_alloc = alloca { i32*, i32* }*
  641.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  642.   %rem_val_ptr = alloca i32
  643.   store i32 %1, i32* %rem_val_ptr
  644.   %rem_val = load i32, i32* %rem_val_ptr
  645.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  646.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  647.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  648.   %list_size = load i32, i32* %list_size_ptr
  649.   %list_find = call i32 @list_findint({ i32*, i32* }* %list_load, i32 %rem_val)
  650.   %loop_cond = icmp sge i32 %list_find, 0
  651.   br i1 %loop_cond, label %then, label %else
  652.  
  653. merge:                                            ; preds = %else
  654.   ret void
  655.  
  656. then:                                             ; preds = %entry
  657.   %loop_cnt_ptr = alloca i32
  658.   %loop_start_idx = add i32 %list_find, 1
  659.   store i32 %loop_start_idx, i32* %loop_cnt_ptr
  660.   br label %while
  661.  
  662. while:                                            ; preds = %while_body, %then
  663.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  664.   %loop_cond1 = icmp slt i32 %loop_cnt, %list_size
  665.   br i1 %loop_cond1, label %while_body, label %merge2
  666.  
  667. while_body:                                       ; preds = %while
  668.   %cur_idx = load i32, i32* %loop_cnt_ptr
  669.   %shift_to_idx = sub i32 %cur_idx, 1
  670.   %list_get = call i32 @list_getint({ i32*, i32* }* %list_load, i32 %cur_idx)
  671.   call void @list_setint({ i32*, i32* }* %list_load, i32 %shift_to_idx, i32 %list_get)
  672.   %loop_itr = add i32 %cur_idx, 1
  673.   store i32 %loop_itr, i32* %loop_cnt_ptr
  674.   br label %while
  675.  
  676. merge2:                                           ; preds = %while
  677.   %size_dec = sub i32 %list_size, 1
  678.   store i32 %size_dec, i32* %list_size_ptr
  679.   ret void
  680.  
  681. else:                                             ; preds = %entry
  682.   br label %merge
  683. }
  684.  
  685. define void @list_removefloat({ i32*, double* }*, double) {
  686. entry:
  687.   %list_ptr_alloc = alloca { i32*, double* }*
  688.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  689.   %rem_val_ptr = alloca double
  690.   store double %1, double* %rem_val_ptr
  691.   %rem_val = load double, double* %rem_val_ptr
  692.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  693.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  694.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  695.   %list_size = load i32, i32* %list_size_ptr
  696.   %list_find = call i32 @list_findfloat({ i32*, double* }* %list_load, double %rem_val)
  697.   %loop_cond = icmp sge i32 %list_find, 0
  698.   br i1 %loop_cond, label %then, label %else
  699.  
  700. merge:                                            ; preds = %else
  701.   ret void
  702.  
  703. then:                                             ; preds = %entry
  704.   %loop_cnt_ptr = alloca i32
  705.   %loop_start_idx = add i32 %list_find, 1
  706.   store i32 %loop_start_idx, i32* %loop_cnt_ptr
  707.   br label %while
  708.  
  709. while:                                            ; preds = %while_body, %then
  710.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  711.   %loop_cond1 = icmp slt i32 %loop_cnt, %list_size
  712.   br i1 %loop_cond1, label %while_body, label %merge2
  713.  
  714. while_body:                                       ; preds = %while
  715.   %cur_idx = load i32, i32* %loop_cnt_ptr
  716.   %shift_to_idx = sub i32 %cur_idx, 1
  717.   %list_get = call double @list_getfloat({ i32*, double* }* %list_load, i32 %cur_idx)
  718.   call void @list_setfloat({ i32*, double* }* %list_load, i32 %shift_to_idx, double %list_get)
  719.   %loop_itr = add i32 %cur_idx, 1
  720.   store i32 %loop_itr, i32* %loop_cnt_ptr
  721.   br label %while
  722.  
  723. merge2:                                           ; preds = %while
  724.   %size_dec = sub i32 %list_size, 1
  725.   store i32 %size_dec, i32* %list_size_ptr
  726.   ret void
  727.  
  728. else:                                             ; preds = %entry
  729.   br label %merge
  730. }
  731.  
  732. define void @list_insertbool({ i32*, i1* }*, i32, i1) {
  733. entry:
  734.   %list_ptr_alloc = alloca { i32*, i1* }*
  735.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  736.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  737.   %insert_idx_ptr = alloca i32
  738.   store i32 %1, i32* %insert_idx_ptr
  739.   %insert_idx = load i32, i32* %insert_idx_ptr
  740.   %insert_val_ptr = alloca i1
  741.   store i1 %2, i1* %insert_val_ptr
  742.   %insert_val = load i1, i1* %insert_val_ptr
  743.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  744.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  745.   %list_size = load i32, i32* %list_size_ptr
  746.   %loop_cnt_ptr = alloca i32
  747.   %last_index = sub i32 %list_size, 1
  748.   store i32 %last_index, i32* %loop_cnt_ptr
  749.   br label %while
  750.  
  751. while:                                            ; preds = %while_body, %entry
  752.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  753.   %loop_cond = icmp sge i32 %loop_cnt, %insert_idx
  754.   br i1 %loop_cond, label %while_body, label %merge
  755.  
  756. while_body:                                       ; preds = %while
  757.   %cur_idx = load i32, i32* %loop_cnt_ptr
  758.   %shift_to_idx = add i32 %cur_idx, 1
  759.   %list_get = call i1 @list_getbool({ i32*, i1* }* %list_load, i32 %cur_idx)
  760.   call void @list_setbool({ i32*, i1* }* %list_load, i32 %shift_to_idx, i1 %list_get)
  761.   %loop_itr = sub i32 %cur_idx, 1
  762.   store i32 %loop_itr, i32* %loop_cnt_ptr
  763.   br label %while
  764.  
  765. merge:                                            ; preds = %while
  766.   call void @list_setbool({ i32*, i1* }* %list_load, i32 %insert_idx, i1 %insert_val)
  767.   %size_inc = add i32 %list_size, 1
  768.   store i32 %size_inc, i32* %list_size_ptr
  769.   ret void
  770. }
  771.  
  772. define void @list_insertint({ i32*, i32* }*, i32, i32) {
  773. entry:
  774.   %list_ptr_alloc = alloca { i32*, i32* }*
  775.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  776.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  777.   %insert_idx_ptr = alloca i32
  778.   store i32 %1, i32* %insert_idx_ptr
  779.   %insert_idx = load i32, i32* %insert_idx_ptr
  780.   %insert_val_ptr = alloca i32
  781.   store i32 %2, i32* %insert_val_ptr
  782.   %insert_val = load i32, i32* %insert_val_ptr
  783.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  784.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  785.   %list_size = load i32, i32* %list_size_ptr
  786.   %loop_cnt_ptr = alloca i32
  787.   %last_index = sub i32 %list_size, 1
  788.   store i32 %last_index, i32* %loop_cnt_ptr
  789.   br label %while
  790.  
  791. while:                                            ; preds = %while_body, %entry
  792.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  793.   %loop_cond = icmp sge i32 %loop_cnt, %insert_idx
  794.   br i1 %loop_cond, label %while_body, label %merge
  795.  
  796. while_body:                                       ; preds = %while
  797.   %cur_idx = load i32, i32* %loop_cnt_ptr
  798.   %shift_to_idx = add i32 %cur_idx, 1
  799.   %list_get = call i32 @list_getint({ i32*, i32* }* %list_load, i32 %cur_idx)
  800.   call void @list_setint({ i32*, i32* }* %list_load, i32 %shift_to_idx, i32 %list_get)
  801.   %loop_itr = sub i32 %cur_idx, 1
  802.   store i32 %loop_itr, i32* %loop_cnt_ptr
  803.   br label %while
  804.  
  805. merge:                                            ; preds = %while
  806.   call void @list_setint({ i32*, i32* }* %list_load, i32 %insert_idx, i32 %insert_val)
  807.   %size_inc = add i32 %list_size, 1
  808.   store i32 %size_inc, i32* %list_size_ptr
  809.   ret void
  810. }
  811.  
  812. define void @list_insertfloat({ i32*, double* }*, i32, double) {
  813. entry:
  814.   %list_ptr_alloc = alloca { i32*, double* }*
  815.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  816.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  817.   %insert_idx_ptr = alloca i32
  818.   store i32 %1, i32* %insert_idx_ptr
  819.   %insert_idx = load i32, i32* %insert_idx_ptr
  820.   %insert_val_ptr = alloca double
  821.   store double %2, double* %insert_val_ptr
  822.   %insert_val = load double, double* %insert_val_ptr
  823.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  824.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  825.   %list_size = load i32, i32* %list_size_ptr
  826.   %loop_cnt_ptr = alloca i32
  827.   %last_index = sub i32 %list_size, 1
  828.   store i32 %last_index, i32* %loop_cnt_ptr
  829.   br label %while
  830.  
  831. while:                                            ; preds = %while_body, %entry
  832.   %loop_cnt = load i32, i32* %loop_cnt_ptr
  833.   %loop_cond = icmp sge i32 %loop_cnt, %insert_idx
  834.   br i1 %loop_cond, label %while_body, label %merge
  835.  
  836. while_body:                                       ; preds = %while
  837.   %cur_idx = load i32, i32* %loop_cnt_ptr
  838.   %shift_to_idx = add i32 %cur_idx, 1
  839.   %list_get = call double @list_getfloat({ i32*, double* }* %list_load, i32 %cur_idx)
  840.   call void @list_setfloat({ i32*, double* }* %list_load, i32 %shift_to_idx, double %list_get)
  841.   %loop_itr = sub i32 %cur_idx, 1
  842.   store i32 %loop_itr, i32* %loop_cnt_ptr
  843.   br label %while
  844.  
  845. merge:                                            ; preds = %while
  846.   call void @list_setfloat({ i32*, double* }* %list_load, i32 %insert_idx, double %insert_val)
  847.   %size_inc = add i32 %list_size, 1
  848.   store i32 %size_inc, i32* %list_size_ptr
  849.   ret void
  850. }
  851.  
  852. define void @list_reversebool({ i32*, i1* }*) {
  853. entry:
  854.   %list_ptr_alloc = alloca { i32*, i1* }*
  855.   store { i32*, i1* }* %0, { i32*, i1* }** %list_ptr_alloc
  856.   %list_load = load { i32*, i1* }*, { i32*, i1* }** %list_ptr_alloc
  857.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i1* }, { i32*, i1* }* %list_load, i32 0, i32 0
  858.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  859.   %list_size = load i32, i32* %list_size_ptr
  860.   %left_idx = alloca i32
  861.   store i32 0, i32* %left_idx
  862.   %right_idx = alloca i32
  863.   %tmp = sub i32 %list_size, 1
  864.   store i32 %tmp, i32* %right_idx
  865.   br label %while
  866.  
  867. while:                                            ; preds = %while_body, %entry
  868.   %right_idx6 = load i32, i32* %right_idx
  869.   %left_idx7 = load i32, i32* %left_idx
  870.   %while_cond = icmp slt i32 %left_idx7, %right_idx6
  871.   br i1 %while_cond, label %while_body, label %merge
  872.  
  873. while_body:                                       ; preds = %while
  874.   %left_idx1 = load i32, i32* %left_idx
  875.   %right_idx2 = load i32, i32* %right_idx
  876.   %list_get = call i1 @list_getbool({ i32*, i1* }* %list_load, i32 %left_idx1)
  877.   %list_get3 = call i1 @list_getbool({ i32*, i1* }* %list_load, i32 %right_idx2)
  878.   call void @list_setbool({ i32*, i1* }* %list_load, i32 %left_idx1, i1 %list_get3)
  879.   call void @list_setbool({ i32*, i1* }* %list_load, i32 %right_idx2, i1 %list_get)
  880.   %tmp4 = add i32 %left_idx1, 1
  881.   store i32 %tmp4, i32* %left_idx
  882.   %tmp5 = sub i32 %right_idx2, 1
  883.   store i32 %tmp5, i32* %right_idx
  884.   br label %while
  885.  
  886. merge:                                            ; preds = %while
  887.   ret void
  888. }
  889.  
  890. define void @list_reverseint({ i32*, i32* }*) {
  891. entry:
  892.   %list_ptr_alloc = alloca { i32*, i32* }*
  893.   store { i32*, i32* }* %0, { i32*, i32* }** %list_ptr_alloc
  894.   %list_load = load { i32*, i32* }*, { i32*, i32* }** %list_ptr_alloc
  895.   %list_size_ptr_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %list_load, i32 0, i32 0
  896.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  897.   %list_size = load i32, i32* %list_size_ptr
  898.   %left_idx = alloca i32
  899.   store i32 0, i32* %left_idx
  900.   %right_idx = alloca i32
  901.   %tmp = sub i32 %list_size, 1
  902.   store i32 %tmp, i32* %right_idx
  903.   br label %while
  904.  
  905. while:                                            ; preds = %while_body, %entry
  906.   %right_idx6 = load i32, i32* %right_idx
  907.   %left_idx7 = load i32, i32* %left_idx
  908.   %while_cond = icmp slt i32 %left_idx7, %right_idx6
  909.   br i1 %while_cond, label %while_body, label %merge
  910.  
  911. while_body:                                       ; preds = %while
  912.   %left_idx1 = load i32, i32* %left_idx
  913.   %right_idx2 = load i32, i32* %right_idx
  914.   %list_get = call i32 @list_getint({ i32*, i32* }* %list_load, i32 %left_idx1)
  915.   %list_get3 = call i32 @list_getint({ i32*, i32* }* %list_load, i32 %right_idx2)
  916.   call void @list_setint({ i32*, i32* }* %list_load, i32 %left_idx1, i32 %list_get3)
  917.   call void @list_setint({ i32*, i32* }* %list_load, i32 %right_idx2, i32 %list_get)
  918.   %tmp4 = add i32 %left_idx1, 1
  919.   store i32 %tmp4, i32* %left_idx
  920.   %tmp5 = sub i32 %right_idx2, 1
  921.   store i32 %tmp5, i32* %right_idx
  922.   br label %while
  923.  
  924. merge:                                            ; preds = %while
  925.   ret void
  926. }
  927.  
  928. define void @list_reversefloat({ i32*, double* }*) {
  929. entry:
  930.   %list_ptr_alloc = alloca { i32*, double* }*
  931.   store { i32*, double* }* %0, { i32*, double* }** %list_ptr_alloc
  932.   %list_load = load { i32*, double* }*, { i32*, double* }** %list_ptr_alloc
  933.   %list_size_ptr_ptr = getelementptr inbounds { i32*, double* }, { i32*, double* }* %list_load, i32 0, i32 0
  934.   %list_size_ptr = load i32*, i32** %list_size_ptr_ptr
  935.   %list_size = load i32, i32* %list_size_ptr
  936.   %left_idx = alloca i32
  937.   store i32 0, i32* %left_idx
  938.   %right_idx = alloca i32
  939.   %tmp = sub i32 %list_size, 1
  940.   store i32 %tmp, i32* %right_idx
  941.   br label %while
  942.  
  943. while:                                            ; preds = %while_body, %entry
  944.   %right_idx6 = load i32, i32* %right_idx
  945.   %left_idx7 = load i32, i32* %left_idx
  946.   %while_cond = icmp slt i32 %left_idx7, %right_idx6
  947.   br i1 %while_cond, label %while_body, label %merge
  948.  
  949. while_body:                                       ; preds = %while
  950.   %left_idx1 = load i32, i32* %left_idx
  951.   %right_idx2 = load i32, i32* %right_idx
  952.   %list_get = call double @list_getfloat({ i32*, double* }* %list_load, i32 %left_idx1)
  953.   %list_get3 = call double @list_getfloat({ i32*, double* }* %list_load, i32 %right_idx2)
  954.   call void @list_setfloat({ i32*, double* }* %list_load, i32 %left_idx1, double %list_get3)
  955.   call void @list_setfloat({ i32*, double* }* %list_load, i32 %right_idx2, double %list_get)
  956.   %tmp4 = add i32 %left_idx1, 1
  957.   store i32 %tmp4, i32* %left_idx
  958.   %tmp5 = sub i32 %right_idx2, 1
  959.   store i32 %tmp5, i32* %right_idx
  960.   br label %while
  961.  
  962. merge:                                            ; preds = %while
  963.   ret void
  964. }
  965.  
  966. define i32 @main() {
  967. entry:
  968.   %a = alloca { i32*, i32* }
  969.   %list_size_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %a, i32 0, i32 0
  970.   %list_size = alloca i32
  971.   store i32 0, i32* %list_size
  972.   store i32* %list_size, i32** %list_size_ptr
  973.   %list.arry = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %a, i32 0, i32 1
  974.   %p = alloca i32, i32 1028
  975.   store i32* %p, i32** %list.arry
  976.   %i = alloca i32
  977.   %new_list_ptr = alloca { i32*, i32* }
  978.   %list_size_ptr1 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %new_list_ptr, i32 0, i32 0
  979.   %list_size2 = alloca i32
  980.   store i32 0, i32* %list_size2
  981.   store i32* %list_size2, i32** %list_size_ptr1
  982.   %list.arry3 = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %new_list_ptr, i32 0, i32 1
  983.   %p4 = alloca i32, i32 1028
  984.   store i32* %p4, i32** %list.arry3
  985.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 10)
  986.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 2)
  987.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 15)
  988.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 8)
  989.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 20)
  990.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 13)
  991.   call void @list_pushint({ i32*, i32* }* %new_list_ptr, i32 9)
  992.   %new_list = load { i32*, i32* }, { i32*, i32* }* %new_list_ptr
  993.   store { i32*, i32* } %new_list, { i32*, i32* }* %a
  994.   %a5 = load { i32*, i32* }, { i32*, i32* }* %a
  995.   call void @bubbleSort({ i32*, i32* } %a5)
  996.   store i32 0, i32* %i
  997.   br label %while
  998.  
  999. while:                                            ; preds = %while_body, %entry
  1000.   %i8 = load i32, i32* %i
  1001.   %list_size9 = call i32 @list_sizeint({ i32*, i32* }* %a)
  1002.   %tmp10 = icmp slt i32 %i8, %list_size9
  1003.   br i1 %tmp10, label %while_body, label %merge
  1004.  
  1005. while_body:                                       ; preds = %while
  1006.   %i6 = load i32, i32* %i
  1007.   %list_get = call i32 @list_getint({ i32*, i32* }* %a, i32 %i6)
  1008.   %printf = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @fmt, i32 0, i32 0), i32 %list_get)
  1009.   %i7 = load i32, i32* %i
  1010.   %tmp = add i32 %i7, 1
  1011.   store i32 %tmp, i32* %i
  1012.   br label %while
  1013.  
  1014. merge:                                            ; preds = %while
  1015.   ret i32 0
  1016. }
  1017.  
  1018. define void @bubbleSort({ i32*, i32* } %arr) {
  1019. entry:
  1020.   %arr1 = alloca { i32*, i32* }
  1021.   %list_size_ptr = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %arr1, i32 0, i32 0
  1022.   %list_size = alloca i32
  1023.   store i32 0, i32* %list_size
  1024.   store i32* %list_size, i32** %list_size_ptr
  1025.   %list.arry = getelementptr inbounds { i32*, i32* }, { i32*, i32* }* %arr1, i32 0, i32 1
  1026.   %p = alloca i32, i32 1028
  1027.   store i32* %p, i32** %list.arry
  1028.   store { i32*, i32* } %arr, { i32*, i32* }* %arr1
  1029.   %i = alloca i32
  1030.   %j = alloca i32
  1031.   %tmp = alloca i32
  1032.   store i32 0, i32* %i
  1033.   br label %while
  1034.  
  1035. while:                                            ; preds = %merge26, %entry
  1036.   %i29 = load i32, i32* %i
  1037.   %list_size30 = call i32 @list_sizeint({ i32*, i32* }* %arr1)
  1038.   %tmp31 = sub i32 %list_size30, 1
  1039.   %tmp32 = icmp slt i32 %i29, %tmp31
  1040.   br i1 %tmp32, label %while_body, label %merge33
  1041.  
  1042. while_body:                                       ; preds = %while
  1043.   store i32 0, i32* %j
  1044.   br label %while2
  1045.  
  1046. while2:                                           ; preds = %merge, %while_body
  1047.   %j20 = load i32, i32* %j
  1048.   %list_size21 = call i32 @list_sizeint({ i32*, i32* }* %arr1)
  1049.   %i22 = load i32, i32* %i
  1050.   %tmp23 = sub i32 %list_size21, %i22
  1051.   %tmp24 = sub i32 %tmp23, 1
  1052.   %tmp25 = icmp slt i32 %j20, %tmp24
  1053.   br i1 %tmp25, label %while_body3, label %merge26
  1054.  
  1055. while_body3:                                      ; preds = %while2
  1056.   %j4 = load i32, i32* %j
  1057.   %list_get = call i32 @list_getint({ i32*, i32* }* %arr1, i32 %j4)
  1058.   %j5 = load i32, i32* %j
  1059.   %tmp6 = add i32 %j5, 1
  1060.   %list_get7 = call i32 @list_getint({ i32*, i32* }* %arr1, i32 %tmp6)
  1061.   %tmp8 = icmp sgt i32 %list_get, %list_get7
  1062.   br i1 %tmp8, label %then, label %else
  1063.  
  1064. merge:                                            ; preds = %else, %then
  1065.   %j18 = load i32, i32* %j
  1066.   %tmp19 = add i32 %j18, 1
  1067.   store i32 %tmp19, i32* %j
  1068.   br label %while2
  1069.  
  1070. then:                                             ; preds = %while_body3
  1071.   %j9 = load i32, i32* %j
  1072.   %list_get10 = call i32 @list_getint({ i32*, i32* }* %arr1, i32 %j9)
  1073.   store i32 %list_get10, i32* %tmp
  1074.   %j11 = load i32, i32* %j
  1075.   %tmp12 = add i32 %j11, 1
  1076.   %list_get13 = call i32 @list_getint({ i32*, i32* }* %arr1, i32 %tmp12)
  1077.   %j14 = load i32, i32* %j
  1078.   call void @list_setint({ i32*, i32* }* %arr1, i32 %j14, i32 %list_get13)
  1079.   %tmp15 = load i32, i32* %tmp
  1080.   %j16 = load i32, i32* %j
  1081.   %tmp17 = add i32 %j16, 1
  1082.   call void @list_setint({ i32*, i32* }* %arr1, i32 %tmp17, i32 %tmp15)
  1083.   br label %merge
  1084.  
  1085. else:                                             ; preds = %while_body3
  1086.   br label %merge
  1087.  
  1088. merge26:                                          ; preds = %while2
  1089.   %i27 = load i32, i32* %i
  1090.   %tmp28 = add i32 %i27, 1
  1091.   store i32 %tmp28, i32* %i
  1092.   br label %while
  1093.  
  1094. merge33:                                          ; preds = %while
  1095.   ret void
  1096. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement