xunge/DecIR huggingface dataset:
/* Variables and functions */
char *malloc(int);
int rand();
char *realloc(char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *fn28() {
  char *result;
  result = malloc(20 + rand() % 20);
  result = realloc(result, 30 + rand() % 20);
  strcpy((char *)result, "fn28");
  return result;
}


x86 assembly (clang, -O0):
<fn28>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    -0x10(%rbp),%rdi
mov    $0x14,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
add    $0x1e,%esi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn28>:
push   %rbx
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x14,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <rand@plt>
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
shl    $0x2,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
lea    (%rax,%rcx,1),%esi
add    $0x1e,%esi
mov    %rbx,%rdi
call   1050 <realloc@plt>
mov    %rax,%rbx
lea    0xe4f(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"fn28\00"
define i8* @fn28() {
%1 = alloca i8*
%2 = call i32 (...) @rand()
%3 = srem i32 %2, 20
%4 = add nsw i32 20, %3
%5 = call i8* @malloc(i32 %4)
store i8* %5, i8** %1
%6 = load i8*, i8** %1
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 20
%9 = add nsw i32 30, %8
%10 = call i8* @realloc(i8* %6, i32 %9)
store i8* %10, i8** %1
%11 = load i8*, i8** %1
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %1
ret i8* %13
}

LLVM IR (-O2):
@.str = [5 x i8] c"fn28\00"
define i8* @fn28() {
%1 = tail call i32 (...) @rand()
%2 = srem i32 %1, 20
%3 = add nsw i32 %2, 20
%4 = tail call i8* @malloc(i32 %3)
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 20
%7 = add nsw i32 %6, 30
%8 = tail call i8* @realloc(i8* %4, i32 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret i8* %8
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
void CloseSocket(int socket) { close(socket); }


x86 assembly (clang, -O0):
<CloseSocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CloseSocket>:
jmp    1030 <close@plt>

LLVM IR (-O0):
define void @CloseSocket(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @close(i32 %3)
ret void
}

LLVM IR (-O2):
define void @CloseSocket(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ putchar(char);
void indent(int depth) {
  for (int i = 0; i < depth; i++) {
    putchar(' ');
  }
}


x86 assembly (clang, -O0):
<indent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1146 <indent+0x36>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <indent+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<indent>:
push   %rbx
test   %edi,%edi
jle    112f <indent+0x1f>
mov    %edi,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1120 <indent+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @indent(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %10, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = call i32 @putchar(i8 signext 32)
br label %10
10: ; preds = %8
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
br label %4
13: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @indent(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %4, label %3
3: ; preds = %4, %1
ret void
4: ; preds = %1, %4
%5 = phi i32 [ %7, %4 ], [ 0, %1 ]
%6 = tail call i32 @putchar(i8 signext 32)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, %0
br i1 %8, label %3, label %4
}
long long _mpy32ll(int src1, int src2) { return ((long long)src1) * src2; }


x86 assembly (clang, -O0):
<_mpy32ll>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movslq -0x4(%rbp),%rax
movslq -0x8(%rbp),%rcx
imul   %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mpy32ll>:
movslq %edi,%rcx
movslq %esi,%rax
imul   %rcx,%rax
ret

LLVM IR (-O0):
define i64 @_mpy32ll(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = mul nsw i64 %6, %8
ret i64 %9
}

LLVM IR (-O2):
define i64 @_mpy32ll(i32 %0, i32 %1) {
%3 = sext i32 %0 to i64
%4 = sext i32 %1 to i64
%5 = mul nsw i64 %4, %3
ret i64 %5
}
void hls_macc(int a, int b, int *accum, _Bool accum_clr) {
#pragma HLS INTERFACE s_axilite port = return bundle = HLS_MACC_PERIPH_BUS
#pragma HLS INTERFACE s_axilite port = a bundle = HLS_MACC_PERIPH_BUS
#pragma HLS INTERFACE s_axilite port = b bundle = HLS_MACC_PERIPH_BUS
#pragma HLS INTERFACE s_axilite port = accum bundle = HLS_MACC_PERIPH_BUS
#pragma HLS INTERFACE s_axilite port = accum_clr bundle = HLS_MACC_PERIPH_BUS
#pragma empty_line
  static acc_reg = 0;
  if (accum_clr)
    acc_reg = 0;
  acc_reg += a * b;
  *accum = acc_reg;
}


x86 assembly (clang, -O0):
<hls_macc>:
push   %rbp
mov    %rsp,%rbp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
and    $0x1,%al
mov    %al,-0x11(%rbp)
testb  $0x1,-0x11(%rbp)
je     1129 <hls_macc+0x29>
movl   $0x0,0x2efb(%rip)
mov    -0x4(%rbp),%eax
imul   -0x8(%rbp),%eax
add    0x2eee(%rip),%eax
mov    %eax,0x2ee8(%rip)
mov    0x2ee2(%rip),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<hls_macc>:
xor    %eax,%eax
test   %ecx,%ecx
jne    110c <hls_macc+0xc>
mov    0x2f18(%rip),%eax
imul   %edi,%esi
add    %eax,%esi
mov    %esi,0x2f0d(%rip)
mov    %esi,(%rdx)
ret

LLVM IR (-O0):
@hls_macc.acc_reg = internal global i32 0
define void @hls_macc(i32 %0, i32 %1, i32* %2, i1 zeroext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%9 = zext i1 %3 to i8
store i8 %9, i8* %8
%10 = load i8, i8* %8
%11 = trunc i8 %10 to i1
br i1 %11, label %12, label %13
12: ; preds = %4
store i32 0, i32* @hls_macc.acc_reg
br label %13
13: ; preds = %12, %4
%14 = load i32, i32* %5
%15 = load i32, i32* %6
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* @hls_macc.acc_reg
%18 = add nsw i32 %17, %16
store i32 %18, i32* @hls_macc.acc_reg
%19 = load i32, i32* @hls_macc.acc_reg
%20 = load i32*, i32** %7
store i32 %19, i32* %20
ret void
}

LLVM IR (-O2):
@hls_macc.acc_reg = internal unnamed_addr global i32 0
define void @hls_macc(i32 %0, i32 %1, i32* nocapture writeonly %2, i1 zeroext %3) {
%5 = load i32, i32* @hls_macc.acc_reg
%6 = select i1 %3, i32 0, i32 %5
%7 = mul nsw i32 %1, %0
%8 = add nsw i32 %6, %7
store i32 %8, i32* @hls_macc.acc_reg
store i32 %8, i32* %2
ret void
}
void SetLargePageSize() {}


x86 assembly (clang, -O0):
<SetLargePageSize>:
push   %rbp
mov    %rsp,%rbp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetLargePageSize>:
ret

LLVM IR (-O0):
define void @SetLargePageSize() {
ret void
}

LLVM IR (-O2):
define void @SetLargePageSize() {
ret void
}
char *fun() {
  char c = '%';
  return &c;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
movb   $0x25,-0x1(%rbp)
lea    -0x1(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
lea    -0x1(%rsp),%rax
ret

LLVM IR (-O0):
define i8* @fun() {
%1 = alloca i8
store i8 37, i8* %1
ret i8* %1
}

LLVM IR (-O2):
define noalias i8* @fun() {
%1 = alloca i8
ret i8* %1
}
/* Variables and functions */
void *malloc(int);
int main() {
  int i = 3;
  int j = 4;
  void *tmp = malloc(sizeof(int *) * 2);
  int *ptrI = &i;
  int *ptrj = &j;
  int **tmphelper = (int **)tmp;
  int *tmpfst = *tmphelper;
  int *tmpsnd = *(tmphelper + 1);
  tmpfst = ptrI;
  tmpsnd = ptrj;
  int **other = (int **)tmp;
  int *snd = *(other + 1);
  if (*tmpfst == 3 && *tmpsnd == 4) {
    return 0;
  }
ERROR:
  goto ERROR;
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x4,-0xc(%rbp)
mov    $0x10,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
cmpl   $0x3,(%rax)
jne    11b0 <main+0xa0>
mov    -0x40(%rbp),%rax
cmpl   $0x4,(%rax)
jne    11b0 <main+0xa0>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret
jmp    11b5 <main+0xa5>
jmp    11b5 <main+0xa5>

x86 assembly (clang, -O2):
<main>:
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32**
%11 = alloca i32*
store i32 0, i32* %1
store i32 3, i32* %2
store i32 4, i32* %3
%12 = call i8* @malloc(i32 16)
store i8* %12, i8** %4
store i32* %2, i32** %5
store i32* %3, i32** %6
%13 = load i8*, i8** %4
%14 = bitcast i8* %13 to i32**
store i32** %14, i32*** %7
%15 = load i32**, i32*** %7
%16 = load i32*, i32** %15
store i32* %16, i32** %8
%17 = load i32**, i32*** %7
%18 = getelementptr inbounds i32*, i32** %17, i64 1
%19 = load i32*, i32** %18
store i32* %19, i32** %9
%20 = load i32*, i32** %5
store i32* %20, i32** %8
%21 = load i32*, i32** %6
store i32* %21, i32** %9
%22 = load i8*, i8** %4
%23 = bitcast i8* %22 to i32**
store i32** %23, i32*** %10
%24 = load i32**, i32*** %10
%25 = getelementptr inbounds i32*, i32** %24, i64 1
%26 = load i32*, i32** %25
store i32* %26, i32** %11
%27 = load i32*, i32** %8
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 3
br i1 %29, label %30, label %35
30: ; preds = %0
%31 = load i32*, i32** %9
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %35
34: ; preds = %30
ret i32 0
35: ; preds = %30, %0
br label %36
36: ; preds = %36, %35
br label %36
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
void withRegister(void) {
  register int i;
  for (i = 0; i < 1e8; i++)
    ;
}


x86 assembly (clang, -O0):
<withRegister>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xee8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1135 <withRegister+0x35>
jmp    1127 <withRegister+0x27>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    110b <withRegister+0xb>
pop    %rbp
ret

x86 assembly (clang, -O2):
<withRegister>:
ret

LLVM IR (-O0):
define void @withRegister() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %7, %0
%3 = load i32, i32* %1
%4 = sitofp i32 %3 to double
%5 = fcmp olt double %4, 1.000000e+08
br i1 %5, label %6, label %10
6: ; preds = %2
br label %7
7: ; preds = %6
%8 = load i32, i32* %1
%9 = add nsw i32 %8, 1
store i32 %9, i32* %1
br label %2
10: ; preds = %2
ret void
}

LLVM IR (-O2):
define void @withRegister() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ atan(double);
double cos(int /*<<< orphan*/);
double __attribute__((no)) cosatan_(double x) { return cos(atan(x)); }


x86 assembly (clang, -O0):
<cosatan_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <atan@plt>
mov    %eax,%edi
call   1040 <cos@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cosatan_>:
push   %rax
call   1030 <atan@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <cos@plt>

LLVM IR (-O0):
define double @cosatan_(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call i32 @atan(double %3)
%5 = call double @cos(i32 %4)
ret double %5
}

LLVM IR (-O2):
define double @cosatan_(double %0) {
%2 = tail call i32 @atan(double %0)
%3 = tail call double @cos(i32 %2)
ret double %3
}
/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
void *calloc(size_t, size_t);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, size_t);
int /*<<< orphan*/ stderr;
void *ecalloc(size_t num, size_t size) {
  void *mem = calloc(num, size);
  if (!mem) {
    fprintf(stderr, "Failed to allocate %zu bytes\n", num * size);
    exit(EXIT_FAILURE);
  }
  return mem;
}


x86 assembly (clang, -O0):
<ecalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <ecalloc+0x58>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
imul   -0x10(%rbp),%rdx
lea    0xe8b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecalloc>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <calloc@plt>
test   %rax,%rax
je     114c <ecalloc+0x1c>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
imul   %rbx,%r14
lea    0xea0(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Failed to allocate %zu bytes\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @ecalloc(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %3
store i64 %1, i64* %4
%6 = load i64, i64* %3
%7 = load i64, i64* %4
%8 = call i8* @calloc(i64 %6, i64 %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
br i1 %10, label %19, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i64, i64* %3
%14 = load i64, i64* %4
%15 = mul i64 %13, %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
%20 = load i8*, i8** %5
ret i8* %20
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Failed to allocate %zu bytes\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @ecalloc(i64 %0, i64 %1) {
%3 = tail call i8* @calloc(i64 %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = mul i64 %1, %0
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
ret i8* %3
}
int abs(int i) { return i > 0 ? i : -i; }


x86 assembly (clang, -O0):
<abs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jle    111c <abs+0x1c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1124 <abs+0x24>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<abs>:
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
ret

LLVM IR (-O0):
define i32 @abs(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = load i32, i32* %2
br label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = sub nsw i32 0, %8
br label %10
10: ; preds = %7, %5
%11 = phi i32 [ %6, %5 ], [ %9, %7 ]
ret i32 %11
}

LLVM IR (-O2):
define i32 @abs(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
ret i32 %2
}
__attribute__((visibility("hidden"))) int colour_to_green(const int colour) {
  int return_val = 0;
  switch (colour) {
  case 8:
  case 1:
  case 5:
  case 6:
    return_val = 255;
    break;
  }
  return return_val;
}


x86 assembly (clang, -O0):
<colour_to_green>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1147 <colour_to_green+0x47>
jmp    1122 <colour_to_green+0x22>
mov    -0xc(%rbp),%eax
add    $0xfffffffb,%eax
sub    $0x2,%eax
jb     1147 <colour_to_green+0x47>
jmp    1136 <colour_to_green+0x36>
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
jne    114e <colour_to_green+0x4e>
jmp    1147 <colour_to_green+0x47>
movl   $0xff,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<colour_to_green>:
add    $0xffffffff,%edi
xor    %eax,%eax
cmp    $0x7,%edi
ja     1117 <colour_to_green+0x17>
movslq %edi,%rax
lea    0xeec(%rip),%rcx
mov    (%rcx,%rax,4),%eax
ret

LLVM IR (-O0):
define hidden i32 @colour_to_green(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
switch i32 %4, label %6 [
i32 8, label %5
i32 1, label %5
i32 5, label %5
i32 6, label %5
]
5: ; preds = %1, %1, %1, %1
store i32 255, i32* %3
br label %6
6: ; preds = %1, %5
%7 = load i32, i32* %3
ret i32 %7
}

LLVM IR (-O2):
@switch.table.colour_to_green = [8 x i32] [i32 255, i32 0, i32 0, i32 0, i32 255, i32 255, i32 0, i32 255]
define hidden i32 @colour_to_green(i32 %0) {
%2 = add i32 %0, -1
%3 = icmp ult i32 %2, 8
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds [8 x i32], [8 x i32]* @switch.table.colour_to_green, i64 0, i64 %5
%7 = load i32, i32* %6
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ 0, %1 ], [ %7, %4 ]
ret i32 %9
}
int dxf_read_is_double(int type) {
  if (type >= 10 && type < 60) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<dxf_read_is_double>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jl     1127 <dxf_read_is_double+0x27>
cmpl   $0x3c,-0x8(%rbp)
jge    1127 <dxf_read_is_double+0x27>
movl   $0x1,-0x4(%rbp)
jmp    112e <dxf_read_is_double+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<dxf_read_is_double>:
add    $0xfffffff6,%edi
xor    %eax,%eax
cmp    $0x32,%edi
setb   %al
ret

LLVM IR (-O0):
define i32 @dxf_read_is_double(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sge i32 %4, 10
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 60
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %2
br label %11
10: ; preds = %6, %1
store i32 0, i32* %2
br label %11
11: ; preds = %10, %9
%12 = load i32, i32* %2
ret i32 %12
}

LLVM IR (-O2):
define i32 @dxf_read_is_double(i32 %0) {
%2 = add i32 %0, -10
%3 = icmp ult i32 %2, 50
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ exp(int /*<<< orphan*/);
int /*<<< orphan*/ wStackPopNumber();
int /*<<< orphan*/ wStackPushNumberFromRoutine(int /*<<< orphan*/, char *);
void wBuiltinExp() {
  wStackPushNumberFromRoutine(exp(wStackPopNumber()), "Exp");
}


x86 assembly (clang, -O0):
<wBuiltinExp>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <wStackPopNumber@plt>
mov    %eax,%edi
call   1040 <exp@plt>
mov    %eax,%edi
lea    0xeb5(%rip),%rsi
call   1050 <wStackPushNumberFromRoutine@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<wBuiltinExp>:
push   %rax
xor    %eax,%eax
call   1030 <wStackPopNumber@plt>
mov    %eax,%edi
call   1040 <exp@plt>
lea    0xeba(%rip),%rsi
mov    %eax,%edi
pop    %rax
jmp    1050 <wStackPushNumberFromRoutine@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"Exp\00"
define void @wBuiltinExp() {
%1 = call i32 (...) @wStackPopNumber()
%2 = call i32 @exp(i32 %1)
%3 = call i32 @wStackPushNumberFromRoutine(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"Exp\00"
define void @wBuiltinExp() {
%1 = tail call i32 (...) @wStackPopNumber()
%2 = tail call i32 @exp(i32 %1)
%3 = tail call i32 @wStackPushNumberFromRoutine(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
char *parse_string(char **, char const *, int);
char *extract_by_delim(char **str, const char *end) {
  return parse_string(&(*str), end, 1);
}


x86 assembly (clang, -O0):
<extract_by_delim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
call   1030 <parse_string@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_by_delim>:
mov    $0x1,%edx
jmp    1030 <parse_string@plt>

LLVM IR (-O0):
define i8* @extract_by_delim(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%5 = load i8**, i8*** %3
%6 = load i8*, i8** %4
%7 = call i8* @parse_string(i8** %5, i8* %6, i32 1)
ret i8* %7
}

LLVM IR (-O2):
define i8* @extract_by_delim(i8** %0, i8* %1) {
%3 = tail call i8* @parse_string(i8** %0, i8* %1, i32 1)
ret i8* %3
}
/* Variables and functions */
int strdircmp(char *, char *);
int string_dir_cmp(const void *a, const void *b) {
  return strdircmp(*(char **)a, *(char **)b);
}


x86 assembly (clang, -O0):
<string_dir_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strdircmp@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_dir_cmp>:
mov    (%rdi),%rdi
mov    (%rsi),%rsi
jmp    1030 <strdircmp@plt>

LLVM IR (-O0):
define i32 @string_dir_cmp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = bitcast i8* %5 to i8**
%7 = load i8*, i8** %6
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i8**
%10 = load i8*, i8** %9
%11 = call i32 @strdircmp(i8* %7, i8* %10)
ret i32 %11
}

LLVM IR (-O2):
define i32 @string_dir_cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i8**
%4 = load i8*, i8** %3
%5 = bitcast i8* %1 to i8**
%6 = load i8*, i8** %5
%7 = tail call i32 @strdircmp(i8* %4, i8* %6)
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ USBSTK5515_GPIO_setDirection(int, int);
short USBSTK5515_ULED_setall(int);
short USBSTK5515_ULED_init() {
  USBSTK5515_GPIO_setDirection(14, 1);
  USBSTK5515_GPIO_setDirection(15, 1);
  USBSTK5515_GPIO_setDirection(16, 1);
  USBSTK5515_GPIO_setDirection(17, 1);
  return USBSTK5515_ULED_setall(0x0F);
}


x86 assembly (clang, -O0):
<USBSTK5515_ULED_init>:
push   %rbp
mov    %rsp,%rbp
mov    $0xe,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0x11,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0xf,%edi
call   1040 <USBSTK5515_ULED_setall@plt>
cwtl
pop    %rbp
ret

x86 assembly (clang, -O2):
<USBSTK5515_ULED_init>:
push   %rax
mov    $0xe,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0xf,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0x10,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0x11,%edi
mov    $0x1,%esi
call   1030 <USBSTK5515_GPIO_setDirection@plt>
mov    $0xf,%edi
pop    %rax
jmp    1040 <USBSTK5515_ULED_setall@plt>

LLVM IR (-O0):
define signext i16 @USBSTK5515_ULED_init() {
%1 = call i32 @USBSTK5515_GPIO_setDirection(i32 14, i32 1)
%2 = call i32 @USBSTK5515_GPIO_setDirection(i32 15, i32 1)
%3 = call i32 @USBSTK5515_GPIO_setDirection(i32 16, i32 1)
%4 = call i32 @USBSTK5515_GPIO_setDirection(i32 17, i32 1)
%5 = call signext i16 @USBSTK5515_ULED_setall(i32 15)
ret i16 %5
}

LLVM IR (-O2):
define signext i16 @USBSTK5515_ULED_init() {
%1 = tail call i32 @USBSTK5515_GPIO_setDirection(i32 14, i32 1)
%2 = tail call i32 @USBSTK5515_GPIO_setDirection(i32 15, i32 1)
%3 = tail call i32 @USBSTK5515_GPIO_setDirection(i32 16, i32 1)
%4 = tail call i32 @USBSTK5515_GPIO_setDirection(i32 17, i32 1)
%5 = tail call signext i16 @USBSTK5515_ULED_setall(i32 15)
ret i16 %5
}
/* Variables and functions */
unsigned long simple_strtoull_patch(char const *, char **, unsigned int);
unsigned long simple_strtoul_patch(const char *cp, char **endp,
                                   unsigned int base) {
  return simple_strtoull_patch(cp, endp, base);
}


x86 assembly (clang, -O0):
<simple_strtoul_patch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <simple_strtoull_patch@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simple_strtoul_patch>:
jmp    1030 <simple_strtoull_patch@plt>

LLVM IR (-O0):
define i64 @simple_strtoul_patch(i8* %0, i8** %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i8**, i8*** %5
%9 = load i32, i32* %6
%10 = call i64 @simple_strtoull_patch(i8* %7, i8** %8, i32 %9)
ret i64 %10
}

LLVM IR (-O2):
define i64 @simple_strtoul_patch(i8* %0, i8** %1, i32 %2) {
%4 = tail call i64 @simple_strtoull_patch(i8* %0, i8** %1, i32 %2)
ret i64 %4
}
/* Variables and functions */
int get_mdterm();
void md_draw_line_green(int x1, int y1, int x2, int y2, int width) {
  switch (get_mdterm()) {}
}


x86 assembly (clang, -O0):
<md_draw_line_green>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
xor    %eax,%eax
call   1030 <get_mdterm@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<md_draw_line_green>:
xor    %eax,%eax
jmp    1030 <get_mdterm@plt>

LLVM IR (-O0):
define void @md_draw_line_green(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = call i32 (...) @get_mdterm()
switch i32 %11, label %12 [
]
12: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @md_draw_line_green(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call i32 (...) @get_mdterm()
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void fprint_rl(FILE *stream) {
  fprintf(stream, "RL    A                         ");
}


x86 assembly (clang, -O0):
<fprint_rl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_rl>:
mov    %rdi,%rcx
lea    0xee6(%rip),%rdi
mov    $0x20,%esi
mov    $0x1,%edx
jmp    1030 <fwrite@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"RL A \00"
define void @fprint_rl(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"RL A \00"
define void @fprint_rl(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i64 32, i64 1, i32* %0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ time_t;
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ writen(int, int /*<<< orphan*/ *, int);
ssize_t write_time(int fd, time_t v) { return writen(fd, &v, sizeof(time_t)); }


x86 assembly (clang, -O0):
<write_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <writen@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_time>:
push   %rax
mov    %esi,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1030 <writen@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @write_time(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = call i32 @writen(i32 %5, i32* %4, i32 4)
ret i32 %6
}

LLVM IR (-O2):
define i32 @write_time(i32 %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = call i32 @writen(i32 %0, i32* %3, i32 4)
ret i32 %4
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int get_8(int /*<<< orphan*/ *);
int get_16(FILE *f) {
  int word;
  word = get_8(f);
  word |= get_8(f) << 8;
  return word;
}


x86 assembly (clang, -O0):
<get_16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_8@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_8@plt>
shl    $0x8,%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_16>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <get_8@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <get_8@plt>
shl    $0x8,%eax
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_16(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @get_8(i32* %4)
store i32 %5, i32* %3
%6 = load i32*, i32** %2
%7 = call i32 @get_8(i32* %6)
%8 = shl i32 %7, 8
%9 = load i32, i32* %3
%10 = or i32 %9, %8
store i32 %10, i32* %3
%11 = load i32, i32* %3
ret i32 %11
}

LLVM IR (-O2):
define i32 @get_16(i32* %0) {
%2 = tail call i32 @get_8(i32* %0)
%3 = tail call i32 @get_8(i32* %0)
%4 = shl i32 %3, 8
%5 = or i32 %4, %2
ret i32 %5
}
void marca_target(char maze[23][30], int target[2]) {
  maze[target[0]][target[1]] = 'T';
}


x86 assembly (clang, -O0):
<marca_target>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
imul   $0x1e,%rcx,%rcx
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
movslq 0x4(%rcx),%rcx
movb   $0x54,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<marca_target>:
movslq (%rsi),%rax
movslq 0x4(%rsi),%rcx
mov    %rax,%rdx
shl    $0x5,%rdx
sub    %rax,%rdx
sub    %rax,%rdx
add    %rdi,%rdx
movb   $0x54,(%rcx,%rdx,1)
ret

LLVM IR (-O0):
define void @marca_target([30 x i8]* %0, i32* %1) {
%3 = alloca [30 x i8]*
%4 = alloca i32*
store [30 x i8]* %0, [30 x i8]** %3
store i32* %1, i32** %4
%5 = load [30 x i8]*, [30 x i8]** %3
%6 = load i32*, i32** %4
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32, i32* %7
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 %9
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = load i32, i32* %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 %14
store i8 84, i8* %15
ret void
}

LLVM IR (-O2):
define void @marca_target([30 x i8]* nocapture writeonly %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i32, i32* %1, i64 1
%6 = load i32, i32* %5
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [30 x i8], [30 x i8]* %0, i64 %4, i64 %7
store i8 84, i8* %8
ret void
}
long labs(long n) { return n >= 0L ? n : -n; }


x86 assembly (clang, -O0):
<labs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jl     1120 <labs+0x20>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    112a <labs+0x2a>
xor    %eax,%eax
sub    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<labs>:
mov    %rdi,%rax
neg    %rax
cmovs  %rdi,%rax
ret

LLVM IR (-O0):
define i64 @labs(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp sge i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = load i64, i64* %2
br label %10
7: ; preds = %1
%8 = load i64, i64* %2
%9 = sub nsw i64 0, %8
br label %10
10: ; preds = %7, %5
%11 = phi i64 [ %6, %5 ], [ %9, %7 ]
ret i64 %11
}

LLVM IR (-O2):
define i64 @labs(i64 %0) {
%2 = tail call i64 @llvm.abs.i64(i64 %0, i1 true)
ret i64 %2
}
/* Variables and functions */
bool is_uint(char *s) {
  while (*s) {
    if (*s < '0' || *s > '9')
      return false;
    s++;
  }
  return true;
}


x86 assembly (clang, -O0):
<is_uint>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1152 <is_uint+0x52>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1135 <is_uint+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x39,%eax
jle    1141 <is_uint+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1159 <is_uint+0x59>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1108 <is_uint+0x8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_uint>:
mov    (%rdi),%cl
mov    $0x1,%eax
test   %cl,%cl
je     1123 <is_uint+0x23>
add    $0x1,%rdi
nop
add    $0xc6,%cl
cmp    $0xf5,%cl
jbe    1124 <is_uint+0x24>
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1110 <is_uint+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @is_uint(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %19, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp slt i32 %11, 48
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp sgt i32 %16, 57
br i1 %17, label %18, label %19
18: ; preds = %13, %8
store i32 0, i32* %2
br label %23
19: ; preds = %13
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %4
22: ; preds = %4
store i32 1, i32* %2
br label %23
23: ; preds = %22, %18
%24 = load i32, i32* %2
ret i32 %24
}

LLVM IR (-O2):
define i32 @is_uint(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %7
4: ; preds = %7
%5 = load i8, i8* %12
%6 = icmp eq i8 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %1, %4
%8 = phi i8 [ %5, %4 ], [ %2, %1 ]
%9 = phi i8* [ %12, %4 ], [ %0, %1 ]
%10 = add i8 %8, -58
%11 = icmp ult i8 %10, -10
%12 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %11, label %13, label %4
13: ; preds = %7, %4, %1
%14 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 0, %7 ]
ret i32 %14
}
void foo_TestFoobis2(void *t) { printf("%s: %p\n", __func__, t); }


x86 assembly (clang, -O0):
<foo_TestFoobis2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xed9(%rip),%rdi
lea    0xeda(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo_TestFoobis2>:
mov    %rdi,%rdx
lea    0xee6(%rip),%rdi
lea    0xee7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s: %p\0A\00"
@__func__.foo_TestFoobis2 = [16 x i8] c"foo_TestFoobis2\00"
define void @foo_TestFoobis2(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.foo_TestFoobis2, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s: %p\0A\00"
@__func__.foo_TestFoobis2 = [16 x i8] c"foo_TestFoobis2\00"
define void @foo_TestFoobis2(i8* %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @__func__.foo_TestFoobis2, i64 0, i64 0), i8* %0)
ret void
}
/* Type definitions */
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ SYS_tkill;
int /*<<< orphan*/ syscall(int /*<<< orphan*/, int, int);
int tgkill(int tgid, int tid, int sig) {
  return (pid_t)syscall(SYS_tkill, tid, sig);
}


x86 assembly (clang, -O0):
<tgkill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    0x2ed0(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <syscall@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tgkill>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
@SYS_tkill = global i32 0
define i32 @tgkill(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* @SYS_tkill
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i32 @syscall(i32 %7, i32 %8, i32 %9)
ret i32 %10
}

LLVM IR (-O2):
@SYS_tkill = global i32 0
define i32 @tgkill(i32 %0, i32 %1, i32 %2) {
%4 = load i32, i32* @SYS_tkill
%5 = tail call i32 @syscall(i32 %4, i32 %1, i32 %2)
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ delline();
int get_screen_rows();
int /*<<< orphan*/ gotoxy(int /*<<< orphan*/, int);
void clrscr(void) {
  int count;
  for (count = 0; count < get_screen_rows(); count++) {
    gotoxy(0, count);
    delline();
  }
  gotoxy(0, 0);
}


x86 assembly (clang, -O0):
<clrscr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <get_screen_rows@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%eax
cmp    %ecx,%eax
jge    1178 <clrscr+0x48>
mov    -0x4(%rbp),%esi
xor    %edi,%edi
call   1050 <gotoxy@plt>
mov    $0x0,%al
call   1040 <delline@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <clrscr+0xf>
xor    %esi,%esi
mov    %esi,%edi
call   1050 <gotoxy@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clrscr>:
push   %rbx
xor    %eax,%eax
call   1030 <get_screen_rows@plt>
test   %eax,%eax
jle    115e <clrscr+0x2e>
xor    %ebx,%ebx
xchg   %ax,%ax
xor    %edi,%edi
mov    %ebx,%esi
call   1050 <gotoxy@plt>
xor    %eax,%eax
call   1040 <delline@plt>
add    $0x1,%ebx
xor    %eax,%eax
call   1030 <get_screen_rows@plt>
cmp    %eax,%ebx
jl     1140 <clrscr+0x10>
xor    %edi,%edi
xor    %esi,%esi
pop    %rbx
jmp    1050 <gotoxy@plt>

LLVM IR (-O0):
define void @clrscr() {
%1 = alloca i32
store i32 0, i32* %1
br label %2
2: ; preds = %10, %0
%3 = load i32, i32* %1
%4 = call i32 (...) @get_screen_rows()
%5 = icmp slt i32 %3, %4
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = load i32, i32* %1
%8 = call i32 @gotoxy(i32 0, i32 %7)
%9 = call i32 (...) @delline()
br label %10
10: ; preds = %6
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %2
13: ; preds = %2
%14 = call i32 @gotoxy(i32 0, i32 0)
ret void
}

LLVM IR (-O2):
define void @clrscr() {
%1 = tail call i32 (...) @get_screen_rows()
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %10
3: ; preds = %0, %3
%4 = phi i32 [ %7, %3 ], [ 0, %0 ]
%5 = tail call i32 @gotoxy(i32 0, i32 %4)
%6 = tail call i32 (...) @delline()
%7 = add nuw nsw i32 %4, 1
%8 = tail call i32 (...) @get_screen_rows()
%9 = icmp slt i32 %7, %8
br i1 %9, label %3, label %10
10: ; preds = %3, %0
%11 = tail call i32 @gotoxy(i32 0, i32 0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fwrite(char const *, int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ strlen(char const *);
int fputs(const char *string, FILE *stream) {
  return fwrite(string, strlen(string), 1, stream);
}


x86 assembly (clang, -O0):
<fputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fwrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputs>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fwrite@plt>

LLVM IR (-O0):
define i32 @fputs(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = load i32*, i32** %4
%9 = call i32 @fwrite(i8* %5, i32 %7, i32 1, i32* %8)
ret i32 %9
}

LLVM IR (-O2):
define i32 @fputs(i8* %0, i32* nocapture %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = tail call i32 @fwrite(i8* %0, i32 %3, i32 1, i32* %1)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ kernelSignalHandler(int /*<<< orphan*/);
void os_enterKernel(void) { kernelSignalHandler(0); }


x86 assembly (clang, -O0):
<os_enterKernel>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1030 <kernelSignalHandler@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_enterKernel>:
xor    %edi,%edi
jmp    1030 <kernelSignalHandler@plt>

LLVM IR (-O0):
define void @os_enterKernel() {
%1 = call i32 @kernelSignalHandler(i32 0)
ret void
}

LLVM IR (-O2):
define void @os_enterKernel() {
%1 = tail call i32 @kernelSignalHandler(i32 0)
ret void
}
int mode_bits(const int version) {
  if (version < 41) {
    return 4;
  }
  if (version < 73) {
    return 3;
  }
  return version - 73;
}


x86 assembly (clang, -O0):
<mode_bits>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x29,-0x8(%rbp)
jge    111d <mode_bits+0x1d>
movl   $0x4,-0x4(%rbp)
jmp    113c <mode_bits+0x3c>
cmpl   $0x49,-0x8(%rbp)
jge    1133 <mode_bits+0x33>
movl   $0x3,-0x4(%rbp)
jmp    113c <mode_bits+0x3c>
mov    -0x8(%rbp),%eax
sub    $0x49,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_bits>:
lea    -0x49(%rdi),%eax
cmp    $0x49,%edi
mov    $0x3,%ecx
cmovge %eax,%ecx
cmp    $0x29,%edi
mov    $0x4,%eax
cmovge %ecx,%eax
ret

LLVM IR (-O0):
define i32 @mode_bits(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp slt i32 %4, 41
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 4, i32* %2
br label %14
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 73
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 3, i32* %2
br label %14
11: ; preds = %7
%12 = load i32, i32* %3
%13 = sub nsw i32 %12, 73
store i32 %13, i32* %2
br label %14
14: ; preds = %11, %10, %6
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
define i32 @mode_bits(i32 %0) {
%2 = icmp slt i32 %0, 41
%3 = icmp slt i32 %0, 73
%4 = add nsw i32 %0, -73
%5 = select i1 %3, i32 3, i32 %4
%6 = select i1 %2, i32 4, i32 %5
ret i32 %6
}
void rop3_38_0_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  unsigned char stk3;
  stk3 = T & S;
  stk2 = *D | stk3;
  stk1 = S ^ stk2;
  *D = stk1;
}


x86 assembly (clang, -O0):
<rop3_38_0_0>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
movzbl -0xa(%rbp),%eax
movzbl -0x9(%rbp),%ecx
and    %ecx,%eax
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
movzbl -0xd(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0xc(%rbp)
movzbl -0x9(%rbp),%eax
movzbl -0xc(%rbp),%ecx
xor    %ecx,%eax
mov    %al,-0xb(%rbp)
mov    -0xb(%rbp),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<rop3_38_0_0>:
and    %esi,%edx
or     (%rdi),%dl
xor    %sil,%dl
mov    %dl,(%rdi)
ret

LLVM IR (-O0):
define void @rop3_38_0_0(i8* %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
%10 = load i8, i8* %6
%11 = zext i8 %10 to i32
%12 = load i8, i8* %5
%13 = zext i8 %12 to i32
%14 = and i32 %11, %13
%15 = trunc i32 %14 to i8
store i8 %15, i8* %9
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = load i8, i8* %9
%20 = zext i8 %19 to i32
%21 = or i32 %18, %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %8
%23 = load i8, i8* %5
%24 = zext i8 %23 to i32
%25 = load i8, i8* %8
%26 = zext i8 %25 to i32
%27 = xor i32 %24, %26
%28 = trunc i32 %27 to i8
store i8 %28, i8* %7
%29 = load i8, i8* %7
%30 = load i8*, i8** %4
store i8 %29, i8* %30
ret void
}

LLVM IR (-O2):
define void @rop3_38_0_0(i8* nocapture %0, i8 zeroext %1, i8 zeroext %2) {
%4 = and i8 %2, %1
%5 = load i8, i8* %0
%6 = or i8 %5, %4
%7 = xor i8 %6, %1
store i8 %7, i8* %0
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(void) {
  int a = 1;
  printf("hello");
  a = 2;
  a = 3;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x8(%rbp)
movl   $0x3,-0x8(%rbp)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %2
store i32 3, i32* %2
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ log_cleanup();
void log_finalize() { log_cleanup(); }


x86 assembly (clang, -O0):
<log_finalize>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <log_cleanup@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_finalize>:
xor    %eax,%eax
jmp    1030 <log_cleanup@plt>

LLVM IR (-O0):
define void @log_finalize() {
%1 = call i32 (...) @log_cleanup()
ret void
}

LLVM IR (-O2):
define void @log_finalize() {
%1 = tail call i32 (...) @log_cleanup()
ret void
}