Guest User

Untitled

a guest
Sep 17th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
LLVM 1.53 KB | None | 0 0
  1. ; ModuleID = 'cb-bytecode-module'
  2. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  3. target triple = "i686-pc-win32"
  4.  
  5. @.str = private unnamed_addr constant [4 x i8] c"%i\0A\00", align 1
  6. @.str1 = private unnamed_addr constant [7 x i8] c"cbMain\00", align 1
  7.  
  8. define i32 @main(i32 %argc, i8** %argv) {
  9.   call void @cbRuntimeMain(i32 %argc, i8** %argv)
  10.   %1 = alloca i32
  11.   store i32 0, i32* %1
  12.   store i32 1, i32* %1
  13.   br label %2
  14.  
  15. ; <label>:2                                       ; preds = %5, %0
  16.   %3 = load i32* %1
  17.   %4 = icmp sge i32 %3, 10
  18.   br i1 %4, label %5, label %8
  19.  
  20. ; <label>:5                                       ; preds = %2
  21.   %6 = load i32* %1
  22.   %7 = add i32 %6, 1
  23.   store i32 %7, i32* %1
  24.   br label %2
  25.  
  26. ; <label>:8                                       ; preds = %2
  27.   call void @commandEnd()
  28.   unreachable
  29. }
  30.  
  31. define void @commandPrintI(i32 %i) nounwind {
  32.   %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %i)
  33.   ret void
  34. }
  35.  
  36. declare i32 @printf(i8* nocapture, ...) nounwind
  37.  
  38. define i32 @functionTimer() {
  39.   %1 = tail call i32 @clock()
  40.   ret i32 %1
  41. }
  42.  
  43. declare i32 @clock()
  44.  
  45. define void @commandEnd() noreturn {
  46.   tail call void @exit(i32 0) noreturn
  47.   unreachable
  48. }
  49.  
  50. declare void @exit(i32) noreturn
  51.  
  52. define void @cbRuntimeMain(i32 %argc, i8** nocapture %argv) nounwind {
  53.   %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str1, i32 0, i32 0))
  54.   ret void
  55. }
Add Comment
Please, Sign In to add comment