xunge/DecIR huggingface dataset:
/* Type definitions */
typedef int /*<<< orphan*/ p;

/* Variables and functions */
int /*<<< orphan*/ free(int *);
int *malloc(int);
void malloc_then_free_ok() {
  int *p = malloc(sizeof(p));
  if (p) {
    *p = 5;
    free(p);
  }
}


x86 assembly (clang, -O0):
<malloc_then_free_ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x8,%edi
call   1040 <malloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1154 <malloc_then_free_ok+0x34>
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<malloc_then_free_ok>:
push   %rax
mov    $0x8,%edi
call   1040 <malloc@plt>
test   %rax,%rax
je     113f <malloc_then_free_ok+0x1f>
movl   $0x5,(%rax)
mov    %rax,%rdi
pop    %rax
jmp    1030 <free@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @malloc_then_free_ok() {
%1 = alloca i32*
%2 = call i32* @malloc(i32 8)
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = icmp ne i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load i32*, i32** %1
store i32 5, i32* %6
%7 = load i32*, i32** %1
%8 = call i32 @free(i32* %7)
br label %9
9: ; preds = %5, %0
ret void
}

LLVM IR (-O2):
define void @malloc_then_free_ok() {
%1 = tail call i32* @malloc(i32 8)
%2 = icmp eq i32* %1, null
br i1 %2, label %5, label %3
3: ; preds = %0
store i32 5, i32* %1
%4 = tail call i32 @free(i32* %1)
br label %5
5: ; preds = %3, %0
ret void
}
/* Variables and functions */
int /*<<< orphan*/ driveForward(int);
void driveBackward(int speed) { driveForward(-speed); }


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

x86 assembly (clang, -O2):
<driveBackward>:
neg    %edi
jmp    1030 <driveForward@plt>

LLVM IR (-O0):
define void @driveBackward(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sub nsw i32 0, %3
%5 = call i32 @driveForward(i32 %4)
ret void
}

LLVM IR (-O2):
define void @driveBackward(i32 %0) {
%2 = sub nsw i32 0, %0
%3 = tail call i32 @driveForward(i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ linear_search_test();
int main() {
  linear_search_test();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <linear_search_test@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <linear_search_test@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @linear_search_test()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @linear_search_test()
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
void usage(char *util_name) {
  fprintf(stderr, "Usage: %s <file_name> <sector_number> [ <nsects> ]\n",
          util_name);
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    %rdi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [52 x i8] c"Usage: %s <file_name> <sector_number> [ <nsects> ]\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [52 x i8] c"Usage: %s <file_name> <sector_number> [ <nsects> ]\0A\00"
define void @usage(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
scalar_t__ close(int);
int write(int, char *, int);
int write_something(int fd) {
  int rc;
  rc = write(fd, "I Love Linux!!!\n", 23);
  if (rc != 23)
    return (0);
  if (close(fd))
    return (0);
  return (1);
}


x86 assembly (clang, -O0):
<write_something>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    0xecb(%rip),%rsi
mov    $0x17,%edx
call   1030 <write@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x17,-0xc(%rbp)
je     1158 <write_something+0x38>
movl   $0x0,-0x4(%rbp)
jmp    117d <write_something+0x5d>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
cmp    $0x0,%rax
je     1176 <write_something+0x56>
movl   $0x0,-0x4(%rbp)
jmp    117d <write_something+0x5d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_something>:
push   %rbx
mov    %edi,%ebx
lea    0xed6(%rip),%rsi
mov    $0x17,%edx
call   1030 <write@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x17,%ecx
jne    114f <write_something+0x2f>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"I Love Linux!!!\0A\00"
define i32 @write_something(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i32 @write(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 23)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 23
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %16
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i64 @close(i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 0, i32* %2
br label %16
15: ; preds = %10
store i32 1, i32* %2
br label %16
16: ; preds = %15, %14, %9
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
@.str = [17 x i8] c"I Love Linux!!!\0A\00"
define i32 @write_something(i32 %0) {
%2 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 23)
%3 = icmp eq i32 %2, 23
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i64 @close(i32 %0)
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ 0, %1 ], [ %7, %4 ]
ret i32 %9
}
void grib_set_bit_on(unsigned char *p, long *bitp) {
  unsigned char o = 1;
  p += (*bitp >> 3);
  o <<= 7 - ((*bitp) % 8);
  *p |= o;
  (*bitp) += 1;
}


x86 assembly (clang, -O0):
<grib_set_bit_on>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x1,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
sar    $0x3,%rax
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    $0x8,%ecx
cqto
idiv   %rcx
mov    $0x7,%ecx
sub    %rdx,%rcx
movzbl -0x11(%rbp),%eax
shl    %cl,%eax
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%edx
mov    -0x8(%rbp),%rax
movzbl (%rax),%ecx
or     %edx,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<grib_set_bit_on>:
mov    (%rsi),%rax
mov    %rax,%rdx
sar    $0x3,%rdx
lea    0x7(%rax),%ecx
test   %rax,%rax
cmovns %eax,%ecx
and    $0xf8,%ecx
sub    %ecx,%eax
mov    $0x7,%cl
sub    %al,%cl
mov    $0x1,%eax
shl    %cl,%eax
or     %al,(%rdi,%rdx,1)
addq   $0x1,(%rsi)
ret

LLVM IR (-O0):
define void @grib_set_bit_on(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i8
store i8* %0, i8** %3
store i64* %1, i64** %4
store i8 1, i8* %5
%6 = load i64*, i64** %4
%7 = load i64, i64* %6
%8 = ashr i64 %7, 3
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 %8
store i8* %10, i8** %3
%11 = load i64*, i64** %4
%12 = load i64, i64* %11
%13 = srem i64 %12, 8
%14 = sub nsw i64 7, %13
%15 = load i8, i8* %5
%16 = zext i8 %15 to i32
%17 = trunc i64 %14 to i32
%18 = shl i32 %16, %17
%19 = trunc i32 %18 to i8
store i8 %19, i8* %5
%20 = load i8, i8* %5
%21 = zext i8 %20 to i32
%22 = load i8*, i8** %3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %24, %21
%26 = trunc i32 %25 to i8
store i8 %26, i8* %22
%27 = load i64*, i64** %4
%28 = load i64, i64* %27
%29 = add nsw i64 %28, 1
store i64 %29, i64* %27
ret void
}

LLVM IR (-O2):
define void @grib_set_bit_on(i8* nocapture %0, i64* nocapture %1) {
%3 = load i64, i64* %1
%4 = ashr i64 %3, 3
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = srem i64 %3, 8
%7 = trunc i64 %6 to i32
%8 = sub nsw i32 7, %7
%9 = shl nuw nsw i32 1, %8
%10 = load i8, i8* %5
%11 = trunc i32 %9 to i8
%12 = or i8 %10, %11
store i8 %12, i8* %5
%13 = load i64, i64* %1
%14 = add nsw i64 %13, 1
store i64 %14, i64* %1
ret void
}
double *fct_7(double *a, double *b, double *c, double *d, double *e, double *f,
              double *g, double *h) {
  (void)a;
  (void)b;
  (void)c;
  (void)d;
  (void)e;
  (void)f;
  (void)g;
  (void)h;
  return h;
}


x86 assembly (clang, -O0):
<fct_7>:
push   %rbp
mov    %rsp,%rbp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fct_7>:
mov    0x10(%rsp),%rax
ret

LLVM IR (-O0):
define double* @fct_7(double* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double* %7) {
%9 = alloca double*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
store double* %0, double** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double* %7, double** %16
%17 = load double*, double** %9
%18 = load double*, double** %10
%19 = load double*, double** %11
%20 = load double*, double** %12
%21 = load double*, double** %13
%22 = load double*, double** %14
%23 = load double*, double** %15
%24 = load double*, double** %16
%25 = load double*, double** %16
ret double* %25
}

LLVM IR (-O2):
define double* @fct_7(double* nocapture readnone %0, double* nocapture readnone %1, double* nocapture readnone %2, double* nocapture readnone %3, double* nocapture readnone %4, double* nocapture readnone %5, double* nocapture readnone %6, double* readnone returned %7) {
ret double* %7
}
main(t) {
  for (;; t++) {
    putchar(t >> (t % 8));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
sar    %cl,%edi
mov    $0x0,%al
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <main+0x12>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %edi,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%ecx
and    $0x7,%cl
mov    %ebx,%edi
sar    %cl,%edi
xor    %eax,%eax
call   1030 <putchar@plt>
add    $0x1,%ebx
jmp    1120 <main+0x10>

LLVM IR (-O0):
define i32 @main(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* %3
%7 = srem i32 %6, 8
%8 = ashr i32 %5, %7
%9 = call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %8)
br label %10
10: ; preds = %4
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
br label %4
}

LLVM IR (-O2):
define i32 @main(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ %0, %1 ], [ %7, %2 ]
%4 = and i32 %3, 7
%5 = ashr i32 %3, %4
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @putchar to i32 (i32, ...)*)(i32 %5)
%7 = add nsw i32 %3, 1
br label %2
}
__attribute__((no, noclone)) signed __int128 t110_4sub(signed __int128 x) {
  signed __int128 y = (3);
  signed __int128 r;
  if (__builtin_sub_overflow(x, y, &r))
    bar();
  return r;
}


x86 assembly (clang, -O0):
<t110_4sub>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x3,-0x40(%rbp)
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x40(%rbp),%rsi
mov    -0x38(%rbp),%rax
sub    %rsi,%rdx
sbb    %rax,%rcx
seto   %al
mov    %rdx,-0x50(%rbp)
mov    %rcx,-0x48(%rbp)
test   $0x1,%al
jne    116e <t110_4sub+0x5e>
jmp    1175 <t110_4sub+0x65>
mov    $0x0,%al
call   1030 <bar@plt>
mov    -0x50(%rbp),%rax
mov    -0x48(%rbp),%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rdx
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t110_4sub>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0xfffffffffffffffd,%rbx
adc    $0xffffffffffffffff,%r14
jno    112b <t110_4sub+0x1b>
xor    %eax,%eax
call   1030 <bar@plt>
mov    %rbx,%rax
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define { i64, i64 } @t110_4sub(i64 %0, i64 %1) {
%3 = alloca i128
%4 = alloca i128
%5 = alloca i128
%6 = alloca i128
%7 = alloca i128
%8 = bitcast i128* %4 to { i64, i64 }*
%9 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 0
store i64 %0, i64* %9
%10 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %8, i32 0, i32 1
store i64 %1, i64* %10
%11 = load i128, i128* %4
store i128 %11, i128* %5
store i128 3, i128* %6
%12 = load i128, i128* %5
%13 = load i128, i128* %6
%14 = call { i128, i1 } @llvm.ssub.with.overflow.i128(i128 %12, i128 %13)
%15 = extractvalue { i128, i1 } %14, 1
%16 = extractvalue { i128, i1 } %14, 0
store i128 %16, i128* %7
br i1 %15, label %17, label %19
17: ; preds = %2
%18 = call i32 (...) @bar()
br label %19
19: ; preds = %17, %2
%20 = load i128, i128* %7
store i128 %20, i128* %3
%21 = bitcast i128* %3 to { i64, i64 }*
%22 = load { i64, i64 }, { i64, i64 }* %21
ret { i64, i64 } %22
}

LLVM IR (-O2):
define { i64, i64 } @t110_4sub(i64 %0, i64 %1) {
%3 = zext i64 %1 to i128
%4 = shl nuw i128 %3, 64
%5 = zext i64 %0 to i128
%6 = or i128 %4, %5
%7 = tail call { i128, i1 } @llvm.sadd.with.overflow.i128(i128 %6, i128 -3)
%8 = extractvalue { i128, i1 } %7, 1
%9 = extractvalue { i128, i1 } %7, 0
br i1 %8, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @bar()
br label %12
12: ; preds = %10, %2
%13 = trunc i128 %9 to i64
%14 = lshr i128 %9, 64
%15 = trunc i128 %14 to i64
%16 = insertvalue { i64, i64 } poison, i64 %13, 0
%17 = insertvalue { i64, i64 } %16, i64 %15, 1
ret { i64, i64 } %17
}
void i2c_start_wait(unsigned char address) {}


x86 assembly (clang, -O0):
<i2c_start_wait>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @i2c_start_wait(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
ret void
}

LLVM IR (-O2):
define void @i2c_start_wait(i8 zeroext %0) {
ret void
}
void r_rspi1_callback_transmitend(void) {}


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

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

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

LLVM IR (-O2):
define void @r_rspi1_callback_transmitend() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void so_init1() {
  printf("so_init1"
         "\n");
}


x86 assembly (clang, -O0):
<so_init1>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<so_init1>:
lea    0xee9(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"so_init1\0A\00"
define void @so_init1() {
%1 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [9 x i8] c"so_init1\00"
define void @so_init1() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
g() {
  for (;;)
    printf("hi\n");
}


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
jmp    1119 <g+0x9>
lea    0xee0(%rip),%rdi
call   1030 <printf@plt>
jmp    1119 <g+0x9>

x86 assembly (clang, -O2):
<g>:
push   %rbx
lea    0xee8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
jmp    1120 <g+0x10>

LLVM IR (-O0):
@.str = [4 x i8] c"hi\0A\00"
define i32 @g() {
br label %1
1: ; preds = %1, %0
%2 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %1
}

LLVM IR (-O2):
@str = [3 x i8] c"hi\00"
define i32 @g() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %1
}
/* Type definitions */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ j64_false_encode(char *, int);
int /*<<< orphan*/ memset(char *, char, int);
scalar_t__ strcmp(char *, char *);
int test_false_encode_2(void) {
  char buf[2 + 1];
  memset(buf, '\0', sizeof(buf));
  j64_false_encode(buf, 2);
  return strcmp(buf, "fa") == 0;
}


x86 assembly (clang, -O0):
<test_false_encode_2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    -0x3(%rbp),%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
lea    -0x3(%rbp),%rdi
mov    $0x2,%esi
call   1050 <j64_false_encode@plt>
lea    -0x3(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_false_encode_2>:
push   %rbx
sub    $0x10,%rsp
lea    0xd(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1030 <memset@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <j64_false_encode@plt>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"fa\00"
define i32 @test_false_encode_2() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i8 signext 0, i32 3)
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%5 = call i32 @j64_false_encode(i8* %4, i32 2)
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
@.str = [3 x i8] c"fa\00"
define i32 @test_false_encode_2() {
%1 = alloca [3 x i8]
%2 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i8 signext 0, i32 3)
%4 = call i32 @j64_false_encode(i8* %2, i32 2)
%5 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
%7 = zext i1 %6 to i32
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ __CPROVER_assume(int);
int /*<<< orphan*/ assert(int);
int f(int);
int main() {
  int i;
  __CPROVER_assume(i == 3 || i == 4);
  switch (f(i)) {
  case 4:
    assert(i == 3);
    break;
  case 5:
    assert(i == 4);
    break;
  default:
    assert(0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%al
cmpl   $0x3,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     1158 <main+0x28>
cmpl   $0x4,-0x8(%rbp)
sete   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1040 <__CPROVER_assume@plt>
mov    -0x8(%rbp),%edi
call   1030 <f@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
sub    $0x4,%eax
je     1192 <main+0x62>
jmp    1181 <main+0x51>
mov    -0x10(%rbp),%eax
sub    $0x5,%eax
je     11a8 <main+0x78>
jmp    11be <main+0x8e>
cmpl   $0x3,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    11c5 <main+0x95>
cmpl   $0x4,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
jmp    11c5 <main+0x95>
xor    %edi,%edi
call   1050 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %edi,%edi
call   1040 <__CPROVER_assume@plt>
call   1030 <f@plt>
xor    %edi,%edi
call   1050 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* %2
%4 = icmp eq i32 %3, 3
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 4
br label %8
8: ; preds = %5, %0
%9 = phi i1 [ true, %0 ], [ %7, %5 ]
%10 = zext i1 %9 to i32
%11 = call i32 @__CPROVER_assume(i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @f(i32 %12)
switch i32 %13, label %24 [
i32 4, label %14
i32 5, label %19
]
14: ; preds = %8
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 3
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
br label %26
19: ; preds = %8
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 4
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
br label %26
24: ; preds = %8
%25 = call i32 @assert(i32 0)
br label %26
26: ; preds = %24, %19, %14
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @__CPROVER_assume(i32 0)
%2 = tail call i32 @f(i32 undef)
%3 = tail call i32 @assert(i32 0)
ret i32 0
}
int test_imm_2Cuint64_highword_mem(unsigned long long *val) {
  return ((*val >> 32) & (0x2C << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_2Cuint64_highword_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
shr    $0x20,%rdx
and    $0x2c,%rdx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_2Cuint64_highword_mem>:
testb  $0x2c,0x4(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

LLVM IR (-O0):
define i32 @test_imm_2Cuint64_highword_mem(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = load i64, i64* %3
%5 = lshr i64 %4, 32
%6 = and i64 %5, 44
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i32 -20, i32 -40
ret i32 %9
}

LLVM IR (-O2):
define i32 @test_imm_2Cuint64_highword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 188978561024
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
void clear_array(char array[100]) {
  int i = 0;
  for (i = 0; i < 100; i++) {
    array[i] = 0;
  };
}


x86 assembly (clang, -O0):
<clear_array>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    113a <clear_array+0x3a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1116 <clear_array+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_array>:
xorps  %xmm0,%xmm0
movups %xmm0,0x50(%rdi)
movups %xmm0,0x40(%rdi)
movups %xmm0,0x30(%rdi)
movups %xmm0,0x20(%rdi)
movups %xmm0,0x10(%rdi)
movups %xmm0,(%rdi)
movl   $0x0,0x60(%rdi)
ret

LLVM IR (-O0):
define void @clear_array(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %12, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 100
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %7
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @clear_array(i8* nocapture writeonly %0) {
ret void
}
/* Type definitions */
typedef char *uint32_t;

/* Variables and functions */
uint32_t crc32c_intel_le_hw_byte(uint32_t crc, unsigned char const *data,
                                 unsigned length) {
  while (length--) {
    __asm__ __volatile__(".byte 0xf2, 0xf, 0x38, 0xf0, 0xf1"
                         : "=S"(crc)
                         : "0"(crc), "c"(*data));
    data++;
  }
  return crc;
}


x86 assembly (clang, -O0):
<crc32c_intel_le_hw_byte>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1147 <crc32c_intel_le_hw_byte+0x47>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%cl
crc32  %cl,%esi
mov    %rsi,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    110f <crc32c_intel_le_hw_byte+0xf>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc32c_intel_le_hw_byte>:
mov    %rsi,%rax
mov    %rdi,%rsi
test   %edx,%edx
je     1121 <crc32c_intel_le_hw_byte+0x21>
mov    %edx,%edx
xor    %edi,%edi
xchg   %ax,%ax
movzbl (%rax,%rdi,1),%ecx
crc32  %cl,%esi
add    $0x1,%rdi
cmp    %edi,%edx
jne    1110 <crc32c_intel_le_hw_byte+0x10>
mov    %rsi,%rax
ret

LLVM IR (-O0):
define i8* @crc32c_intel_le_hw_byte(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
br label %7
7: ; preds = %11, %3
%8 = load i32, i32* %6
%9 = add i32 %8, -1
store i32 %9, i32* %6
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i8*, i8** %5
%14 = load i8, i8* %13
%15 = call i8* asm sideeffect ".byte 0xf2, 0xf, 0x38, 0xf0, 0xf1", "={si},0,{cx},~{dirflag},~{fpsr},~{flags}"(i8* %12, i8 %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %5
br label %7
18: ; preds = %7
%19 = load i8*, i8** %4
ret i8* %19
}

LLVM IR (-O2):
define i8* @crc32c_intel_le_hw_byte(i8* %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %14, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %9, %5 ], [ %2, %3 ]
%7 = phi i8* [ %12, %5 ], [ %1, %3 ]
%8 = phi i8* [ %11, %5 ], [ %0, %3 ]
%9 = add i32 %6, -1
%10 = load i8, i8* %7
%11 = tail call i8* asm sideeffect ".byte 0xf2, 0xf, 0x38, 0xf0, 0xf1", "={si},0,{cx},~{dirflag},~{fpsr},~{flags}"(i8* %8, i8 %10)
%12 = getelementptr inbounds i8, i8* %7, i64 1
%13 = icmp eq i32 %9, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %3
%15 = phi i8* [ %0, %3 ], [ %11, %5 ]
ret i8* %15
}
/* Type definitions */
typedef unsigned long uint32_t;

/* Variables and functions */
void SysCtlMOSCConfigSet(uint32_t ui32Config) {
  (*((volatile unsigned long *)(0x400FE07C))) = ui32Config;
}


x86 assembly (clang, -O0):
<SysCtlMOSCConfigSet>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0x400fe07c,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<SysCtlMOSCConfigSet>:
mov    %rdi,0x400fe07c
40
ret

LLVM IR (-O0):
define void @SysCtlMOSCConfigSet(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
store volatile i64 %3, i64* inttoptr (i64 1074782332 to i64*)
ret void
}

LLVM IR (-O2):
define void @SysCtlMOSCConfigSet(i64 %0) {
store volatile i64 %0, i64* inttoptr (i64 1074782332 to i64*)
ret void
}
/* Variables and functions */
int U_WMRCORENONE_get(char *);
int U_WMRF1_get(void) { return U_WMRCORENONE_get("U_WMRF1"); }


x86 assembly (clang, -O0):
<U_WMRF1_get>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
call   1030 <U_WMRCORENONE_get@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<U_WMRF1_get>:
lea    0xee9(%rip),%rdi
jmp    1030 <U_WMRCORENONE_get@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"U_WMRF1\00"
define i32 @U_WMRF1_get() {
%1 = call i32 @U_WMRCORENONE_get(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 %1
}

LLVM IR (-O2):
@.str = [8 x i8] c"U_WMRF1\00"
define i32 @U_WMRF1_get() {
%1 = tail call i32 @U_WMRCORENONE_get(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
ret i32 %1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *);
void main() {
  int a, b, c;
  printf("input a and b\n");
  scanf("%d,%d", &a, &b);
  c = a + b;
  printf("a+b=%d\n", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x4(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed6(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
call   1050 <scanf@plt>
mov    (%rsp),%esi
add    0x4(%rsp),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [15 x i8] c"input a and b\0A\00"
@.str.1 = [6 x i8] c"%d,%d\00"
@.str.2 = [8 x i8] c"a+b=%d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = add nsw i32 %6, %7
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret void
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%d,%d\00"
@.str.2 = [8 x i8] c"a+b=%d\0A\00"
@str = [14 x i8] c"input a and b\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = add nsw i32 %8, %7
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret void
}
/* Variables and functions */
char *malloc(int);
int /*<<< orphan*/ memmove(char *, char *, int);
int strlen(char *);
char *strdup(char *p) {
  int n;
  char *np;
  n = strlen(p) + 1;
  np = malloc(n);
  if (np)
    memmove(np, p, n);
  return np;
}


x86 assembly (clang, -O0):
<strdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1172 <strdup+0x42>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1050 <memmove@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strdup>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     115d <strdup+0x2d>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <memmove@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @strdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, 1
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %1
%13 = load i8*, i8** %4
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = call i32 @memmove(i8* %13, i8* %14, i32 %15)
br label %17
17: ; preds = %12, %1
%18 = load i8*, i8** %4
ret i8* %18
}

LLVM IR (-O2):
define i8* @strdup(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @memmove(i8* %4, i8* %0, i32 %3)
br label %8
8: ; preds = %6, %1
ret i8* %4
}
/* Variables and functions */
int /*<<< orphan*/ init();
void CPU_Init(void) {
  init();
  return;
}


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

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

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

LLVM IR (-O2):
define void @CPU_Init() {
%1 = tail call i32 (...) @init()
ret void
}
/* Type definitions */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AT_FDCWD;
int /*<<< orphan*/ AT_SYMLINK_NOFOLLOW;
int fstatat(int /*<<< orphan*/, char const *, struct stat *,
            int /*<<< orphan*/);
int lstat(const char *restrict path, struct stat *restrict result) {
  return fstatat(AT_FDCWD, path, result, AT_SYMLINK_NOFOLLOW);
}


x86 assembly (clang, -O0):
<lstat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    0x2ea8(%rip),%rax
mov    (%rax),%ecx
call   1030 <fstatat@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lstat>:
mov    %rsi,%rdx
mov    %rdi,%rsi
mov    0x2eb3(%rip),%rax
mov    (%rax),%edi
mov    0x2eba(%rip),%rax
mov    (%rax),%ecx
jmp    1030 <fstatat@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
define i32 @lstat(i8* noalias %0, %struct.stat* noalias %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%5 = load i32, i32* @AT_FDCWD
%6 = load i8*, i8** %3
%7 = load %struct.stat*, %struct.stat** %4
%8 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%9 = call i32 @fstatat(i32 %5, i8* %6, %struct.stat* %7, i32 %8)
ret i32 %9
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@AT_FDCWD = global i32 0
@AT_SYMLINK_NOFOLLOW = global i32 0
define i32 @lstat(i8* noalias %0, %struct.stat* noalias %1) {
%3 = load i32, i32* @AT_FDCWD
%4 = load i32, i32* @AT_SYMLINK_NOFOLLOW
%5 = tail call i32 @fstatat(i32 %3, i8* %0, %struct.stat* %1, i32 %4)
ret i32 %5
}
/* Variables and functions */
unsigned char asm_sleep(unsigned int);
unsigned char sleep(unsigned int msec) { return asm_sleep(msec); }


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

x86 assembly (clang, -O2):
<sleep>:
jmp    1030 <asm_sleep@plt>

LLVM IR (-O0):
define zeroext i8 @sleep(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call zeroext i8 @asm_sleep(i32 %3)
ret i8 %4
}

LLVM IR (-O2):
define zeroext i8 @sleep(i32 %0) {
%2 = tail call zeroext i8 @asm_sleep(i32 %0)
ret i8 %2
}
/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void _do_offset(int offset) {
  while (offset-- > 0)
    fputc(' ', stdout);
}


x86 assembly (clang, -O0):
<_do_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x4(%rbp)
cmp    $0x0,%eax
jle    1147 <_do_offset+0x37>
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    111b <_do_offset+0xb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_do_offset>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1145 <_do_offset+0x35>
mov    %edi,%ebx
add    $0x1,%ebx
mov    0x2ebc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1130 <_do_offset+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stdout = global i32 0
define void @_do_offset(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %9
3: ; preds = %1, %3
%4 = phi i32 [ %5, %3 ], [ %0, %1 ]
%5 = add nsw i32 %4, -1
%6 = load i32, i32* @stdout
%7 = tail call i32 @fputc(i8 signext 32, i32 %6)
%8 = icmp ugt i32 %4, 1
br i1 %8, label %3, label %9
9: ; preds = %3, %1
ret void
}
/* Type definitions */
struct neusession {
  int dummy;
};
struct neupdu {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void msg_dispatch(struct neusession *ses, struct neupdu *pdu) {
  printf("==>recv pdu %d\n", (int)pdu);
}


x86 assembly (clang, -O0):
<msg_dispatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%esi
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msg_dispatch>:
lea    0xee9(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.neusession = type { i32 }
%struct.neupdu = type { i32 }
@.str = [16 x i8] c"==>recv pdu %d\0A\00"
define void @msg_dispatch(%struct.neusession* %0, %struct.neupdu* %1) {
%3 = alloca %struct.neusession*
%4 = alloca %struct.neupdu*
store %struct.neusession* %0, %struct.neusession** %3
store %struct.neupdu* %1, %struct.neupdu** %4
%5 = load %struct.neupdu*, %struct.neupdu** %4
%6 = ptrtoint %struct.neupdu* %5 to i32
%7 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %6)
ret void
}

LLVM IR (-O2):
%struct.neusession = type { i32 }
%struct.neupdu = type { i32 }
@.str = [16 x i8] c"==>recv pdu %d\0A\00"
define void @msg_dispatch(%struct.neusession* nocapture readnone %0, %struct.neupdu* %1) {
%3 = ptrtoint %struct.neupdu* %1 to i64
%4 = trunc i64 %3 to i32
%5 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %4)
ret void
}
/* Variables and functions */
char *strchr(char *, int);
char *rx_chr(char *rx, size_t rxn, int c) {
  char *r = strchr(rx, c);
  return r - rx >= rxn ? NULL : r;
}


x86 assembly (clang, -O0):
<rx_chr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <strchr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
cmp    -0x10(%rbp),%rax
jb     1153 <rx_chr+0x43>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    115b <rx_chr+0x4b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rx_chr>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%esi
call   1030 <strchr@plt>
mov    %rax,%rcx
sub    %rbx,%rcx
xor    %edx,%edx
cmp    %r14,%rcx
cmovae %rdx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @rx_chr(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %6
%10 = call i8* @strchr(i8* %8, i32 %9)
store i8* %10, i8** %7
%11 = load i8*, i8** %7
%12 = load i8*, i8** %4
%13 = ptrtoint i8* %11 to i64
%14 = ptrtoint i8* %12 to i64
%15 = sub i64 %13, %14
%16 = load i64, i64* %5
%17 = icmp uge i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %3
br label %21
19: ; preds = %3
%20 = load i8*, i8** %7
br label %21
21: ; preds = %19, %18
%22 = phi i8* [ null, %18 ], [ %20, %19 ]
ret i8* %22
}

LLVM IR (-O2):
define i8* @rx_chr(i8* %0, i64 %1, i32 %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 %2)
%5 = ptrtoint i8* %4 to i64
%6 = ptrtoint i8* %0 to i64
%7 = sub i64 %5, %6
%8 = icmp ult i64 %7, %1
%9 = select i1 %8, i8* %4, i8* null
ret i8* %9
}
int rlDidExperimentConnect() { return 1; }


x86 assembly (clang, -O0):
<rlDidExperimentConnect>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<rlDidExperimentConnect>:
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @rlDidExperimentConnect() {
ret i32 1
}

LLVM IR (-O2):
define i32 @rlDidExperimentConnect() {
ret i32 1
}
/* Type definitions */
struct sock {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ sock_read(struct sock *, char *, int);
void sock_dump(struct sock *sock) {
  char buf[BUFSIZ];
  sock_read(sock, buf, sizeof(buf));
}


x86 assembly (clang, -O0):
<sock_dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ebd(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    %eax,%edx
call   1030 <sock_read@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sock_dump>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rsi
mov    %rdx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rsi
mov    %rsi,%rsp
call   1030 <sock_read@plt>
mov    %rbp,%rsp
pop    %rbp
ret

LLVM IR (-O0):
%struct.sock = type { i32 }
@BUFSIZ = global i32 0
define void @sock_dump(%struct.sock* %0) {
%2 = alloca %struct.sock*
%3 = alloca i8*
%4 = alloca i64
store %struct.sock* %0, %struct.sock** %2
%5 = load i32, i32* @BUFSIZ
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
store i8* %7, i8** %3
%8 = alloca i8, i64 %6
store i64 %6, i64* %4
%9 = load %struct.sock*, %struct.sock** %2
%10 = trunc i64 %6 to i32
%11 = call i32 @sock_read(%struct.sock* %9, i8* %8, i32 %10)
%12 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
%struct.sock = type { i32 }
@BUFSIZ = global i32 0
define void @sock_dump(%struct.sock* %0) {
%2 = load i32, i32* @BUFSIZ
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32 @sock_read(%struct.sock* %0, i8* %4, i32 %2)
ret void
}
/* Type definitions */
typedef int uint64_t;
typedef int uint16_t;

/* Variables and functions */
uint64_t bytes_to_blocks(uint64_t bytes, uint16_t block_size) {
  return (bytes + block_size - 1) / block_size;
}


x86 assembly (clang, -O0):
<bytes_to_blocks>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
sub    $0x1,%eax
cltd
idivl  -0x8(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bytes_to_blocks>:
lea    (%rdi,%rsi,1),%eax
add    $0xffffffff,%eax
cltd
idiv   %esi
ret

LLVM IR (-O0):
define i32 @bytes_to_blocks(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 = load i32, i32* %4
%7 = add nsw i32 %5, %6
%8 = sub nsw i32 %7, 1
%9 = load i32, i32* %4
%10 = sdiv i32 %8, %9
ret i32 %10
}

LLVM IR (-O2):
define i32 @bytes_to_blocks(i32 %0, i32 %1) {
%3 = add i32 %0, -1
%4 = add i32 %3, %1
%5 = sdiv i32 %4, %1
ret i32 %5
}
void foo805(int p) {}


x86 assembly (clang, -O0):
<foo805>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
pop    %rbp
ret

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

LLVM IR (-O0):
define void @foo805(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
ret void
}

LLVM IR (-O2):
define void @foo805(i32 %0) {
ret void
}
char foo(char bar[]) { return bar[1]; }


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
mov    0x1(%rdi),%al
ret

LLVM IR (-O0):
define signext i8 @foo(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %4
ret i8 %5
}

LLVM IR (-O2):
define signext i8 @foo(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 1
%3 = load i8, i8* %2
ret i8 %3
}
/* Type definitions */
typedef int /*<<< orphan*/ str;
typedef int ssize_t;

/* Variables and functions */
int write(int, char *, int);
int GPIO_write(int gpio_fd, int onoff) {
  ssize_t ret;
  char str[1];
  str[0] = ((char)'0') + onoff;
  ret = write(gpio_fd, str, sizeof(str));
  return (ret == sizeof(str)) ? 0 : 1;
}


x86 assembly (clang, -O0):
<GPIO_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %al,-0xd(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x1,%rdx
cmove  %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPIO_write>:
push   %rax
add    $0x30,%sil
mov    %sil,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
setne  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @GPIO_write(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = add nsw i32 48, %7
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
store i8 %9, i8* %10
%11 = load i32, i32* %3
%12 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
%13 = call i32 @write(i32 %11, i8* %12, i32 1)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = icmp eq i64 %15, 1
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 0, i32 1
ret i32 %18
}

LLVM IR (-O2):
define i32 @GPIO_write(i32 %0, i32 %1) {
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%5 = trunc i32 %1 to i8
%6 = add i8 %5, 48
store i8 %6, i8* %4
%7 = call i32 @write(i32 %0, i8* %4, i32 1)
%8 = icmp ne i32 %7, 1
%9 = zext i1 %8 to i32
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ io_out8(int, int);
int /*<<< orphan*/ wait_KBC_sendready();
void init_keyboard(void) {
  wait_KBC_sendready();
  io_out8(0x0064, 0x60);
  wait_KBC_sendready();
  io_out8(0x0060, 0x47);
}


x86 assembly (clang, -O0):
<init_keyboard>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <wait_KBC_sendready@plt>
mov    $0x64,%edi
mov    $0x60,%esi
call   1040 <io_out8@plt>
mov    $0x0,%al
call   1030 <wait_KBC_sendready@plt>
mov    $0x60,%edi
mov    $0x47,%esi
call   1040 <io_out8@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_keyboard>:
push   %rax
xor    %eax,%eax
call   1030 <wait_KBC_sendready@plt>
mov    $0x64,%edi
mov    $0x60,%esi
call   1040 <io_out8@plt>
xor    %eax,%eax
call   1030 <wait_KBC_sendready@plt>
mov    $0x60,%edi
mov    $0x47,%esi
pop    %rax
jmp    1040 <io_out8@plt>

LLVM IR (-O0):
define void @init_keyboard() {
%1 = call i32 (...) @wait_KBC_sendready()
%2 = call i32 @io_out8(i32 100, i32 96)
%3 = call i32 (...) @wait_KBC_sendready()
%4 = call i32 @io_out8(i32 96, i32 71)
ret void
}

LLVM IR (-O2):
define void @init_keyboard() {
%1 = tail call i32 (...) @wait_KBC_sendready()
%2 = tail call i32 @io_out8(i32 100, i32 96)
%3 = tail call i32 (...) @wait_KBC_sendready()
%4 = tail call i32 @io_out8(i32 96, i32 71)
ret void
}
/* Variables and functions */
char *Cvar_BitInfo(int);
char *Cvar_Serverinfo(void) { return Cvar_BitInfo(4); }


x86 assembly (clang, -O0):
<Cvar_Serverinfo>:
push   %rbp
mov    %rsp,%rbp
mov    $0x4,%edi
call   1030 <Cvar_BitInfo@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cvar_Serverinfo>:
mov    $0x4,%edi
jmp    1030 <Cvar_BitInfo@plt>

LLVM IR (-O0):
define i8* @Cvar_Serverinfo() {
%1 = call i8* @Cvar_BitInfo(i32 4)
ret i8* %1
}

LLVM IR (-O2):
define i8* @Cvar_Serverinfo() {
%1 = tail call i8* @Cvar_BitInfo(i32 4)
ret i8* %1
}