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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void print_help(FILE *fp) {
  fprintf(fp, "csubst --file=<in-file>:<out-file>\n");
}


x86 assembly (clang, -O0):
<print_help>:
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):
<print_help>:
mov    %rdi,%rcx
lea    0xee6(%rip),%rdi
mov    $0x23,%esi
mov    $0x1,%edx
jmp    1030 <fwrite@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"csubst --file=<in-file>:<out-file>\0A\00"
define void @print_help(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @fprintf(i32* %3, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"csubst --file=<in-file>:<out-file>\0A\00"
define void @print_help(i32* nocapture %0) {
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 35, i64 1, i32* %0)
ret void
}
push(char *stack, char c, int *top) { *(stack + (++(*top))) = c; }


x86 assembly (clang, -O0):
<push>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rsi
mov    (%rsi),%ecx
add    $0x1,%ecx
mov    %ecx,(%rsi)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<push>:
movslq (%rdx),%rax
lea    0x1(%rax),%rcx
mov    %ecx,(%rdx)
mov    %sil,0x1(%rdi,%rax,1)
ret

LLVM IR (-O0):
define i32 @push(i8* %0, i8 signext %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32*
store i8* %0, i8** %5
store i8 %1, i8* %6
store i32* %2, i32** %7
%8 = load i8, i8* %6
%9 = load i8*, i8** %5
%10 = load i32*, i32** %7
%11 = load i32, i32* %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %10
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %9, i64 %13
store i8 %8, i8* %14
%15 = load i32, i32* %4
ret i32 %15
}

LLVM IR (-O2):
define i32 @push(i8* nocapture writeonly %0, i8 signext %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = add nsw i32 %4, 1
store i32 %5, i32* %2
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %1, i8* %7
ret i32 undef
}
int Section2Seconds(int seconds) { return seconds % 60; }


x86 assembly (clang, -O0):
<Section2Seconds>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Section2Seconds>:
movslq %edi,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x3c,%ecx,%ecx
sub    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @Section2Seconds(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 60
ret i32 %4
}

LLVM IR (-O2):
define i32 @Section2Seconds(i32 %0) {
%2 = srem i32 %0, 60
ret i32 %2
}
/* Variables and functions */
double linePointDist(int *, int *, int *, int);
int /*<<< orphan*/ printf(char *, double);
int main() {
  int a[2] = {1, 2};
  int b[2] = {2, 1};
  int c[2] = {0, 0};
  printf("c to AB segment distance is %f\n", linePointDist(a, b, c, 1));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0xc(%rbp),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x1,%ecx
call   1050 <linePointDist@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x200000001,%rax
mov    %rax,0x10(%rsp)
movabs $0x100000002,%rax
mov    %rax,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
mov    $0x1,%ecx
call   1040 <linePointDist@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.a = [2 x i32] [i32 1, i32 2]
@__const.main.b = [2 x i32] [i32 2, i32 1]
@.str = [32 x i8] c"c to AB segment distance is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x i32]
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
store i32 0, i32* %1
%5 = bitcast [2 x i32]* %2 to i8*
%6 = bitcast [2 x i32]* %3 to i8*
%7 = bitcast [2 x i32]* %4 to i8*
%8 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%11 = call double @linePointDist(i32* %8, i32* %9, i32* %10, i32 1)
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c"c to AB segment distance is %f\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = bitcast i64* %1 to i8*
store i64 8589934593, i64* %1
%5 = bitcast i64* %2 to i8*
store i64 4294967298, i64* %2
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = bitcast i64* %1 to i32*
%8 = bitcast i64* %2 to i32*
%9 = bitcast i64* %3 to i32*
%10 = call double @linePointDist(i32* %7, i32* %8, i32* %9, i32 1)
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), double %10)
ret i32 0
}
int probe1(unsigned char root, int codeword) {
  int newHashCode = ((root << 4) ^ codeword) & 0xfff;
  return (newHashCode);
}


x86 assembly (clang, -O0):
<probe1>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x4,%eax
xor    -0x8(%rbp),%eax
and    $0xfff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<probe1>:
mov    %esi,%eax
shl    $0x4,%edi
and    $0xfff,%eax
xor    %edi,%eax
ret

LLVM IR (-O0):
define i32 @probe1(i8 zeroext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = load i8, i8* %3
%7 = zext i8 %6 to i32
%8 = shl i32 %7, 4
%9 = load i32, i32* %4
%10 = xor i32 %8, %9
%11 = and i32 %10, 4095
store i32 %11, i32* %5
%12 = load i32, i32* %5
ret i32 %12
}

LLVM IR (-O2):
define i32 @probe1(i8 zeroext %0, i32 %1) {
%3 = zext i8 %0 to i32
%4 = shl nuw nsw i32 %3, 4
%5 = and i32 %1, 4095
%6 = xor i32 %4, %5
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rmdir(char *);
int main() {
  int a;
  printf("Interstellar\n");
  chdir("/home/shahas/Desktop/");
  rmdir("new_dir");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1050 <printf@plt>
lea    0xec3(%rip),%rdi
call   1040 <chdir@plt>
lea    0xecd(%rip),%rdi
call   1030 <rmdir@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
call   1050 <chdir@plt>
lea    0xec6(%rip),%rdi
call   1040 <rmdir@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Interstellar\0A\00"
@.str.1 = [22 x i8] c"/home/shahas/Desktop/\00"
@.str.2 = [8 x i8] c"new_dir\00"
define i32 @main() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @chdir(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"/home/shahas/Desktop/\00"
@.str.2 = [8 x i8] c"new_dir\00"
@str = [13 x i8] c"Interstellar\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @chdir(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @rmdir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int rk_threads(int);
int mk_threads(int n) { return rk_threads(n); }


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

x86 assembly (clang, -O2):
<mk_threads>:
jmp    1030 <rk_threads@plt>

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

LLVM IR (-O2):
define i32 @mk_threads(i32 %0) {
%2 = tail call i32 @rk_threads(i32 %0)
ret i32 %2
}
/* Variables and functions */
void *array_get(void **base, size_t length, int position) {
  if (position > length)
    return (void *)0;
  if (position < 0)
    return (void *)0;
  return base[position];
}


x86 assembly (clang, -O0):
<array_get>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    112a <array_get+0x2a>
movq   $0x0,-0x8(%rbp)
jmp    1151 <array_get+0x51>
cmpl   $0x0,-0x1c(%rbp)
jge    1141 <array_get+0x41>
movq   $0x0,-0x8(%rbp)
jmp    1151 <array_get+0x51>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_get>:
xor    %eax,%eax
test   %edx,%edx
js     1112 <array_get+0x12>
movslq %edx,%rcx
cmp    %rsi,%rcx
ja     1112 <array_get+0x12>
mov    (%rdi,%rcx,8),%rax
ret

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

LLVM IR (-O2):
define i8* @array_get(i8** nocapture %0, i64 %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = icmp ugt i64 %4, %1
%6 = icmp slt i32 %2, 0
%7 = or i1 %6, %5
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = getelementptr inbounds i8*, i8** %0, i64 %4
%10 = load i8*, i8** %9
br label %11
11: ; preds = %3, %8
%12 = phi i8* [ %10, %8 ], [ null, %3 ]
ret i8* %12
}
pred() { return 1; }


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

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

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

LLVM IR (-O2):
define i32 @pred() {
ret i32 1
}
double Sleef_sin_u35(double x) { return __builtin_sin(x); }


x86 assembly (clang, -O0):
<Sleef_sin_u35>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Sleef_sin_u35>:
jmp    1030 <sin@plt>

LLVM IR (-O0):
define double @Sleef_sin_u35(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call double @sin(double %3)
ret double %4
}

LLVM IR (-O2):
define double @Sleef_sin_u35(double %0) {
%2 = tail call double @sin(double %0)
ret double %2
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}


x86 assembly (clang, -O0):
<gcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1138 <gcd+0x28>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1152 <gcd+0x42>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
mov    %rdx,%rsi
call   1030 <gcd@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcd>:
mov    %rdi,%rax
test   %rsi,%rsi
je     1135 <gcd+0x35>
mov    %rsi,%rdx
jmp    111d <gcd+0x1d>
nopl   (%rax)
cqto
idiv   %rcx
mov    %rcx,%rax
test   %rdx,%rdx
je     1132 <gcd+0x32>
mov    %rdx,%rcx
mov    %rax,%rdx
or     %rcx,%rdx
shr    $0x20,%rdx
jne    1110 <gcd+0x10>
xor    %edx,%edx
div    %ecx
jmp    1115 <gcd+0x15>
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i64 @gcd(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i64, i64* %4
store i64 %9, i64* %3
br label %16
10: ; preds = %2
%11 = load i64, i64* %5
%12 = load i64, i64* %4
%13 = load i64, i64* %5
%14 = srem i64 %12, %13
%15 = call i64 @gcd(i64 %11, i64 %14)
store i64 %15, i64* %3
br label %16
16: ; preds = %10, %8
%17 = load i64, i64* %3
ret i64 %17
}

LLVM IR (-O2):
define i64 @gcd(i64 %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %9, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %7, %4 ], [ %1, %2 ]
%6 = phi i64 [ %5, %4 ], [ %0, %2 ]
%7 = srem i64 %6, %5
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4, %2
%10 = phi i64 [ %0, %2 ], [ %5, %4 ]
ret i64 %10
}
void nseel_asm_stack_push_end(void) {}


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

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

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

LLVM IR (-O2):
define void @nseel_asm_stack_push_end() {
ret void
}
int fun2(int a, int b) {}


x86 assembly (clang, -O0):
<fun2>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @fun2(i32 %0, i32 %1) {
ret i32 undef
}
/* Variables and functions */
int f();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int x = 5 + (5 + (f() + (10 / 5)));
  printf("%d\n", x);
  return 0;
}


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

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

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @f()
%2 = add nsw i32 %1, 12
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 0
}
/* Variables and functions */
char *cmalloc(int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strndup(char *str, int len) {
  char *tmp;
  tmp = cmalloc(len + 1);
  strncpy(tmp, str, len);
  return tmp;
}


x86 assembly (clang, -O0):
<strndup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1040 <cmalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strndup>:
push   %r15
push   %r14
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0x1(%r15),%edi
call   1040 <cmalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @strndup(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = add nsw i32 %6, 1
%8 = call i8* @cmalloc(i32 %7)
store i8* %8, i8** %5
%9 = load i8*, i8** %5
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = call i32 @strncpy(i8* %9, i8* %10, i32 %11)
%13 = load i8*, i8** %5
ret i8* %13
}

LLVM IR (-O2):
define i8* @strndup(i8* %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = tail call i8* @cmalloc(i32 %3)
%5 = tail call i32 @strncpy(i8* %4, i8* %0, i32 %1)
ret i8* %4
}
/* Variables and functions */
int libiso_msgs__sev_to_text(int, char **, int /*<<< orphan*/);
int iso_sev_to_text(int severity_number, char **severity_name) {
  int ret;
  ret = libiso_msgs__sev_to_text(severity_number, severity_name, 0);
  return ret;
}


x86 assembly (clang, -O0):
<iso_sev_to_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1030 <libiso_msgs__sev_to_text@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iso_sev_to_text>:
xor    %edx,%edx
jmp    1030 <libiso_msgs__sev_to_text@plt>

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

LLVM IR (-O2):
define i32 @iso_sev_to_text(i32 %0, i8** %1) {
%3 = tail call i32 @libiso_msgs__sev_to_text(i32 %0, i8** %1, i32 0)
ret i32 %3
}
/* Type definitions */
struct genhash {
  int dummy;
};
struct entry_hash {
  int dummy;
};

/* Variables and functions */
scalar_t__ genhash_copy(struct genhash const *);
struct entry_hash *entry_hash_copy(const struct entry_hash *tthis) {
  return (struct entry_hash *)genhash_copy((const struct genhash *)tthis);
}


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

x86 assembly (clang, -O2):
<entry_hash_copy>:
jmp    1030 <genhash_copy@plt>

LLVM IR (-O0):
%struct.entry_hash = type { i32 }
%struct.genhash = type { i32 }
define %struct.entry_hash* @entry_hash_copy(%struct.entry_hash* %0) {
%2 = alloca %struct.entry_hash*
store %struct.entry_hash* %0, %struct.entry_hash** %2
%3 = load %struct.entry_hash*, %struct.entry_hash** %2
%4 = bitcast %struct.entry_hash* %3 to %struct.genhash*
%5 = call i64 @genhash_copy(%struct.genhash* %4)
%6 = inttoptr i64 %5 to %struct.entry_hash*
ret %struct.entry_hash* %6
}

LLVM IR (-O2):
%struct.entry_hash = type { i32 }
%struct.genhash = type { i32 }
define %struct.entry_hash* @entry_hash_copy(%struct.entry_hash* %0) {
%2 = bitcast %struct.entry_hash* %0 to %struct.genhash*
%3 = tail call i64 @genhash_copy(%struct.genhash* %2)
%4 = inttoptr i64 %3 to %struct.entry_hash*
ret %struct.entry_hash* %4
}
/* Variables and functions */
int ASM(char *);
int _getchr() {
  while (!(ASM(" IN   (IN_STATUS), RU") & 0x01))
    ;
  ASM("IN   (IN_RX_DATA), RU");
}


x86 assembly (clang, -O0):
<_getchr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <ASM@plt>
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    113c <_getchr+0x2c>
jmp    1141 <_getchr+0x31>
jmp    1118 <_getchr+0x8>
lea    0xece(%rip),%rdi
call   1030 <ASM@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_getchr>:
push   %rbx
lea    0xee8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <ASM@plt>
test   $0x1,%al
je     1120 <_getchr+0x10>
lea    0xee3(%rip),%rdi
pop    %rbx
jmp    1030 <ASM@plt>

LLVM IR (-O0):
@.str = [22 x i8] c" IN (IN_STATUS), RU\00"
@.str.1 = [22 x i8] c"IN (IN_RX_DATA), RU\00"
define i32 @_getchr() {
%1 = alloca i32
br label %2
2: ; preds = %7, %0
%3 = call i32 @ASM(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = and i32 %3, 1
%5 = icmp ne i32 %4, 0
%6 = xor i1 %5, true
br i1 %6, label %7, label %8
7: ; preds = %2
br label %2
8: ; preds = %2
%9 = call i32 @ASM(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* %1
ret i32 %10
}

LLVM IR (-O2):
@.str = [22 x i8] c" IN (IN_STATUS), RU\00"
@.str.1 = [22 x i8] c"IN (IN_RX_DATA), RU\00"
define i32 @_getchr() {
br label %1
1: ; preds = %1, %0
%2 = tail call i32 @ASM(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = and i32 %2, 1
%4 = icmp eq i32 %3, 0
br i1 %4, label %1, label %5
5: ; preds = %1
%6 = tail call i32 @ASM(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
ret i32 undef
}
void src_fn(void) {}


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

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

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

LLVM IR (-O2):
define void @src_fn() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ lua_error(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void lua_arg_error(char *funcname) {
  char buff[100];
  sprintf(buff, "incorrect arguments to function `%s'", funcname);
  lua_error(buff);
}


x86 assembly (clang, -O0):
<lua_arg_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xec5(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x70(%rbp),%rdi
call   1030 <lua_error@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lua_arg_error>:
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rdx
lea    0xed1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <lua_error@plt>
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"incorrect arguments to function `%s'\00"
define void @lua_arg_error(i8* %0) {
%2 = alloca i8*
%3 = alloca [100 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @lua_error(i8* %7)
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"incorrect arguments to function `%s'\00"
define void @lua_arg_error(i8* %0) {
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = call i32 @lua_error(i8* %3)
ret void
}
/* Type definitions */
struct instrument {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ inst_wrtstr(struct instrument *, char *);
void inst_488_2_cls(struct instrument *gd) { inst_wrtstr(gd, "*CLS\n"); }


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

x86 assembly (clang, -O2):
<inst_488_2_cls>:
lea    0xee9(%rip),%rsi
jmp    1030 <inst_wrtstr@plt>

LLVM IR (-O0):
%struct.instrument = type { i32 }
@.str = [6 x i8] c"*CLS\0A\00"
define void @inst_488_2_cls(%struct.instrument* %0) {
%2 = alloca %struct.instrument*
store %struct.instrument* %0, %struct.instrument** %2
%3 = load %struct.instrument*, %struct.instrument** %2
%4 = call i32 @inst_wrtstr(%struct.instrument* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.instrument = type { i32 }
@.str = [6 x i8] c"*CLS\0A\00"
define void @inst_488_2_cls(%struct.instrument* %0) {
%2 = tail call i32 @inst_wrtstr(%struct.instrument* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
float atan2(float, float);
float sqrtf(float);
void cartesianas_polares(float x, float y, float *r, float *theta) {
  *r = sqrtf(x * x + y * y);
  *theta = atan2(y, x);
}


x86 assembly (clang, -O0):
<cartesianas_polares>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrtf@plt>
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
call   1030 <atan2@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cartesianas_polares>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movaps %xmm1,%xmm3
movaps %xmm0,%xmm2
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     114a <cartesianas_polares+0x2a>
sqrtss %xmm0,%xmm0
jmp    1165 <cartesianas_polares+0x45>
movss  %xmm2,0x4(%rsp)
movss  %xmm3,(%rsp)
call   1040 <sqrtf@plt>
movss  (%rsp),%xmm3
movss  0x4(%rsp),%xmm2
movss  %xmm0,(%rbx)
movaps %xmm3,%xmm0
movaps %xmm2,%xmm1
call   1030 <atan2@plt>
movss  %xmm0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @cartesianas_polares(float %0, float %1, float* %2, float* %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float*
%8 = alloca float*
store float %0, float* %5
store float %1, float* %6
store float* %2, float** %7
store float* %3, float** %8
%9 = load float, float* %5
%10 = load float, float* %5
%11 = load float, float* %6
%12 = load float, float* %6
%13 = fmul float %11, %12
%14 = call float @llvm.fmuladd.f32(float %9, float %10, float %13)
%15 = call float @sqrtf(float %14)
%16 = load float*, float** %7
store float %15, float* %16
%17 = load float, float* %6
%18 = load float, float* %5
%19 = call float @atan2(float %17, float %18)
%20 = load float*, float** %8
store float %19, float* %20
ret void
}

LLVM IR (-O2):
define void @cartesianas_polares(float %0, float %1, float* nocapture writeonly %2, float* nocapture writeonly %3) {
%5 = fmul float %1, %1
%6 = tail call float @llvm.fmuladd.f32(float %0, float %0, float %5)
%7 = tail call float @sqrtf(float %6)
store float %7, float* %2
%8 = tail call float @atan2(float %1, float %0)
store float %8, float* %3
ret void
}
void timeDifference(double *deltaT1, double thetaS, double thetaL) {
  *deltaT1 = -(thetaS - thetaL) / 15.0;
  return;
}


x86 assembly (clang, -O0):
<timeDifference>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xec5(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeDifference>:
subsd  %xmm1,%xmm0
divsd  0xef4(%rip),%xmm0
movsd  %xmm0,(%rdi)
ret

LLVM IR (-O0):
define void @timeDifference(double* %0, double %1, double %2) {
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store double* %0, double** %4
store double %1, double* %5
store double %2, double* %6
%7 = load double, double* %5
%8 = load double, double* %6
%9 = fsub double %7, %8
%10 = fneg double %9
%11 = fdiv double %10, 1.500000e+01
%12 = load double*, double** %4
store double %11, double* %12
ret void
}

LLVM IR (-O2):
define void @timeDifference(double* nocapture writeonly %0, double %1, double %2) {
%4 = fsub double %1, %2
%5 = fdiv double %4, -1.500000e+01
store double %5, double* %0
ret void
}
void mpp_min_double(int count, double *data) {}


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

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

LLVM IR (-O0):
define void @mpp_min_double(i32 %0, double* %1) {
%3 = alloca i32
%4 = alloca double*
store i32 %0, i32* %3
store double* %1, double** %4
ret void
}

LLVM IR (-O2):
define void @mpp_min_double(i32 %0, double* nocapture %1) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isxdigit(int);
void t_isxdigit_0x0a() {
  Assert_real((isxdigit(10) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isxdigit.c",
              55, ("isxdigit should be 0 for 0x0a"));
}


x86 assembly (clang, -O0):
<t_isxdigit_0x0a>:
push   %rbp
mov    %rsp,%rbp
mov    $0xa,%edi
call   1030 <isxdigit@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xebf(%rip),%rsi
mov    $0x37,%edx
lea    0xf5c(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_isxdigit_0x0a>:
push   %rax
mov    $0xa,%edi
call   1030 <isxdigit@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf67(%rip),%rcx
mov    $0x37,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0x0a\00"
define void @t_isxdigit_0x0a() {
%1 = call i64 @isxdigit(i32 10)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [169 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0x0a\00"
define void @t_isxdigit_0x0a() {
%1 = tail call i64 @isxdigit(i32 10)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int foo(n, a)
int n;
int a[][n];
{
  int i;
  for (i = 0; i < n; ++i)
    printf("%d: %d\n", i, a[0][i]);
  return n;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1172 <foo+0x62>
mov    -0x20(%rbp),%rcx
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
imul   $0x0,%rcx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112d <foo+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
test   %edi,%edi
jle    1149 <foo+0x39>
mov    %rsi,%r12
mov    %r14d,%ebx
lea    0xed4(%rip),%r15
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r12,%rbp,4),%edx
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <foo+0x20>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%d: %d\0A\00"
define i32 @foo(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
%6 = load i32, i32* %3
%7 = zext i32 %6 to i64
store i32 0, i32* %5
br label %8
8: ; preds = %22, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32*, i32** %4
%15 = mul nsw i64 0, %7
%16 = getelementptr inbounds i32, i32* %14, i64 %15
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %20)
br label %22
22: ; preds = %12
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %8
25: ; preds = %8
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d: %d\0A\00"
define i32 @foo(i32 returned %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %14
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %12, %6 ]
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = load i32, i32* %8
%10 = trunc i64 %7 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %9)
%12 = add nuw nsw i64 %7, 1
%13 = icmp eq i64 %12, %5
br i1 %13, label %14, label %6
14: ; preds = %6, %2
ret i32 %0
}
/* Type definitions */
struct lzx {
  int dummy;
};

/* Variables and functions */
int lzx_accumulate(struct lzx *, unsigned int);
int lzx_consume(struct lzx *, unsigned int);
int lzx_getbits(struct lzx *lzx, unsigned int bits) {
  int norm_value;
  int rc;
  norm_value = lzx_accumulate(lzx, bits);
  if ((rc = lzx_consume(lzx, bits)) != 0)
    return rc;
  return (norm_value >> (16 - bits));
}


x86 assembly (clang, -O0):
<lzx_getbits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <lzx_accumulate@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <lzx_consume@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     1161 <lzx_getbits+0x41>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1171 <lzx_getbits+0x51>
mov    -0x18(%rbp),%eax
mov    $0x10,%ecx
sub    -0x14(%rbp),%ecx
sar    %cl,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lzx_getbits>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %rdi,%r14
call   1040 <lzx_accumulate@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <lzx_consume@plt>
mov    $0x10,%cl
sub    %bl,%cl
sar    %cl,%ebp
test   %eax,%eax
cmove  %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.lzx = type { i32 }
define i32 @lzx_getbits(%struct.lzx* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.lzx*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store %struct.lzx* %0, %struct.lzx** %4
store i32 %1, i32* %5
%8 = load %struct.lzx*, %struct.lzx** %4
%9 = load i32, i32* %5
%10 = call i32 @lzx_accumulate(%struct.lzx* %8, i32 %9)
store i32 %10, i32* %6
%11 = load %struct.lzx*, %struct.lzx** %4
%12 = load i32, i32* %5
%13 = call i32 @lzx_consume(%struct.lzx* %11, i32 %12)
store i32 %13, i32* %7
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i32, i32* %7
store i32 %16, i32* %3
br label %22
17: ; preds = %2
%18 = load i32, i32* %6
%19 = load i32, i32* %5
%20 = sub i32 16, %19
%21 = ashr i32 %18, %20
store i32 %21, i32* %3
br label %22
22: ; preds = %17, %15
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
%struct.lzx = type { i32 }
define i32 @lzx_getbits(%struct.lzx* %0, i32 %1) {
%3 = tail call i32 @lzx_accumulate(%struct.lzx* %0, i32 %1)
%4 = tail call i32 @lzx_consume(%struct.lzx* %0, i32 %1)
%5 = icmp eq i32 %4, 0
%6 = sub i32 16, %1
%7 = ashr i32 %3, %6
%8 = select i1 %5, i32 %7, i32 %4
ret i32 %8
}
int save_state_information(int autosave) {}


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

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

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

LLVM IR (-O2):
define i32 @save_state_information(i32 %0) {
ret i32 undef
}
/* Variables and functions */
char *my_str_cpy(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char a[8] = {};
  char *b = "abcde";
  printf("%s\n", my_str_cpy(a, b));
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <my_str_cpy@plt>
mov    %rax,%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movq   $0x0,(%rsp)
lea    0xec0(%rip),%rsi
mov    %rsp,%rdi
call   1050 <my_str_cpy@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"abcde\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [8 x i8]* %2 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i8* @my_str_cpy(i8* %5, i8* %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"abcde\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%3 = call i8* @my_str_cpy(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* dereferenceable(1) %3)
%5 = call i32 @putchar(i32 10)
ret i32 0
}
void mutate_int(int *x) { *x *= 2; }


x86 assembly (clang, -O0):
<mutate_int>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
shl    $0x1,%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<mutate_int>:
shll   (%rdi)
ret

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

LLVM IR (-O2):
define void @mutate_int(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = shl nsw i32 %2, 1
store i32 %3, i32* %0
ret void
}
/* Variables and functions */
void *calloc(size_t, size_t);
void *hoof_hook_calloc(size_t nmemb, size_t size) {
  return calloc(nmemb, size);
}


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

x86 assembly (clang, -O2):
<hoof_hook_calloc>:
jmp    1030 <calloc@plt>

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

LLVM IR (-O2):
define noalias i8* @hoof_hook_calloc(i64 %0, i64 %1) {
%3 = tail call i8* @calloc(i64 %0, i64 %1)
ret i8* %3
}
/* Variables and functions */
extern uintptr_t ptr_to_int(void *p) { return (uintptr_t)p; }


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

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

LLVM IR (-O0):
define i64 @ptr_to_int(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = ptrtoint i8* %3 to i64
ret i64 %4
}

LLVM IR (-O2):
define i64 @ptr_to_int(i8* %0) {
%2 = ptrtoint i8* %0 to i64
ret i64 %2
}
int meow() {
  int i, s;
  i = 0;
  s = 0;
  while (i < 10) {
    s = s + i;
    i = i + 1;
    if (i % 5 == 0)
      break;
  }
  s = s + 1 - 2 - 3;
  return s;
}


x86 assembly (clang, -O0):
<meow>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x4(%rbp)
jge    114c <meow+0x4c>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1147 <meow+0x47>
jmp    114c <meow+0x4c>
jmp    1112 <meow+0x12>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
sub    $0x2,%eax
sub    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @meow() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %16, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 10
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = load i32, i32* %2
%8 = load i32, i32* %1
%9 = add nsw i32 %7, %8
store i32 %9, i32* %2
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = srem i32 %12, 5
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %6
br label %17
16: ; preds = %6
br label %3
17: ; preds = %15, %3
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
%20 = sub nsw i32 %19, 2
%21 = sub nsw i32 %20, 3
store i32 %21, i32* %2
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
define i32 @meow() {
ret i32 6
}
int is_word_char(char value) {
  switch (value) {
  case ' ':
  case '\t':
  case '\n':
  case ':':
  case ',':
  case '(':
  case ')':
  case '{':
  case '}':
  case '[':
  case ']':
  case '"':
  case '*':
    return 0;
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<is_word_char>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xfffffff7,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x74,%eax
ja     1140 <is_word_char+0x40>
mov    -0x10(%rbp),%rax
lea    0xed5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    1147 <is_word_char+0x47>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_word_char>:
add    $0xfffffff7,%edi
cmp    $0x74,%edi
ja     111b <is_word_char+0x1b>
xor    %eax,%eax
lea    0xeef(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @is_word_char(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %7 [
i32 32, label %6
i32 9, label %6
i32 10, label %6
i32 58, label %6
i32 44, label %6
i32 40, label %6
i32 41, label %6
i32 123, label %6
i32 125, label %6
i32 91, label %6
i32 93, label %6
i32 34, label %6
i32 42, label %6
]
6: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1
store i32 0, i32* %2
br label %8
7: ; preds = %1
store i32 1, i32* %2
br label %8
8: ; preds = %7, %6
%9 = load i32, i32* %2
ret i32 %9
}

LLVM IR (-O2):
define i32 @is_word_char(i8 signext %0) {
%2 = sext i8 %0 to i32
switch i32 %2, label %3 [
i32 32, label %4
i32 9, label %4
i32 10, label %4
i32 58, label %4
i32 44, label %4
i32 40, label %4
i32 41, label %4
i32 123, label %4
i32 125, label %4
i32 91, label %4
i32 93, label %4
i32 34, label %4
i32 42, label %4
]
3: ; preds = %1
br label %4
4: ; preds = %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %1, %3
%5 = phi i32 [ 1, %3 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ], [ 0, %1 ]
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ os_shellexec(char *, char *, size_t);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int adb_ls(const char *path, char *result, size_t result_maxlen) {
  char buf[2048] = {0};
  int files = 0;
  sprintf(buf, "adb shell \"su -c 'ls %s'\"", path);
  os_shellexec(buf, result, result_maxlen);
  return 1;
}


x86 assembly (clang, -O0):
<adb_ls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1030 <memset@plt>
movl   $0x0,-0x824(%rbp)
lea    -0x820(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <os_shellexec@plt>
mov    $0x1,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<adb_ls>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%r12
mov    $0x800,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
lea    0xea0(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
call   1050 <sprintf@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <os_shellexec@plt>
mov    $0x1,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"adb shell \22su -c 'ls %s'\22\00"
define i32 @adb_ls(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca [2048 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%9 = bitcast [2048 x i8]* %7 to i8*
store i32 0, i32* %8
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = call i32 @os_shellexec(i8* %13, i8* %14, i64 %15)
ret i32 1
}

LLVM IR (-O2):
@.str = [26 x i8] c"adb shell \22su -c 'ls %s'\22\00"
define i32 @adb_ls(i8* %0, i8* %1, i64 %2) {
%4 = alloca [2048 x i8]
%5 = getelementptr inbounds [2048 x i8], [2048 x i8]* %4, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%7 = call i32 @os_shellexec(i8* %5, i8* %1, i64 %2)
ret i32 1
}