Advertisement
amitsp21

Untitled

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