main.ll 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140
  1. %.string = type {i8*, i64} ; Basic_string
  2. %.rawptr = type i8* ; Basic_rawptr
  3. %HANDLE = type %.rawptr
  4. %HWND = type %.rawptr
  5. %HDC = type %.rawptr
  6. %HINSTANCE = type %.rawptr
  7. %HICON = type %.rawptr
  8. %HCURSOR = type %.rawptr
  9. %HMENU = type %.rawptr
  10. %WPARAM = type i64
  11. %LPARAM = type i64
  12. %LRESULT = type i64
  13. %ATOM = type i16
  14. %POINT = type {i32, i32}
  15. %BOOL = type i32
  16. %WNDPROC = type %LRESULT (%HWND, i32, %WPARAM, %LPARAM)*
  17. %WNDCLASSEXA = type {i32, i32, %WNDPROC, i32, i32, %HINSTANCE, %HICON, %HCURSOR, %HANDLE, i8*, i8*, %HICON}
  18. %MSG = type {%HWND, i32, %WPARAM, %LPARAM, i32, %POINT}
  19. declare void @llvm.memmove.p0i8.p0i8.i64(i8*, i8*, i64, i32, i1) argmemonly nounwind
  20. define void @main() {
  21. entry.-.0:
  22. %0 = alloca %WNDCLASSEXA, align 8 ; wc
  23. store %WNDCLASSEXA zeroinitializer, %WNDCLASSEXA* %0
  24. %1 = alloca %HINSTANCE, align 8 ; instance
  25. store %HINSTANCE zeroinitializer, %HINSTANCE* %1
  26. %2 = call %HINSTANCE @GetModuleHandleA(i8* null)
  27. store %HINSTANCE %2, %HINSTANCE* %1
  28. %3 = alloca i8*, align 8 ; class_name
  29. store i8* zeroinitializer, i8** %3
  30. %4 = getelementptr inbounds [18 x i8], [18 x i8]* @.str0, i64 0, i64 0
  31. %5 = alloca %.string, align 8
  32. store %.string zeroinitializer, %.string* %5
  33. %6 = getelementptr inbounds %.string, %.string* %5, i64 0, i32 0
  34. %7 = getelementptr inbounds %.string, %.string* %5, i64 0, i32 1
  35. store i8* %4, i8** %6
  36. store i64 18, i64* %7
  37. %8 = load %.string, %.string* %5, align 8
  38. %9 = call i8* @main$to_c_string-0(%.string %8)
  39. store i8* %9, i8** %3
  40. %10 = alloca i8*, align 8 ; title
  41. store i8* zeroinitializer, i8** %10
  42. %11 = getelementptr inbounds [18 x i8], [18 x i8]* @.str1, i64 0, i64 0
  43. %12 = alloca %.string, align 8
  44. store %.string zeroinitializer, %.string* %12
  45. %13 = getelementptr inbounds %.string, %.string* %12, i64 0, i32 0
  46. %14 = getelementptr inbounds %.string, %.string* %12, i64 0, i32 1
  47. store i8* %11, i8** %13
  48. store i64 18, i64* %14
  49. %15 = load %.string, %.string* %12, align 8
  50. %16 = call i8* @main$to_c_string-0(%.string %15)
  51. store i8* %16, i8** %10
  52. %17 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0, i64 0, i32 0
  53. store i32 80, i32* %17
  54. %18 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0, i64 0, i32 1
  55. store i32 3, i32* %18
  56. %19 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0, i64 0, i32 5
  57. %20 = load %HINSTANCE, %HINSTANCE* %1, align 8
  58. store %HINSTANCE %20, %HINSTANCE* %19
  59. %21 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0, i64 0, i32 10
  60. %22 = load i8*, i8** %3, align 8
  61. store i8* %22, i8** %21
  62. %23 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0, i64 0, i32 2
  63. store %WNDPROC @main$1, %WNDPROC* %23
  64. %24 = getelementptr inbounds %WNDCLASSEXA, %WNDCLASSEXA* %0
  65. %25 = call %ATOM @RegisterClassExA(%WNDCLASSEXA* %24)
  66. %26 = icmp eq i16 %25, 0
  67. br i1 %26, label %if.then.-.1, label %if.done.-.2
  68. if.then.-.1:
  69. ret void
  70. if.done.-.2:
  71. %27 = alloca %HWND, align 8 ; hwnd
  72. store %HWND zeroinitializer, %HWND* %27
  73. %28 = load i8*, i8** %3, align 8
  74. %29 = load i8*, i8** %10, align 8
  75. %30 = load %HINSTANCE, %HINSTANCE* %1, align 8
  76. %31 = call %HWND @CreateWindowExA(i32 0, i8* %28, i8* %29, i32 281673728, i32 0, i32 0, i32 854, i32 480, %HWND null, %HMENU null, %HINSTANCE %30, %.rawptr null)
  77. store %HWND %31, %HWND* %27
  78. %32 = load %HWND, %HWND* %27, align 8
  79. %33 = icmp eq %.rawptr %32, null
  80. br i1 %33, label %if.then.-.3, label %if.done.-.4
  81. if.then.-.3:
  82. %34 = getelementptr inbounds [14 x i8], [14 x i8]* @.str2, i64 0, i64 0
  83. %35 = alloca %.string, align 8
  84. store %.string zeroinitializer, %.string* %35
  85. %36 = getelementptr inbounds %.string, %.string* %35, i64 0, i32 0
  86. %37 = getelementptr inbounds %.string, %.string* %35, i64 0, i32 1
  87. store i8* %34, i8** %36
  88. store i64 14, i64* %37
  89. %38 = load %.string, %.string* %35, align 8
  90. call void @print_string(%.string %38)
  91. %39 = call i32 @GetLastError()
  92. %40 = zext i32 %39 to i64
  93. call void @print_int(i64 %40)
  94. %41 = getelementptr inbounds [1 x i8], [1 x i8]* @.str3, i64 0, i64 0
  95. %42 = alloca %.string, align 8
  96. store %.string zeroinitializer, %.string* %42
  97. %43 = getelementptr inbounds %.string, %.string* %42, i64 0, i32 0
  98. %44 = getelementptr inbounds %.string, %.string* %42, i64 0, i32 1
  99. store i8* %41, i8** %43
  100. store i64 1, i64* %44
  101. %45 = load %.string, %.string* %42, align 8
  102. call void @print_string(%.string %45)
  103. ret void
  104. if.done.-.4:
  105. %46 = alloca %MSG, align 8 ; msg
  106. store %MSG zeroinitializer, %MSG* %46
  107. br label %for.body.-.5
  108. for.body.-.5:
  109. %47 = alloca %BOOL, align 4 ; ok
  110. store %BOOL zeroinitializer, %BOOL* %47
  111. %48 = getelementptr inbounds %MSG, %MSG* %46
  112. %49 = call %BOOL @PeekMessageA(%MSG* %48, %HWND null, i32 0, i32 0, i32 1)
  113. store %BOOL %49, %BOOL* %47
  114. %50 = load %BOOL, %BOOL* %47, align 4
  115. %51 = icmp eq i32 %50, 0
  116. br i1 %51, label %if.then.-.6, label %if.done.-.7
  117. if.then.-.6:
  118. br label %for.done.-.11
  119. if.done.-.7:
  120. %52 = getelementptr inbounds %MSG, %MSG* %46, i64 0, i32 1
  121. %53 = load i32, i32* %52, align 4
  122. %54 = icmp eq i32 %53, 18
  123. br i1 %54, label %if.then.-.8, label %if.else.-.9
  124. if.then.-.8:
  125. ret void
  126. if.else.-.9:
  127. %55 = getelementptr inbounds %MSG, %MSG* %46
  128. %56 = call %BOOL @TranslateMessage(%MSG* %55)
  129. %57 = getelementptr inbounds %MSG, %MSG* %46
  130. %58 = call %LRESULT @DispatchMessageA(%MSG* %57)
  131. br label %if.done.-.10
  132. if.done.-.10:
  133. br label %for.body.-.5
  134. for.done.-.11:
  135. ret void
  136. }
  137. define i8* @main$to_c_string-0(%.string %s) {
  138. entry.-.0:
  139. %0 = alloca %.string, align 8 ; s
  140. store %.string zeroinitializer, %.string* %0
  141. store %.string %s, %.string* %0
  142. %1 = alloca i8*, align 8 ; c_str
  143. store i8* zeroinitializer, i8** %1
  144. %2 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  145. %3 = load i64, i64* %2, align 8
  146. %4 = add i64 %3, 1
  147. %5 = call %.rawptr @malloc(i64 %4)
  148. %6 = bitcast %.rawptr %5 to i8*
  149. store i8* %6, i8** %1
  150. %7 = load i8*, i8** %1, align 8
  151. %8 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 0
  152. %9 = load i8*, i8** %8, align 8
  153. %10 = getelementptr i8, i8* %9, i64 0
  154. %11 = getelementptr inbounds i8, i8* %10
  155. %12 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  156. %13 = load i64, i64* %12, align 8
  157. %14 = call i32 @memcpy(%.rawptr %7, %.rawptr %11, i64 %13)
  158. %15 = load i8*, i8** %1, align 8
  159. %16 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  160. %17 = load i64, i64* %16, align 8
  161. %18 = getelementptr i8, i8* %15, i64 %17
  162. store i8 0, i8* %18
  163. %19 = load i8*, i8** %1, align 8
  164. ret i8* %19
  165. }
  166. define %LRESULT @main$1(%HWND %hwnd, i32 %msg, %WPARAM %wparam, %LPARAM %lparam) noinline {
  167. entry.-.0:
  168. %0 = alloca %HWND, align 8 ; hwnd
  169. store %HWND zeroinitializer, %HWND* %0
  170. store %HWND %hwnd, %HWND* %0
  171. %1 = alloca i32, align 4 ; msg
  172. store i32 zeroinitializer, i32* %1
  173. store i32 %msg, i32* %1
  174. %2 = alloca %WPARAM, align 8 ; wparam
  175. store %WPARAM zeroinitializer, %WPARAM* %2
  176. store %WPARAM %wparam, %WPARAM* %2
  177. %3 = alloca %LPARAM, align 8 ; lparam
  178. store %LPARAM zeroinitializer, %LPARAM* %3
  179. store %LPARAM %lparam, %LPARAM* %3
  180. %4 = load i32, i32* %1, align 4
  181. %5 = icmp eq i32 %4, 2
  182. br i1 %5, label %if.then.-.1, label %cmp-or.-.3
  183. if.then.-.1:
  184. call void @ExitProcess(i32 0)
  185. ret %LRESULT 0
  186. cmp-or.-.2:
  187. %6 = load i32, i32* %1, align 4
  188. %7 = icmp eq i32 %6, 18
  189. br i1 %7, label %if.then.-.1, label %if.done.-.4
  190. cmp-or.-.3:
  191. %8 = load i32, i32* %1, align 4
  192. %9 = icmp eq i32 %8, 16
  193. br i1 %9, label %if.then.-.1, label %cmp-or.-.2
  194. if.done.-.4:
  195. %10 = load %HWND, %HWND* %0, align 8
  196. %11 = load i32, i32* %1, align 4
  197. %12 = load %WPARAM, %WPARAM* %2, align 8
  198. %13 = load %LPARAM, %LPARAM* %3, align 8
  199. %14 = call %LRESULT @DefWindowProcA(%HWND %10, i32 %11, %WPARAM %12, %LPARAM %13)
  200. ret i64 %14
  201. }
  202. define void @print_string(%.string %s) {
  203. entry.-.0:
  204. %0 = alloca %.string, align 8 ; s
  205. store %.string zeroinitializer, %.string* %0
  206. store %.string %s, %.string* %0
  207. br label %for.init.-.1
  208. for.init.-.1:
  209. %1 = alloca i64, align 8 ; i
  210. store i64 zeroinitializer, i64* %1
  211. store i64 0, i64* %1
  212. br label %for.loop.-.3
  213. for.body.-.2:
  214. %2 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 0
  215. %3 = load i8*, i8** %2, align 8
  216. %4 = load i64, i64* %1, align 8
  217. %5 = getelementptr i8, i8* %3, i64 %4
  218. %6 = load i8, i8* %5, align 1
  219. %7 = zext i8 %6 to i32
  220. %8 = call i32 @putchar(i32 %7)
  221. br label %for.post.-.4
  222. for.loop.-.3:
  223. %9 = load i64, i64* %1, align 8
  224. %10 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  225. %11 = load i64, i64* %10, align 8
  226. %12 = icmp slt i64 %9, %11
  227. br i1 %12, label %for.body.-.2, label %for.done.-.5
  228. for.post.-.4:
  229. %13 = load i64, i64* %1, align 8
  230. %14 = add i64 %13, 1
  231. store i64 %14, i64* %1
  232. br label %for.loop.-.3
  233. for.done.-.5:
  234. ret void
  235. }
  236. define void @byte_reverse({i8*, i64, i64} %b) {
  237. entry.-.0:
  238. %0 = alloca {i8*, i64, i64}, align 8 ; b
  239. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %0
  240. store {i8*, i64, i64} %b, {i8*, i64, i64}* %0
  241. %1 = alloca i64, align 8 ; n
  242. store i64 zeroinitializer, i64* %1
  243. %2 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %0, i64 0, i32 1
  244. %3 = load i64, i64* %2, align 8
  245. store i64 %3, i64* %1
  246. br label %for.init.-.1
  247. for.init.-.1:
  248. %4 = alloca i64, align 8 ; i
  249. store i64 zeroinitializer, i64* %4
  250. store i64 0, i64* %4
  251. br label %for.loop.-.3
  252. for.body.-.2:
  253. %5 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %0, i64 0, i32 0
  254. %6 = load i8*, i8** %5, align 8
  255. %7 = load i64, i64* %4, align 8
  256. %8 = getelementptr i8, i8* %6, i64 %7
  257. %9 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %0, i64 0, i32 0
  258. %10 = load i8*, i8** %9, align 8
  259. %11 = load i64, i64* %4, align 8
  260. %12 = load i64, i64* %1, align 8
  261. %13 = sub i64 %12, 1
  262. %14 = sub i64 %13, %11
  263. %15 = getelementptr i8, i8* %10, i64 %14
  264. %16 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %0, i64 0, i32 0
  265. %17 = load i8*, i8** %16, align 8
  266. %18 = load i64, i64* %4, align 8
  267. %19 = load i64, i64* %1, align 8
  268. %20 = sub i64 %19, 1
  269. %21 = sub i64 %20, %18
  270. %22 = getelementptr i8, i8* %17, i64 %21
  271. %23 = load i8, i8* %22, align 1
  272. %24 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %0, i64 0, i32 0
  273. %25 = load i8*, i8** %24, align 8
  274. %26 = load i64, i64* %4, align 8
  275. %27 = getelementptr i8, i8* %25, i64 %26
  276. %28 = load i8, i8* %27, align 1
  277. store i8 %23, i8* %8
  278. store i8 %28, i8* %15
  279. br label %for.post.-.4
  280. for.loop.-.3:
  281. %29 = load i64, i64* %4, align 8
  282. %30 = load i64, i64* %1, align 8
  283. %31 = sdiv i64 %30, 2
  284. %32 = icmp slt i64 %29, %31
  285. br i1 %32, label %for.body.-.2, label %for.done.-.5
  286. for.post.-.4:
  287. %33 = load i64, i64* %4, align 8
  288. %34 = add i64 %33, 1
  289. store i64 %34, i64* %4
  290. br label %for.loop.-.3
  291. for.done.-.5:
  292. ret void
  293. }
  294. define {[4 x i8], i64} @encode_rune(i32 %r) {
  295. entry.-.0:
  296. %0 = alloca i32, align 4 ; r
  297. store i32 zeroinitializer, i32* %0
  298. store i32 %r, i32* %0
  299. %1 = alloca [4 x i8], align 1 ; buf
  300. store [4 x i8] zeroinitializer, [4 x i8]* %1
  301. %2 = alloca i32, align 4 ; i
  302. store i32 zeroinitializer, i32* %2
  303. %3 = load i32, i32* %0, align 4
  304. store i32 %3, i32* %2
  305. %4 = load i32, i32* %2, align 4
  306. %5 = icmp ule i32 %4, 127
  307. br i1 %5, label %if.then.-.1, label %if.done.-.2
  308. if.then.-.1:
  309. %6 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  310. %7 = getelementptr i8, i8* %6, i64 0
  311. %8 = load i32, i32* %0, align 4
  312. %9 = trunc i32 %8 to i8
  313. store i8 %9, i8* %7
  314. %10 = alloca {[4 x i8], i64}, align 8
  315. store {[4 x i8], i64} zeroinitializer, {[4 x i8], i64}* %10
  316. %11 = load [4 x i8], [4 x i8]* %1, align 1
  317. %12 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %10, i64 0, i32 0
  318. store [4 x i8] %11, [4 x i8]* %12
  319. %13 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %10, i64 0, i32 1
  320. store i64 1, i64* %13
  321. %14 = load {[4 x i8], i64}, {[4 x i8], i64}* %10, align 8
  322. ret {[4 x i8], i64} %14
  323. if.done.-.2:
  324. %15 = load i32, i32* %2, align 4
  325. %16 = icmp ule i32 %15, 2047
  326. br i1 %16, label %if.then.-.3, label %if.done.-.4
  327. if.then.-.3:
  328. %17 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  329. %18 = getelementptr i8, i8* %17, i64 0
  330. %19 = load i32, i32* %0, align 4
  331. %20 = lshr i32 %19, 6
  332. %21 = trunc i32 %20 to i8
  333. %22 = or i8 192, %21
  334. store i8 %22, i8* %18
  335. %23 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  336. %24 = getelementptr i8, i8* %23, i64 1
  337. %25 = load i32, i32* %0, align 4
  338. %26 = trunc i32 %25 to i8
  339. %27 = and i8 %26, 63
  340. %28 = or i8 128, %27
  341. store i8 %28, i8* %24
  342. %29 = alloca {[4 x i8], i64}, align 8
  343. store {[4 x i8], i64} zeroinitializer, {[4 x i8], i64}* %29
  344. %30 = load [4 x i8], [4 x i8]* %1, align 1
  345. %31 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %29, i64 0, i32 0
  346. store [4 x i8] %30, [4 x i8]* %31
  347. %32 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %29, i64 0, i32 1
  348. store i64 2, i64* %32
  349. %33 = load {[4 x i8], i64}, {[4 x i8], i64}* %29, align 8
  350. ret {[4 x i8], i64} %33
  351. if.done.-.4:
  352. %34 = load i32, i32* %2, align 4
  353. %35 = icmp ugt i32 %34, 1114111
  354. br i1 %35, label %if.then.-.5, label %cmp-or.-.6
  355. if.then.-.5:
  356. store i32 65533, i32* %0
  357. br label %if.done.-.8
  358. cmp-or.-.6:
  359. %36 = load i32, i32* %2, align 4
  360. %37 = icmp uge i32 %36, 55296
  361. br i1 %37, label %cmp-and.-.7, label %if.done.-.8
  362. cmp-and.-.7:
  363. %38 = load i32, i32* %2, align 4
  364. %39 = icmp ule i32 %38, 57343
  365. br i1 %39, label %if.then.-.5, label %if.done.-.8
  366. if.done.-.8:
  367. %40 = load i32, i32* %2, align 4
  368. %41 = icmp ule i32 %40, 65535
  369. br i1 %41, label %if.then.-.9, label %if.done.-.10
  370. if.then.-.9:
  371. %42 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  372. %43 = getelementptr i8, i8* %42, i64 0
  373. %44 = load i32, i32* %0, align 4
  374. %45 = lshr i32 %44, 12
  375. %46 = trunc i32 %45 to i8
  376. %47 = or i8 224, %46
  377. store i8 %47, i8* %43
  378. %48 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  379. %49 = getelementptr i8, i8* %48, i64 1
  380. %50 = load i32, i32* %0, align 4
  381. %51 = lshr i32 %50, 6
  382. %52 = trunc i32 %51 to i8
  383. %53 = and i8 %52, 63
  384. %54 = or i8 128, %53
  385. store i8 %54, i8* %49
  386. %55 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  387. %56 = getelementptr i8, i8* %55, i64 2
  388. %57 = load i32, i32* %0, align 4
  389. %58 = trunc i32 %57 to i8
  390. %59 = and i8 %58, 63
  391. %60 = or i8 128, %59
  392. store i8 %60, i8* %56
  393. %61 = alloca {[4 x i8], i64}, align 8
  394. store {[4 x i8], i64} zeroinitializer, {[4 x i8], i64}* %61
  395. %62 = load [4 x i8], [4 x i8]* %1, align 1
  396. %63 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %61, i64 0, i32 0
  397. store [4 x i8] %62, [4 x i8]* %63
  398. %64 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %61, i64 0, i32 1
  399. store i64 3, i64* %64
  400. %65 = load {[4 x i8], i64}, {[4 x i8], i64}* %61, align 8
  401. ret {[4 x i8], i64} %65
  402. if.done.-.10:
  403. %66 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  404. %67 = getelementptr i8, i8* %66, i64 0
  405. %68 = load i32, i32* %0, align 4
  406. %69 = lshr i32 %68, 18
  407. %70 = trunc i32 %69 to i8
  408. %71 = or i8 240, %70
  409. store i8 %71, i8* %67
  410. %72 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  411. %73 = getelementptr i8, i8* %72, i64 1
  412. %74 = load i32, i32* %0, align 4
  413. %75 = lshr i32 %74, 12
  414. %76 = trunc i32 %75 to i8
  415. %77 = and i8 %76, 63
  416. %78 = or i8 128, %77
  417. store i8 %78, i8* %73
  418. %79 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  419. %80 = getelementptr i8, i8* %79, i64 2
  420. %81 = load i32, i32* %0, align 4
  421. %82 = lshr i32 %81, 6
  422. %83 = trunc i32 %82 to i8
  423. %84 = and i8 %83, 63
  424. %85 = or i8 128, %84
  425. store i8 %85, i8* %80
  426. %86 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  427. %87 = getelementptr i8, i8* %86, i64 3
  428. %88 = load i32, i32* %0, align 4
  429. %89 = trunc i32 %88 to i8
  430. %90 = and i8 %89, 63
  431. %91 = or i8 128, %90
  432. store i8 %91, i8* %87
  433. %92 = alloca {[4 x i8], i64}, align 8
  434. store {[4 x i8], i64} zeroinitializer, {[4 x i8], i64}* %92
  435. %93 = load [4 x i8], [4 x i8]* %1, align 1
  436. %94 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %92, i64 0, i32 0
  437. store [4 x i8] %93, [4 x i8]* %94
  438. %95 = getelementptr inbounds {[4 x i8], i64}, {[4 x i8], i64}* %92, i64 0, i32 1
  439. store i64 4, i64* %95
  440. %96 = load {[4 x i8], i64}, {[4 x i8], i64}* %92, align 8
  441. ret {[4 x i8], i64} %96
  442. }
  443. define void @print_rune(i32 %r) {
  444. entry.-.0:
  445. %0 = alloca i32, align 4 ; r
  446. store i32 zeroinitializer, i32* %0
  447. store i32 %r, i32* %0
  448. %1 = alloca [4 x i8], align 1 ; buf
  449. store [4 x i8] zeroinitializer, [4 x i8]* %1
  450. %2 = alloca i64, align 8 ; n
  451. store i64 zeroinitializer, i64* %2
  452. %3 = load i32, i32* %0, align 4
  453. %4 = call {[4 x i8], i64} @encode_rune(i32 %3)
  454. %5 = extractvalue {[4 x i8], i64} %4, 0
  455. %6 = extractvalue {[4 x i8], i64} %4, 1
  456. store [4 x i8] %5, [4 x i8]* %1
  457. store i64 %6, i64* %2
  458. %7 = alloca %.string, align 8 ; str
  459. store %.string zeroinitializer, %.string* %7
  460. %8 = load i64, i64* %2, align 8
  461. %9 = sub i64 %8, 0
  462. %10 = sub i64 4, 0
  463. %11 = getelementptr inbounds [4 x i8], [4 x i8]* %1, i64 0, i64 0
  464. %12 = getelementptr i8, i8* %11, i64 0
  465. %13 = alloca {i8*, i64, i64}, align 8
  466. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %13
  467. %14 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %13, i64 0, i32 0
  468. store i8* %12, i8** %14
  469. %15 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %13, i64 0, i32 1
  470. store i64 %9, i64* %15
  471. %16 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %13, i64 0, i32 2
  472. store i64 %10, i64* %16
  473. %17 = load {i8*, i64, i64}, {i8*, i64, i64}* %13, align 8
  474. %18 = alloca {i8*, i64, i64}, align 8
  475. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %18
  476. store {i8*, i64, i64} %17, {i8*, i64, i64}* %18
  477. %19 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %18, i64 0, i32 0
  478. %20 = load i8*, i8** %19, align 8
  479. %21 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %18, i64 0, i32 1
  480. %22 = load i64, i64* %21, align 8
  481. %23 = alloca %.string, align 8
  482. store %.string zeroinitializer, %.string* %23
  483. %24 = getelementptr inbounds %.string, %.string* %23, i64 0, i32 0
  484. %25 = getelementptr inbounds %.string, %.string* %23, i64 0, i32 1
  485. store i8* %20, i8** %24
  486. store i64 %22, i64* %25
  487. %26 = load %.string, %.string* %23, align 8
  488. store %.string %26, %.string* %7
  489. %27 = load %.string, %.string* %7, align 8
  490. call void @print_string(%.string %27)
  491. ret void
  492. }
  493. define void @print_int(i64 %i) {
  494. entry.-.0:
  495. %0 = alloca i64, align 8 ; i
  496. store i64 zeroinitializer, i64* %0
  497. store i64 %i, i64* %0
  498. %1 = load i64, i64* %0, align 8
  499. call void @print_int_base(i64 %1, i64 10)
  500. ret void
  501. }
  502. define void @print_int_base(i64 %i, i64 %base) {
  503. entry.-.0:
  504. %0 = alloca i64, align 8 ; i
  505. store i64 zeroinitializer, i64* %0
  506. store i64 %i, i64* %0
  507. %1 = alloca i64, align 8 ; base
  508. store i64 zeroinitializer, i64* %1
  509. store i64 %base, i64* %1
  510. %2 = alloca [65 x i8], align 1 ; buf
  511. store [65 x i8] zeroinitializer, [65 x i8]* %2
  512. %3 = alloca i64, align 8 ; len
  513. store i64 zeroinitializer, i64* %3
  514. store i64 0, i64* %3
  515. %4 = alloca i1, align 1 ; negative
  516. store i1 zeroinitializer, i1* %4
  517. store i1 false, i1* %4
  518. %5 = load i64, i64* %0, align 8
  519. %6 = icmp slt i64 %5, 0
  520. br i1 %6, label %if.then.-.1, label %if.done.-.2
  521. if.then.-.1:
  522. store i1 true, i1* %4
  523. %7 = load i64, i64* %0, align 8
  524. %8 = sub i64 0, %7
  525. store i64 %8, i64* %0
  526. br label %if.done.-.2
  527. if.done.-.2:
  528. %9 = load i64, i64* %0, align 8
  529. %10 = icmp eq i64 %9, 0
  530. br i1 %10, label %if.then.-.3, label %if.done.-.4
  531. if.then.-.3:
  532. %11 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  533. %12 = load i64, i64* %3, align 8
  534. %13 = getelementptr i8, i8* %11, i64 %12
  535. store i8 48, i8* %13
  536. %14 = load i64, i64* %3, align 8
  537. %15 = add i64 %14, 1
  538. store i64 %15, i64* %3
  539. br label %if.done.-.4
  540. if.done.-.4:
  541. br label %for.loop.-.6
  542. for.body.-.5:
  543. %16 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  544. %17 = load i64, i64* %3, align 8
  545. %18 = getelementptr i8, i8* %16, i64 %17
  546. %19 = getelementptr inbounds [64 x i8], [64 x i8]* @.str4, i64 0, i64 0
  547. %20 = load i64, i64* %1, align 8
  548. %21 = load i64, i64* %0, align 8
  549. %22 = srem i64 %21, %20
  550. %23 = getelementptr i8, i8* %19, i64 %22
  551. %24 = load i8, i8* %23, align 1
  552. store i8 %24, i8* %18
  553. %25 = load i64, i64* %3, align 8
  554. %26 = add i64 %25, 1
  555. store i64 %26, i64* %3
  556. %27 = load i64, i64* %1, align 8
  557. %28 = load i64, i64* %0, align 8
  558. %29 = sdiv i64 %28, %27
  559. store i64 %29, i64* %0
  560. br label %for.loop.-.6
  561. for.loop.-.6:
  562. %30 = load i64, i64* %0, align 8
  563. %31 = icmp sgt i64 %30, 0
  564. br i1 %31, label %for.body.-.5, label %for.done.-.7
  565. for.done.-.7:
  566. %32 = load i1, i1* %4, align 1
  567. br i1 %32, label %if.then.-.8, label %if.done.-.9
  568. if.then.-.8:
  569. %33 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  570. %34 = load i64, i64* %3, align 8
  571. %35 = getelementptr i8, i8* %33, i64 %34
  572. store i8 45, i8* %35
  573. %36 = load i64, i64* %3, align 8
  574. %37 = add i64 %36, 1
  575. store i64 %37, i64* %3
  576. br label %if.done.-.9
  577. if.done.-.9:
  578. %38 = load i64, i64* %3, align 8
  579. %39 = sub i64 %38, 0
  580. %40 = sub i64 65, 0
  581. %41 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  582. %42 = getelementptr i8, i8* %41, i64 0
  583. %43 = alloca {i8*, i64, i64}, align 8
  584. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %43
  585. %44 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 0
  586. store i8* %42, i8** %44
  587. %45 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 1
  588. store i64 %39, i64* %45
  589. %46 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 2
  590. store i64 %40, i64* %46
  591. %47 = load {i8*, i64, i64}, {i8*, i64, i64}* %43, align 8
  592. call void @byte_reverse({i8*, i64, i64} %47)
  593. %48 = load i64, i64* %3, align 8
  594. %49 = sub i64 %48, 0
  595. %50 = sub i64 65, 0
  596. %51 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  597. %52 = getelementptr i8, i8* %51, i64 0
  598. %53 = alloca {i8*, i64, i64}, align 8
  599. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %53
  600. %54 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 0
  601. store i8* %52, i8** %54
  602. %55 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 1
  603. store i64 %49, i64* %55
  604. %56 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 2
  605. store i64 %50, i64* %56
  606. %57 = load {i8*, i64, i64}, {i8*, i64, i64}* %53, align 8
  607. %58 = alloca {i8*, i64, i64}, align 8
  608. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %58
  609. store {i8*, i64, i64} %57, {i8*, i64, i64}* %58
  610. %59 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %58, i64 0, i32 0
  611. %60 = load i8*, i8** %59, align 8
  612. %61 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %58, i64 0, i32 1
  613. %62 = load i64, i64* %61, align 8
  614. %63 = alloca %.string, align 8
  615. store %.string zeroinitializer, %.string* %63
  616. %64 = getelementptr inbounds %.string, %.string* %63, i64 0, i32 0
  617. %65 = getelementptr inbounds %.string, %.string* %63, i64 0, i32 1
  618. store i8* %60, i8** %64
  619. store i64 %62, i64* %65
  620. %66 = load %.string, %.string* %63, align 8
  621. call void @print_string(%.string %66)
  622. ret void
  623. }
  624. define void @print_uint(i64 %i) {
  625. entry.-.0:
  626. %0 = alloca i64, align 8 ; i
  627. store i64 zeroinitializer, i64* %0
  628. store i64 %i, i64* %0
  629. %1 = load i64, i64* %0, align 8
  630. call void @print_uint_base(i64 %1, i64 10)
  631. ret void
  632. }
  633. define void @print_uint_base(i64 %i, i64 %base) {
  634. entry.-.0:
  635. %0 = alloca i64, align 8 ; i
  636. store i64 zeroinitializer, i64* %0
  637. store i64 %i, i64* %0
  638. %1 = alloca i64, align 8 ; base
  639. store i64 zeroinitializer, i64* %1
  640. store i64 %base, i64* %1
  641. %2 = alloca [65 x i8], align 1 ; buf
  642. store [65 x i8] zeroinitializer, [65 x i8]* %2
  643. %3 = alloca i64, align 8 ; len
  644. store i64 zeroinitializer, i64* %3
  645. store i64 0, i64* %3
  646. %4 = alloca i1, align 1 ; negative
  647. store i1 zeroinitializer, i1* %4
  648. store i1 false, i1* %4
  649. %5 = load i64, i64* %0, align 8
  650. %6 = icmp ult i64 %5, 0
  651. br i1 %6, label %if.then.-.1, label %if.done.-.2
  652. if.then.-.1:
  653. store i1 true, i1* %4
  654. %7 = load i64, i64* %0, align 8
  655. %8 = sub i64 0, %7
  656. store i64 %8, i64* %0
  657. br label %if.done.-.2
  658. if.done.-.2:
  659. %9 = load i64, i64* %0, align 8
  660. %10 = icmp eq i64 %9, 0
  661. br i1 %10, label %if.then.-.3, label %if.done.-.4
  662. if.then.-.3:
  663. %11 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  664. %12 = load i64, i64* %3, align 8
  665. %13 = getelementptr i8, i8* %11, i64 %12
  666. store i8 48, i8* %13
  667. %14 = load i64, i64* %3, align 8
  668. %15 = add i64 %14, 1
  669. store i64 %15, i64* %3
  670. br label %if.done.-.4
  671. if.done.-.4:
  672. br label %for.loop.-.6
  673. for.body.-.5:
  674. %16 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  675. %17 = load i64, i64* %3, align 8
  676. %18 = getelementptr i8, i8* %16, i64 %17
  677. %19 = getelementptr inbounds [64 x i8], [64 x i8]* @.str5, i64 0, i64 0
  678. %20 = load i64, i64* %1, align 8
  679. %21 = load i64, i64* %0, align 8
  680. %22 = urem i64 %21, %20
  681. %23 = getelementptr i8, i8* %19, i64 %22
  682. %24 = load i8, i8* %23, align 1
  683. store i8 %24, i8* %18
  684. %25 = load i64, i64* %3, align 8
  685. %26 = add i64 %25, 1
  686. store i64 %26, i64* %3
  687. %27 = load i64, i64* %1, align 8
  688. %28 = load i64, i64* %0, align 8
  689. %29 = udiv i64 %28, %27
  690. store i64 %29, i64* %0
  691. br label %for.loop.-.6
  692. for.loop.-.6:
  693. %30 = load i64, i64* %0, align 8
  694. %31 = icmp ugt i64 %30, 0
  695. br i1 %31, label %for.body.-.5, label %for.done.-.7
  696. for.done.-.7:
  697. %32 = load i1, i1* %4, align 1
  698. br i1 %32, label %if.then.-.8, label %if.done.-.9
  699. if.then.-.8:
  700. %33 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  701. %34 = load i64, i64* %3, align 8
  702. %35 = getelementptr i8, i8* %33, i64 %34
  703. store i8 45, i8* %35
  704. %36 = load i64, i64* %3, align 8
  705. %37 = add i64 %36, 1
  706. store i64 %37, i64* %3
  707. br label %if.done.-.9
  708. if.done.-.9:
  709. %38 = load i64, i64* %3, align 8
  710. %39 = sub i64 %38, 0
  711. %40 = sub i64 65, 0
  712. %41 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  713. %42 = getelementptr i8, i8* %41, i64 0
  714. %43 = alloca {i8*, i64, i64}, align 8
  715. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %43
  716. %44 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 0
  717. store i8* %42, i8** %44
  718. %45 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 1
  719. store i64 %39, i64* %45
  720. %46 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %43, i64 0, i32 2
  721. store i64 %40, i64* %46
  722. %47 = load {i8*, i64, i64}, {i8*, i64, i64}* %43, align 8
  723. call void @byte_reverse({i8*, i64, i64} %47)
  724. %48 = load i64, i64* %3, align 8
  725. %49 = sub i64 %48, 0
  726. %50 = sub i64 65, 0
  727. %51 = getelementptr inbounds [65 x i8], [65 x i8]* %2, i64 0, i64 0
  728. %52 = getelementptr i8, i8* %51, i64 0
  729. %53 = alloca {i8*, i64, i64}, align 8
  730. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %53
  731. %54 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 0
  732. store i8* %52, i8** %54
  733. %55 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 1
  734. store i64 %49, i64* %55
  735. %56 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %53, i64 0, i32 2
  736. store i64 %50, i64* %56
  737. %57 = load {i8*, i64, i64}, {i8*, i64, i64}* %53, align 8
  738. %58 = alloca {i8*, i64, i64}, align 8
  739. store {i8*, i64, i64} zeroinitializer, {i8*, i64, i64}* %58
  740. store {i8*, i64, i64} %57, {i8*, i64, i64}* %58
  741. %59 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %58, i64 0, i32 0
  742. %60 = load i8*, i8** %59, align 8
  743. %61 = getelementptr inbounds {i8*, i64, i64}, {i8*, i64, i64}* %58, i64 0, i32 1
  744. %62 = load i64, i64* %61, align 8
  745. %63 = alloca %.string, align 8
  746. store %.string zeroinitializer, %.string* %63
  747. %64 = getelementptr inbounds %.string, %.string* %63, i64 0, i32 0
  748. %65 = getelementptr inbounds %.string, %.string* %63, i64 0, i32 1
  749. store i8* %60, i8** %64
  750. store i64 %62, i64* %65
  751. %66 = load %.string, %.string* %63, align 8
  752. call void @print_string(%.string %66)
  753. ret void
  754. }
  755. define void @print_bool(i1 %b) {
  756. entry.-.0:
  757. %0 = alloca i1, align 1 ; b
  758. store i1 zeroinitializer, i1* %0
  759. store i1 %b, i1* %0
  760. %1 = load i1, i1* %0, align 1
  761. br i1 %1, label %if.then.-.1, label %if.else.-.2
  762. if.then.-.1:
  763. %2 = getelementptr inbounds [4 x i8], [4 x i8]* @.str6, i64 0, i64 0
  764. %3 = alloca %.string, align 8
  765. store %.string zeroinitializer, %.string* %3
  766. %4 = getelementptr inbounds %.string, %.string* %3, i64 0, i32 0
  767. %5 = getelementptr inbounds %.string, %.string* %3, i64 0, i32 1
  768. store i8* %2, i8** %4
  769. store i64 4, i64* %5
  770. %6 = load %.string, %.string* %3, align 8
  771. call void @print_string(%.string %6)
  772. br label %if.done.-.3
  773. if.else.-.2:
  774. %7 = getelementptr inbounds [5 x i8], [5 x i8]* @.str7, i64 0, i64 0
  775. %8 = alloca %.string, align 8
  776. store %.string zeroinitializer, %.string* %8
  777. %9 = getelementptr inbounds %.string, %.string* %8, i64 0, i32 0
  778. %10 = getelementptr inbounds %.string, %.string* %8, i64 0, i32 1
  779. store i8* %7, i8** %9
  780. store i64 5, i64* %10
  781. %11 = load %.string, %.string* %8, align 8
  782. call void @print_string(%.string %11)
  783. br label %if.done.-.3
  784. if.done.-.3:
  785. ret void
  786. }
  787. declare %HANDLE @GetStdHandle(i32 %h) ; foreign
  788. declare i32 @CloseHandle(%HANDLE %h) ; foreign
  789. declare i32 @WriteFileA(%HANDLE %h, %.rawptr %buf, i32 %len, i32* %written_result, %.rawptr %overlapped) ; foreign
  790. declare i32 @GetLastError() ; foreign
  791. declare void @ExitProcess(i32 %exit_code) ; foreign
  792. declare %HWND @GetDesktopWindow() ; foreign
  793. declare i32 @GetCursorPos(%POINT* %p) ; foreign
  794. declare i32 @ScreenToClient(%HWND %h, %POINT* %p) ; foreign
  795. declare %HINSTANCE @GetModuleHandleA(i8* %module_name) ; foreign
  796. declare i32 @QueryPerformanceFrequency(i64* %result) ; foreign
  797. declare i32 @QueryPerformanceCounter(i64* %result) ; foreign
  798. define void @sleep_ms(i32 %ms) {
  799. entry.-.0:
  800. %0 = alloca i32, align 4 ; ms
  801. store i32 zeroinitializer, i32* %0
  802. store i32 %ms, i32* %0
  803. %1 = load i32, i32* %0, align 4
  804. %2 = call i32 @Sleep(i32 %1)
  805. ret void
  806. }
  807. declare i32 @Sleep(i32 %ms) declare void @OutputDebugStringA(i8* %c_str) ; foreign
  808. declare %ATOM @RegisterClassExA(%WNDCLASSEXA* %wc) ; foreign
  809. declare %HWND @CreateWindowExA(i32 %ex_style, i8* %class_name, i8* %title, i32 %style, i32 %x, i32 %y, i32 %w, i32 %h, %HWND %parent, %HMENU %menu, %HINSTANCE %instance, %.rawptr %param) ; foreign
  810. declare %BOOL @ShowWindow(%HWND %hwnd, i32 %cmd_show) ; foreign
  811. declare %BOOL @UpdateWindow(%HWND %hwnd) ; foreign
  812. declare %BOOL @PeekMessageA(%MSG* %msg, %HWND %hwnd, i32 %msg_filter_min, i32 %msg_filter_max, i32 %remove_msg) ; foreign
  813. declare %BOOL @TranslateMessage(%MSG* %msg) ; foreign
  814. declare %LRESULT @DispatchMessageA(%MSG* %msg) ; foreign
  815. declare %LRESULT @DefWindowProcA(%HWND %hwnd, i32 %msg, %WPARAM %wparam, %LPARAM %lparam) ; foreign
  816. declare i32 @putchar(i32 %c) ; foreign
  817. declare %.rawptr @malloc(i64 %sz) ; foreign
  818. declare void @free(%.rawptr %ptr) ; foreign
  819. declare i32 @memcmp(%.rawptr %dst, %.rawptr %src, i64 %len) ; foreign
  820. declare i32 @memcpy(%.rawptr %dst, %.rawptr %src, i64 %len) ; foreign
  821. declare i32 @memmove(%.rawptr %dst, %.rawptr %src, i64 %len) ; foreign
  822. declare void @llvm.debugtrap() ; foreign
  823. define i1 @__string_eq(%.string %a, %.string %b) {
  824. entry.-.0:
  825. %0 = alloca %.string, align 8 ; a
  826. store %.string zeroinitializer, %.string* %0
  827. store %.string %a, %.string* %0
  828. %1 = alloca %.string, align 8 ; b
  829. store %.string zeroinitializer, %.string* %1
  830. store %.string %b, %.string* %1
  831. %2 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  832. %3 = load i64, i64* %2, align 8
  833. %4 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 1
  834. %5 = load i64, i64* %4, align 8
  835. %6 = icmp ne i64 %3, %5
  836. br i1 %6, label %if.then.-.1, label %if.done.-.2
  837. if.then.-.1:
  838. ret i1 false
  839. if.done.-.2:
  840. %7 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 0
  841. %8 = load i8*, i8** %7, align 8
  842. %9 = getelementptr i8, i8* %8, i64 0
  843. %10 = getelementptr inbounds i8, i8* %9
  844. %11 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 0
  845. %12 = load i8*, i8** %11, align 8
  846. %13 = getelementptr i8, i8* %12, i64 0
  847. %14 = getelementptr inbounds i8, i8* %13
  848. %15 = icmp eq i8* %10, %14
  849. br i1 %15, label %if.then.-.3, label %if.done.-.4
  850. if.then.-.3:
  851. ret i1 true
  852. if.done.-.4:
  853. %16 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 0
  854. %17 = load i8*, i8** %16, align 8
  855. %18 = getelementptr i8, i8* %17, i64 0
  856. %19 = getelementptr inbounds i8, i8* %18
  857. %20 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 0
  858. %21 = load i8*, i8** %20, align 8
  859. %22 = getelementptr i8, i8* %21, i64 0
  860. %23 = getelementptr inbounds i8, i8* %22
  861. %24 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  862. %25 = load i64, i64* %24, align 8
  863. %26 = call i32 @memcmp(%.rawptr %19, %.rawptr %23, i64 %25)
  864. %27 = icmp eq i32 %26, 0
  865. ret i1 %27
  866. }
  867. define i1 @__string_ne(%.string %a, %.string %b) {
  868. entry.-.0:
  869. %0 = alloca %.string, align 8 ; a
  870. store %.string zeroinitializer, %.string* %0
  871. store %.string %a, %.string* %0
  872. %1 = alloca %.string, align 8 ; b
  873. store %.string zeroinitializer, %.string* %1
  874. store %.string %b, %.string* %1
  875. %2 = load %.string, %.string* %0, align 8
  876. %3 = load %.string, %.string* %1, align 8
  877. %4 = call i1 @__string_eq(%.string %2, %.string %3)
  878. %5 = xor i1 %4, -1
  879. ret i1 %5
  880. }
  881. define i64 @__string_cmp(%.string %a, %.string %b) {
  882. entry.-.0:
  883. %0 = alloca %.string, align 8 ; a
  884. store %.string zeroinitializer, %.string* %0
  885. store %.string %a, %.string* %0
  886. %1 = alloca %.string, align 8 ; b
  887. store %.string zeroinitializer, %.string* %1
  888. store %.string %b, %.string* %1
  889. %2 = alloca i64, align 8 ; min_len
  890. store i64 zeroinitializer, i64* %2
  891. %3 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  892. %4 = load i64, i64* %3, align 8
  893. store i64 %4, i64* %2
  894. %5 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 1
  895. %6 = load i64, i64* %5, align 8
  896. %7 = load i64, i64* %2, align 8
  897. %8 = icmp slt i64 %6, %7
  898. br i1 %8, label %if.then.-.1, label %if.done.-.2
  899. if.then.-.1:
  900. %9 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 1
  901. %10 = load i64, i64* %9, align 8
  902. store i64 %10, i64* %2
  903. br label %if.done.-.2
  904. if.done.-.2:
  905. br label %for.init.-.3
  906. for.init.-.3:
  907. %11 = alloca i64, align 8 ; i
  908. store i64 zeroinitializer, i64* %11
  909. store i64 0, i64* %11
  910. br label %for.loop.-.5
  911. for.body.-.4:
  912. %12 = alloca i8, align 1 ; x
  913. store i8 zeroinitializer, i8* %12
  914. %13 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 0
  915. %14 = load i8*, i8** %13, align 8
  916. %15 = load i64, i64* %11, align 8
  917. %16 = getelementptr i8, i8* %14, i64 %15
  918. %17 = load i8, i8* %16, align 1
  919. store i8 %17, i8* %12
  920. %18 = alloca i8, align 1 ; y
  921. store i8 zeroinitializer, i8* %18
  922. %19 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 0
  923. %20 = load i8*, i8** %19, align 8
  924. %21 = load i64, i64* %11, align 8
  925. %22 = getelementptr i8, i8* %20, i64 %21
  926. %23 = load i8, i8* %22, align 1
  927. store i8 %23, i8* %18
  928. %24 = load i8, i8* %12, align 1
  929. %25 = load i8, i8* %18, align 1
  930. %26 = icmp ult i8 %24, %25
  931. br i1 %26, label %if.then.-.7, label %if.else.-.8
  932. for.loop.-.5:
  933. %27 = load i64, i64* %11, align 8
  934. %28 = load i64, i64* %2, align 8
  935. %29 = icmp slt i64 %27, %28
  936. br i1 %29, label %for.body.-.4, label %for.done.-.12
  937. for.post.-.6:
  938. %30 = load i64, i64* %11, align 8
  939. %31 = add i64 %30, 1
  940. store i64 %31, i64* %11
  941. br label %for.loop.-.5
  942. if.then.-.7:
  943. ret i64 -1
  944. if.else.-.8:
  945. %32 = load i8, i8* %12, align 1
  946. %33 = load i8, i8* %18, align 1
  947. %34 = icmp ugt i8 %32, %33
  948. br i1 %34, label %if.then.-.9, label %if.done.-.10
  949. if.then.-.9:
  950. ret i64 1
  951. if.done.-.10:
  952. br label %if.done.-.11
  953. if.done.-.11:
  954. br label %for.post.-.6
  955. for.done.-.12:
  956. %35 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  957. %36 = load i64, i64* %35, align 8
  958. %37 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 1
  959. %38 = load i64, i64* %37, align 8
  960. %39 = icmp slt i64 %36, %38
  961. br i1 %39, label %if.then.-.13, label %if.else.-.14
  962. if.then.-.13:
  963. ret i64 -1
  964. if.else.-.14:
  965. %40 = getelementptr inbounds %.string, %.string* %0, i64 0, i32 1
  966. %41 = load i64, i64* %40, align 8
  967. %42 = getelementptr inbounds %.string, %.string* %1, i64 0, i32 1
  968. %43 = load i64, i64* %42, align 8
  969. %44 = icmp sgt i64 %41, %43
  970. br i1 %44, label %if.then.-.15, label %if.done.-.16
  971. if.then.-.15:
  972. ret i64 1
  973. if.done.-.16:
  974. br label %if.done.-.17
  975. if.done.-.17:
  976. ret i64 0
  977. }
  978. define i1 @__string_lt(%.string %a, %.string %b) {
  979. entry.-.0:
  980. %0 = alloca %.string, align 8 ; a
  981. store %.string zeroinitializer, %.string* %0
  982. store %.string %a, %.string* %0
  983. %1 = alloca %.string, align 8 ; b
  984. store %.string zeroinitializer, %.string* %1
  985. store %.string %b, %.string* %1
  986. %2 = load %.string, %.string* %0, align 8
  987. %3 = load %.string, %.string* %1, align 8
  988. %4 = call i64 @__string_cmp(%.string %2, %.string %3)
  989. %5 = icmp slt i64 %4, 0
  990. ret i1 %5
  991. }
  992. define i1 @__string_gt(%.string %a, %.string %b) {
  993. entry.-.0:
  994. %0 = alloca %.string, align 8 ; a
  995. store %.string zeroinitializer, %.string* %0
  996. store %.string %a, %.string* %0
  997. %1 = alloca %.string, align 8 ; b
  998. store %.string zeroinitializer, %.string* %1
  999. store %.string %b, %.string* %1
  1000. %2 = load %.string, %.string* %0, align 8
  1001. %3 = load %.string, %.string* %1, align 8
  1002. %4 = call i64 @__string_cmp(%.string %2, %.string %3)
  1003. %5 = icmp sgt i64 %4, 0
  1004. ret i1 %5
  1005. }
  1006. define i1 @__string_le(%.string %a, %.string %b) {
  1007. entry.-.0:
  1008. %0 = alloca %.string, align 8 ; a
  1009. store %.string zeroinitializer, %.string* %0
  1010. store %.string %a, %.string* %0
  1011. %1 = alloca %.string, align 8 ; b
  1012. store %.string zeroinitializer, %.string* %1
  1013. store %.string %b, %.string* %1
  1014. %2 = load %.string, %.string* %0, align 8
  1015. %3 = load %.string, %.string* %1, align 8
  1016. %4 = call i64 @__string_cmp(%.string %2, %.string %3)
  1017. %5 = icmp sle i64 %4, 0
  1018. ret i1 %5
  1019. }
  1020. define i1 @__string_ge(%.string %a, %.string %b) {
  1021. entry.-.0:
  1022. %0 = alloca %.string, align 8 ; a
  1023. store %.string zeroinitializer, %.string* %0
  1024. store %.string %a, %.string* %0
  1025. %1 = alloca %.string, align 8 ; b
  1026. store %.string zeroinitializer, %.string* %1
  1027. store %.string %b, %.string* %1
  1028. %2 = load %.string, %.string* %0, align 8
  1029. %3 = load %.string, %.string* %1, align 8
  1030. %4 = call i64 @__string_cmp(%.string %2, %.string %3)
  1031. %5 = icmp sge i64 %4, 0
  1032. ret i1 %5
  1033. }
  1034. @.str0 = global [18 x i8] c"Odin-Language-Demo"
  1035. @.str1 = global [18 x i8] c"Odin-Language-Demo"
  1036. @.str2 = global [14 x i8] c"GetLastError\3A\20"
  1037. @.str3 = global [1 x i8] c"\0A"
  1038. @.str4 = global [64 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\40$"
  1039. @.str5 = global [64 x i8] c"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\40$"
  1040. @.str6 = global [4 x i8] c"true"
  1041. @.str7 = global [5 x i8] c"false"