xunge/DecIR huggingface dataset:
int calcParallaxX(int camX, int x, char layer) {
  long dx = x - camX;
  return (camX) + ((dx - 48) / layer) + 48;
}


x86 assembly (clang, -O0):
<calcParallaxX>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
cltq
mov    %rax,-0x18(%rbp)
movslq -0x4(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
sub    $0x30,%rax
movsbq -0x9(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
add    $0x30,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcParallaxX>:
mov    %edx,%ecx
sub    %edi,%esi
movslq %esi,%rax
add    $0xffffffffffffffd0,%rax
movslq %edx,%rsi
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
je     1125 <calcParallaxX+0x25>
cqto
idiv   %rsi
add    %edi,%eax
add    $0x30,%eax
ret
xor    %edx,%edx
div    %ecx
add    %edi,%eax
add    $0x30,%eax
ret

LLVM IR (-O0):
define i32 @calcParallaxX(i32 %0, i32 %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %8, %9
%11 = sext i32 %10 to i64
store i64 %11, i64* %7
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = load i64, i64* %7
%15 = sub nsw i64 %14, 48
%16 = load i8, i8* %6
%17 = sext i8 %16 to i64
%18 = sdiv i64 %15, %17
%19 = add nsw i64 %13, %18
%20 = add nsw i64 %19, 48
%21 = trunc i64 %20 to i32
ret i32 %21
}

LLVM IR (-O2):
define i32 @calcParallaxX(i32 %0, i32 %1, i8 signext %2) {
%4 = sub nsw i32 %1, %0
%5 = sext i32 %4 to i64
%6 = add nsw i64 %5, -48
%7 = sext i8 %2 to i64
%8 = sdiv i64 %6, %7
%9 = trunc i64 %8 to i32
%10 = add i32 %0, 48
%11 = add i32 %10, %9
ret i32 %11
}
char *strchr(const char *s, int c) {
  register char ch;
  for (;;) {
    if ((ch = *s) == c)
      return s;
    if (ch == 0)
      return 0;
    s++;
  }
}


x86 assembly (clang, -O0):
<strchr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x15(%rbp)
movsbl %al,%eax
cmp    -0x14(%rbp),%eax
jne    112d <strchr+0x2d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1158 <strchr+0x58>
movsbl -0x15(%rbp),%eax
cmp    $0x0,%eax
jne    1147 <strchr+0x47>
movq   $0x0,-0x8(%rbp)
jmp    1158 <strchr+0x58>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    110b <strchr+0xb>
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchr>:
mov    %rdi,%rax
movsbl (%rdi),%ecx
cmp    %esi,%ecx
je     1120 <strchr+0x20>
nopw   0x0(%rax,%rax,1)
test   %cl,%cl
je     1121 <strchr+0x21>
movsbl 0x1(%rax),%ecx
add    $0x1,%rax
cmp    %esi,%ecx
jne    1110 <strchr+0x10>
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i8* @strchr(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
%5 = icmp eq i32 %4, %1
br i1 %5, label %15, label %6
6: ; preds = %2, %10
%7 = phi i8 [ %12, %10 ], [ %3, %2 ]
%8 = phi i8* [ %11, %10 ], [ %0, %2 ]
%9 = icmp eq i8 %7, 0
br i1 %9, label %15, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %6
15: ; preds = %10, %6, %2
%16 = phi i8* [ %0, %2 ], [ null, %6 ], [ %11, %10 ]
ret i8* %16
}
void case_path(name) char *name;
{ (char *)name; }


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

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

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

LLVM IR (-O2):
define void @case_path(i8* nocapture %0) {
ret void
}
/* Variables and functions */
int getNum();
int /*<<< orphan*/ printDigitsReverseOrder(int);
int /*<<< orphan*/ printf(char *);
int main() {
  int num1;
  printf("\n\n");
  num1 = getNum();
  printDigitsReverseOrder(num1);
  printf("\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getNum@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <printDigitsReverseOrder@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getNum@plt>
mov    %eax,%edi
call   1040 <printDigitsReverseOrder@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.1, i64 0, i64 0))
%2 = tail call i32 (...) @getNum()
%3 = tail call i32 @printDigitsReverseOrder(i32 %2)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.1, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
void *malloc(int);
int /*<<< orphan*/ oops(char *);
void *mymalloc(size_t len) {
  void *p;
  if (len)
    p = malloc(len);
  else
    p = malloc(1);
  if (p == NULL)
    oops("Out of memory.");
  return p;
}


x86 assembly (clang, -O0):
<mymalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     114b <mymalloc+0x2b>
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
jmp    1159 <mymalloc+0x39>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <mymalloc+0x50>
lea    0xe95(%rip),%rdi
call   1030 <oops@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mymalloc>:
push   %rbx
test   %rdi,%rdi
je     1128 <mymalloc+0x8>
jmp    112d <mymalloc+0xd>
mov    $0x1,%edi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1146 <mymalloc+0x26>
lea    0xebf(%rip),%rdi
call   1030 <oops@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Out of memory.\00"
define i8* @mymalloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i64, i64* %2
%8 = trunc i64 %7 to i32
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %3
br label %12
10: ; preds = %1
%11 = call i8* @malloc(i32 1)
store i8* %11, i8** %3
br label %12
12: ; preds = %10, %6
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [15 x i8] c"Out of memory.\00"
define i8* @mymalloc(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %6, label %3
3: ; preds = %1
%4 = trunc i64 %0 to i32
%5 = tail call i8* @malloc(i32 %4)
br label %8
6: ; preds = %1
%7 = tail call dereferenceable_or_null(1) i8* @malloc(i32 1)
br label %8
8: ; preds = %6, %3
%9 = phi i8* [ %5, %3 ], [ %7, %6 ]
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @oops(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
ret i8* %9
}
/* Variables and functions */
int htoi(char *, int);
int htoi_oct(char *s) { return htoi(s, 8); }


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

x86 assembly (clang, -O2):
<htoi_oct>:
mov    $0x8,%esi
jmp    1030 <htoi@plt>

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

LLVM IR (-O2):
define i32 @htoi_oct(i8* %0) {
%2 = tail call i32 @htoi(i8* %0, i32 8)
ret i32 %2
}
int fun1099() { return 1099; }


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

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

LLVM IR (-O0):
define i32 @fun1099() {
ret i32 1099
}

LLVM IR (-O2):
define i32 @fun1099() {
ret i32 1099
}
/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
int main(int argc, char **argv) {
  char *buf;
  int num = 1 << 31;
  buf = malloc(num);
  fgets(buf, 1024, stdin);
  printf("%s\n", buf);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x80000000,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e84(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
mov    -0x18(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x80000000,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1040 <fgets@plt>
lea    0xea5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -2147483648, i32* %7
%8 = load i32, i32* %7
%9 = call i8* @malloc(i32 %8)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 1024, i32 %11)
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
ret i32 1
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(2147483648) i8* @malloc(i32 -2147483648)
%4 = load i32, i32* @stdin
%5 = tail call i32 @fgets(i8* %3, i32 1024, i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ ispunct(int);
void t_ispunct_0x22() {
  Assert_real((ispunct(34)),
              "/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_ispunct.c",
              175, ("ispunct should be 1 for 0x22"));
}


x86 assembly (clang, -O0):
<t_ispunct_0x22>:
push   %rbp
mov    %rsp,%rbp
mov    $0x22,%edi
call   1030 <ispunct@plt>
mov    %eax,%edi
lea    0xec9(%rip),%rsi
mov    $0xaf,%edx
lea    0xf65(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_ispunct_0x22>:
push   %rax
mov    $0x22,%edi
call   1030 <ispunct@plt>
lea    0xece(%rip),%rsi
lea    0xf6f(%rip),%rcx
mov    %eax,%edi
mov    $0xaf,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [168 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_ispunct.c\00"
@.str.1 = [29 x i8] c"ispunct should be 1 for 0x22\00"
define void @t_ispunct_0x22() {
%1 = call i32 @ispunct(i32 34)
%2 = call i32 @Assert_real(i32 %1, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 175, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 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_ispunct.c\00"
@.str.1 = [29 x i8] c"ispunct should be 1 for 0x22\00"
define void @t_ispunct_0x22() {
%1 = tail call i32 @ispunct(i32 34)
%2 = tail call i32 @Assert_real(i32 %1, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 175, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
double cdfgum_(double *, double *);
double ccdfgum(double *x, double *para) { return cdfgum_(x, para); }


x86 assembly (clang, -O0):
<ccdfgum>:
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 <cdfgum_@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ccdfgum>:
jmp    1030 <cdfgum_@plt>

LLVM IR (-O0):
define double @ccdfgum(double* %0, double* %1) {
%3 = alloca double*
%4 = alloca double*
store double* %0, double** %3
store double* %1, double** %4
%5 = load double*, double** %3
%6 = load double*, double** %4
%7 = call double @cdfgum_(double* %5, double* %6)
ret double %7
}

LLVM IR (-O2):
define double @ccdfgum(double* %0, double* %1) {
%3 = tail call double @cdfgum_(double* %0, double* %1)
ret double %3
}
/* Variables and functions */
int /*<<< orphan*/ division(int, int);
int /*<<< orphan*/ hello_world();
int /*<<< orphan*/ somme(int, int);
int main(int argc, char *argv[]) {
  int a = 1, b = 2;
  hello_world();
  somme(a, b);
  division(a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
mov    $0x0,%al
call   1030 <hello_world@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <somme@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <division@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <hello_world@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1050 <somme@plt>
mov    $0x1,%edi
mov    $0x2,%esi
call   1040 <division@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
store i32 2, i32* %7
%8 = call i32 (...) @hello_world()
%9 = load i32, i32* %6
%10 = load i32, i32* %7
%11 = call i32 @somme(i32 %9, i32 %10)
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 @division(i32 %12, i32 %13)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @hello_world()
%4 = tail call i32 @somme(i32 1, i32 2)
%5 = tail call i32 @division(i32 1, i32 2)
ret i32 0
}
void memclear(void *dest, unsigned char value, unsigned long size) {
  unsigned long i;
  unsigned char *d;
  d = (unsigned char *)dest;
  for (i = 0; i < size; i++) {
    d[i] = value;
  }
}


x86 assembly (clang, -O0):
<memclear>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    114f <memclear+0x4f>
mov    -0x9(%rbp),%dl
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1122 <memclear+0x22>
pop    %rbp
ret

x86 assembly (clang, -O2):
<memclear>:
test   %rdx,%rdx
je     1123 <memclear+0x13>
push   %rax
movzbl %sil,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
ret

LLVM IR (-O0):
define void @memclear(i8* %0, i8 zeroext %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %4
store i8 %1, i8* %5
store i64 %2, i64* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %8
store i64 0, i64* %7
br label %10
10: ; preds = %19, %3
%11 = load i64, i64* %7
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = load i8, i8* %5
%16 = load i8*, i8** %8
%17 = load i64, i64* %7
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8 %15, i8* %18
br label %19
19: ; preds = %14
%20 = load i64, i64* %7
%21 = add i64 %20, 1
store i64 %21, i64* %7
br label %10
22: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @memclear(i8* nocapture writeonly %0, i8 zeroext %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %6, label %5
5: ; preds = %3
br label %6
6: ; preds = %5, %3
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ bit_set(int *, int, int);
void bit_set_u32(uint32_t *bitmap, int bits, uint32_t val) {
  int i;
  for (i = 0; i < bits; i++)
    bit_set(bitmap, i, (val >> i) & 1);
}


x86 assembly (clang, -O0):
<bit_set_u32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    115a <bit_set_u32+0x4a>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
sar    %cl,%edx
and    $0x1,%edx
call   1030 <bit_set@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <bit_set_u32+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_set_u32>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    114b <bit_set_u32+0x3b>
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,%edx
mov    %ebx,%ecx
shr    %cl,%edx
and    $0x1,%edx
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <bit_set@plt>
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1130 <bit_set_u32+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @bit_set_u32(i32* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %5
%6 = phi i32 [ %10, %5 ], [ 0, %3 ]
%7 = lshr i32 %2, %6
%8 = and i32 %7, 1
%9 = tail call i32 @bit_set(i32* %0, i32 %6, i32 %8)
%10 = add nuw nsw i32 %6, 1
%11 = icmp eq i32 %10, %1
br i1 %11, label %12, label %5
12: ; preds = %5, %3
ret void
}
float parallhlogrammo(float factor1, float factor2) {
  return 2 * (factor1 + factor2);
}


x86 assembly (clang, -O0):
<parallhlogrammo>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm1
addss  -0x8(%rbp),%xmm1
movss  0xee0(%rip),%xmm0
mulss  %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<parallhlogrammo>:
addss  %xmm1,%xmm0
addss  %xmm0,%xmm0
ret

LLVM IR (-O0):
define float @parallhlogrammo(float %0, float %1) {
%3 = alloca float
%4 = alloca float
store float %0, float* %3
store float %1, float* %4
%5 = load float, float* %3
%6 = load float, float* %4
%7 = fadd float %5, %6
%8 = fmul float 2.000000e+00, %7
ret float %8
}

LLVM IR (-O2):
define float @parallhlogrammo(float %0, float %1) {
%3 = fadd float %0, %1
%4 = fmul float %3, 2.000000e+00
ret float %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  printf("These are  multiple  lines\n");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [28 x i8] c"These are multiple lines\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [27 x i8] c"These are multiple lines\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
ret i32 0
}
void _dirhelper_fork_child(void) {}


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

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

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

LLVM IR (-O2):
define void @_dirhelper_fork_child() {
ret void
}
int func(int (*funcptr)(int), int x) { return (*funcptr)(x); }


x86 assembly (clang, -O0):
<func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%edi
call   *%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func>:
mov    %rdi,%rax
mov    %esi,%edi
jmp    *%rax

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

LLVM IR (-O2):
define i32 @func(i32 (i32)* nocapture %0, i32 %1) {
%3 = tail call i32 %0(i32 %1)
ret i32 %3
}
/* Variables and functions */
unsigned int div_const(int);
void iter_div_const_constant() {
  unsigned int n = div_const(20);
  for (int i = 0; i < n; i++) {
  }
}


x86 assembly (clang, -O0):
<iter_div_const_constant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
call   1030 <div_const@plt>
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    114b <iter_div_const_constant+0x3b>
jmp    113d <iter_div_const_constant+0x2d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112c <iter_div_const_constant+0x1c>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iter_div_const_constant>:
mov    $0x14,%edi
jmp    1030 <div_const@plt>

LLVM IR (-O0):
define void @iter_div_const_constant() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @div_const(i32 20)
store i32 %3, i32* %1
store i32 0, i32* %2
br label %4
4: ; preds = %9, %0
%5 = load i32, i32* %2
%6 = load i32, i32* %1
%7 = icmp ult i32 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %4
br label %9
9: ; preds = %8
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
store i32 %11, i32* %2
br label %4
12: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @iter_div_const_constant() {
%1 = tail call i32 @div_const(i32 20)
ret void
}
void delay_reduce(long int delay) {
  while (delay) {
    delay--;
    asm volatile("nop");
  }
}


x86 assembly (clang, -O0):
<delay_reduce>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1125 <delay_reduce+0x25>
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
nop
jmp    1108 <delay_reduce+0x8>
pop    %rbp
ret

x86 assembly (clang, -O2):
<delay_reduce>:
test   %rdi,%rdi
je     1117 <delay_reduce+0x17>
cs nopw 0x0(%rax,%rax,1)
nop
nop
add    $0xffffffffffffffff,%rdi
jne    1110 <delay_reduce+0x10>
ret

LLVM IR (-O0):
define void @delay_reduce(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
br label %3
3: ; preds = %6, %1
%4 = load i64, i64* %2
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = load i64, i64* %2
%8 = add nsw i64 %7, -1
store i64 %8, i64* %2
br label %3
9: ; preds = %3
ret void
}

LLVM IR (-O2):
define void @delay_reduce(i64 %0) {
%2 = icmp eq i64 %0, 0
br i1 %2, label %7, label %3
3: ; preds = %1, %3
%4 = phi i64 [ %5, %3 ], [ %0, %1 ]
%5 = add nsw i64 %4, -1
tail call void asm sideeffect "nop", "~{dirflag},~{fpsr},~{flags}"()
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %3
7: ; preds = %3, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ calculaComponentesConexos();
int /*<<< orphan*/ zeraVariaveis();
int main() {
  zeraVariaveis();
  calculaComponentesConexos();
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @zeraVariaveis()
%2 = tail call i32 (...) @calculaComponentesConexos()
ret i32 0
}
int main(void) {
  char a[5] = {1, 2, 3, 4, 5};
  return *(int *)(&a[4]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    0xeef(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xeea(%rip),%al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.a = [5 x i8] c"\01\02\03\04\05"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
store i32 0, i32* %1
%3 = bitcast [5 x i8]* %2 to i8*
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 4
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
ret i32 %6
}

LLVM IR (-O2):
define i32 @main() {
ret i32 5
}
/* Variables and functions */
int read(int, char *, int);
int main() {
  int i = read(1, "abc", 4);
  return i == 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%edi
lea    0xed5(%rip),%rsi
mov    $0x4,%edx
call   1030 <read@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rsi
mov    $0x1,%edi
mov    $0x4,%edx
call   1030 <read@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @read(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
ret i32 %6
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
define i32 @main() {
%1 = tail call i32 @read(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 4)
%2 = icmp eq i32 %1, 0
%3 = zext i1 %2 to i32
ret i32 %3
}
int test_imm_3Auint8_reg(unsigned char val) {
  return ((val) & (0x3A << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_3Auint8_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edx
and    $0x3a,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_3Auint8_reg>:
test   $0x3a,%dil
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_3Auint8_reg(i8 zeroext %0) {
%2 = and i8 %0, 58
%3 = icmp eq i8 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
int check_prime(int num) {
  int i;
  for (i = 2; i <= num - 1; ++i) {
    if (num % i == 0) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_prime>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     114e <check_prime+0x4e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    113b <check_prime+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1155 <check_prime+0x55>
jmp    1140 <check_prime+0x40>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110e <check_prime+0xe>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_prime>:
mov    $0x1,%ecx
cmp    $0x3,%edi
jl     1120 <check_prime+0x20>
mov    $0x2,%esi
nop
mov    %edi,%eax
cltd
idiv   %esi
test   %edx,%edx
je     1123 <check_prime+0x23>
add    $0x1,%esi
cmp    %esi,%edi
jne    1110 <check_prime+0x10>
mov    %ecx,%eax
ret
xor    %ecx,%ecx
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @check_prime(i32 %0) {
%2 = icmp sgt i32 %0, 2
br i1 %2, label %5, label %10
3: ; preds = %5
%4 = icmp eq i32 %9, %0
br i1 %4, label %10, label %5
5: ; preds = %1, %3
%6 = phi i32 [ %9, %3 ], [ 2, %1 ]
%7 = srem i32 %0, %6
%8 = icmp eq i32 %7, 0
%9 = add nuw nsw i32 %6, 1
br i1 %8, label %10, label %3
10: ; preds = %5, %3, %1
%11 = phi i32 [ 1, %1 ], [ 1, %3 ], [ 0, %5 ]
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
void *realloc(void *, size_t);
int /*<<< orphan*/ stderr;
void *xrealloc(void *p, size_t n) {
  p = realloc(p, n);
  if (p == NULL) {
    (void)fprintf(stderr, "ERROR slurping file: out of memory\n");
    exit(10);
  }
  return p;
}


x86 assembly (clang, -O0):
<xrealloc>:
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   1040 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    117b <xrealloc+0x4b>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrealloc>:
push   %rax
call   1040 <realloc@plt>
test   %rax,%rax
je     113d <xrealloc+0xd>
pop    %rcx
ret
mov    0x2e9c(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xa,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"ERROR slurping file: out of memory\0A\00"
define i8* @xrealloc(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%5 = load i8*, i8** %3
%6 = load i64, i64* %4
%7 = call i8* @realloc(i8* %5, i64 %6)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 10)
unreachable
14: ; preds = %2
%15 = load i8*, i8** %3
ret i8* %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"ERROR slurping file: out of memory\0A\00"
define noalias i8* @xrealloc(i8* nocapture %0, i64 %1) {
%3 = tail call i8* @realloc(i8* %0, i64 %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 10)
unreachable
9: ; preds = %2
ret i8* %3
}
int StringLen(char s[]) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @StringLen(i8* nocapture readnone %0) {
ret i32 0
}
int modular_pow(int base, int exponent, int modulus) {
  int result = 1;
  base = base % modulus;
  while (exponent > 0) {
    if (exponent & 1) {
      result = (result * base) % modulus;
    }
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}


x86 assembly (clang, -O0):
<modular_pow>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x4(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1161 <modular_pow+0x61>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1145 <modular_pow+0x45>
mov    -0x10(%rbp),%eax
imul   -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
imul   -0x4(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x4(%rbp)
jmp    111e <modular_pow+0x1e>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<modular_pow>:
test   %esi,%esi
jle    113c <modular_pow+0x3c>
mov    %edx,%r8d
mov    $0x1,%ecx
jmp    111e <modular_pow+0x1e>
xchg   %ax,%ax
mov    %esi,%eax
shr    %eax
imul   %edi,%edi
cmp    $0x1,%esi
mov    %eax,%esi
jbe    1139 <modular_pow+0x39>
mov    %edi,%eax
cltd
idiv   %r8d
mov    %edx,%edi
test   $0x1,%sil
je     1110 <modular_pow+0x10>
imul   %edi,%ecx
mov    %ecx,%eax
cltd
idiv   %r8d
mov    %edx,%ecx
jmp    1110 <modular_pow+0x10>
mov    %ecx,%eax
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @modular_pow(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %7
%8 = load i32, i32* %4
%9 = load i32, i32* %6
%10 = srem i32 %8, %9
store i32 %10, i32* %4
br label %11
11: ; preds = %24, %3
%12 = load i32, i32* %5
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32, i32* %5
%16 = and i32 %15, 1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = mul nsw i32 %19, %20
%22 = load i32, i32* %6
%23 = srem i32 %21, %22
store i32 %23, i32* %7
br label %24
24: ; preds = %18, %14
%25 = load i32, i32* %5
%26 = ashr i32 %25, 1
store i32 %26, i32* %5
%27 = load i32, i32* %4
%28 = load i32, i32* %4
%29 = mul nsw i32 %27, %28
%30 = load i32, i32* %6
%31 = srem i32 %29, %30
store i32 %31, i32* %4
br label %11
32: ; preds = %11
%33 = load i32, i32* %7
ret i32 %33
}

LLVM IR (-O2):
define i32 @modular_pow(i32 %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %20
5: ; preds = %3, %15
%6 = phi i32 [ %18, %15 ], [ %0, %3 ]
%7 = phi i32 [ %16, %15 ], [ 1, %3 ]
%8 = phi i32 [ %17, %15 ], [ %1, %3 ]
%9 = srem i32 %6, %2
%10 = and i32 %8, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %5
%13 = mul nsw i32 %9, %7
%14 = srem i32 %13, %2
br label %15
15: ; preds = %12, %5
%16 = phi i32 [ %14, %12 ], [ %7, %5 ]
%17 = lshr i32 %8, 1
%18 = mul nsw i32 %9, %9
%19 = icmp ult i32 %8, 2
br i1 %19, label %20, label %5
20: ; preds = %15, %3
%21 = phi i32 [ 1, %3 ], [ %16, %15 ]
ret i32 %21
}
void kasan_cache_destroy(struct kmem_cache *cache) {}


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

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

LLVM IR (-O0):
%struct.kmem_cache = type opaque
define void @kasan_cache_destroy(%struct.kmem_cache* %0) {
%2 = alloca %struct.kmem_cache*
store %struct.kmem_cache* %0, %struct.kmem_cache** %2
ret void
}

LLVM IR (-O2):
%struct.kmem_cache = type opaque
define void @kasan_cache_destroy(%struct.kmem_cache* nocapture %0) {
ret void
}
/* Variables and functions */
size_t strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void strncpy_contents_Bad() {
  char src[5] = "test";
  char dst[10];
  strncpy(dst, src, 5);
  int a[4];
  a[strlen(dst)] = 0;
}


x86 assembly (clang, -O0):
<strncpy_contents_Bad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed2(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0xf(%rbp),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
lea    -0xf(%rbp),%rdi
call   1040 <strlen@plt>
movl   $0x0,-0x20(%rbp,%rax,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strncpy_contents_Bad>:
sub    $0x18,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x74736574,0x8(%rsp)
74
lea    0xe(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x5,%edx
call   1030 <strncpy@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.strncpy_contents_Bad.src = [5 x i8] c"test\00"
define void @strncpy_contents_Bad() {
%1 = alloca [5 x i8]
%2 = alloca [10 x i8]
%3 = alloca [4 x i32]
%4 = bitcast [5 x i8]* %1 to i8*
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%7 = call i32 @strncpy(i8* %5, i8* %6, i32 5)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%9 = call i64 @strlen(i8* %8)
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %9
store i32 0, i32* %10
ret void
}

LLVM IR (-O2):
@__const.strncpy_contents_Bad.src = [5 x i8] c"test\00"
define void @strncpy_contents_Bad() {
%1 = alloca [5 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = call i32 @strncpy(i8* %4, i8* %3, i32 5)
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ ASSERT(int);
bool ComparatorValueGet(uint32_t ui32Base, uint32_t ui32Comp) {
  ASSERT(ui32Base == 0x4003C000);
  ASSERT(ui32Comp < 3);
  if ((*((volatile uint32_t *)(ui32Base + (ui32Comp * 0x20) + 0x00000020))) &
      0x00000002) {
    return (true);
  } else {
    return (false);
  }
}


x86 assembly (clang, -O0):
<ComparatorValueGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x4003c000,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x3,-0xc(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x5,%ecx
add    %ecx,%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     116d <ComparatorValueGet+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    1174 <ComparatorValueGet+0x64>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ComparatorValueGet>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r14d
xor    %edi,%edi
cmp    $0x4003c000,%r14d
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x3,%ebx
setl   %dil
call   1030 <ASSERT@plt>
shl    $0x5,%ebx
lea    (%r14,%rbx,1),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
shr    %eax
and    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @ComparatorValueGet(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* %4
%7 = icmp eq i32 %6, 1073987584
%8 = zext i1 %7 to i32
%9 = call i32 @ASSERT(i32 %8)
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 3
%12 = zext i1 %11 to i32
%13 = call i32 @ASSERT(i32 %12)
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = mul nsw i32 %15, 32
%17 = add nsw i32 %14, %16
%18 = add nsw i32 %17, 32
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = load volatile i32, i32* %20
%22 = and i32 %21, 2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %2
store i32 1, i32* %3
br label %26
25: ; preds = %2
store i32 0, i32* %3
br label %26
26: ; preds = %25, %24
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
define i32 @ComparatorValueGet(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 1073987584
%4 = zext i1 %3 to i32
%5 = tail call i32 @ASSERT(i32 %4)
%6 = icmp slt i32 %1, 3
%7 = zext i1 %6 to i32
%8 = tail call i32 @ASSERT(i32 %7)
%9 = shl nsw i32 %1, 5
%10 = add i32 %0, 32
%11 = add i32 %10, %9
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = load volatile i32, i32* %13
%15 = lshr i32 %14, 1
%16 = and i32 %15, 1
ret i32 %16
}
int count_colons(char *p) {
  int n = 0;
  while (*p) {
    if (*p == ':')
      n++;
    p++;
  }
  return n;
}


x86 assembly (clang, -O0):
<count_colons>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1146 <count_colons+0x46>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    1135 <count_colons+0x35>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <count_colons+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_colons>:
xor    %eax,%eax
jmp    1117 <count_colons+0x17>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%eax
add    $0x1,%rdi
movzbl (%rdi),%ecx
cmp    $0x3a,%cl
je     1110 <count_colons+0x10>
test   %cl,%cl
jne    1113 <count_colons+0x13>
ret

LLVM IR (-O0):
define i32 @count_colons(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %16, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 58
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
br label %16
16: ; preds = %13, %8
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
br label %4
19: ; preds = %4
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
define i32 @count_colons(i8* nocapture %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ %0, %1 ], [ %10, %8 ]
%4 = phi i32 [ 0, %1 ], [ %9, %8 ]
%5 = load i8, i8* %3
switch i8 %5, label %8 [
i8 0, label %11
i8 58, label %6
]
6: ; preds = %2
%7 = add nsw i32 %4, 1
br label %8
8: ; preds = %2, %6
%9 = phi i32 [ %7, %6 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %2
ret i32 %4
}
/* Type definitions */
typedef int uint32_t;
typedef int /*<<< orphan*/ arr;

/* Variables and functions */
int /*<<< orphan*/ Qsort(int *, int, int);
int /*<<< orphan*/ printArray(int *, int);
int main() {
  int arr[9] = {21, 2, 5, 11, 9, 7, 30, 1, 4};
  printArray(arr, 9);
  uint32_t pivot, pivotIndex, start, end;
  start = 0;
  end = sizeof(arr) / sizeof(int) - 1;
  Qsort(arr, start, end);
  printArray(arr, 9);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x24,%edx
call   1030 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0x9,%esi
call   1040 <printArray@plt>
movl   $0x0,-0x3c(%rbp)
movl   $0x8,-0x40(%rbp)
lea    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x40(%rbp),%edx
call   1050 <Qsort@plt>
lea    -0x30(%rbp),%rdi
mov    $0x9,%esi
call   1040 <printArray@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    0xef5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeda(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xebe(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printArray@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <Qsort@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <printArray@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.arr = [9 x i32] [i32 21, i32 2, i32 5, i32 11, i32 9, i32 7, i32 30, i32 1, i32 4]
define i32 @main() {
%1 = alloca i32
%2 = alloca [9 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [9 x i32]* %2 to i8*
%8 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%9 = call i32 @printArray(i32* %8, i32 9)
store i32 0, i32* %5
store i32 8, i32* %6
%10 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @Qsort(i32* %10, i32 %11, i32 %12)
%14 = getelementptr inbounds [9 x i32], [9 x i32]* %2, i64 0, i64 0
%15 = call i32 @printArray(i32* %14, i32 9)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [9 x i32] [i32 21, i32 2, i32 5, i32 11, i32 9, i32 7, i32 30, i32 1, i32 4]
define i32 @main() {
%1 = alloca [9 x i32]
%2 = bitcast [9 x i32]* %1 to i8*
%3 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%4 = call i32 @printArray(i32* %3, i32 9)
%5 = call i32 @Qsort(i32* %3, i32 0, i32 8)
%6 = call i32 @printArray(i32* %3, i32 9)
ret i32 0
}
/* Variables and functions */
int *getNull();
void testNoArguments() {
  int *casted = getNull();
  *casted = 1;
}


x86 assembly (clang, -O0):
<testNoArguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <getNull@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testNoArguments>:
push   %rax
xor    %eax,%eax
call   1030 <getNull@plt>
movl   $0x1,(%rax)
pop    %rax
ret

LLVM IR (-O0):
define void @testNoArguments() {
%1 = alloca i32*
%2 = call i32* (...) @getNull()
store i32* %2, i32** %1
%3 = load i32*, i32** %1
store i32 1, i32* %3
ret void
}

LLVM IR (-O2):
define void @testNoArguments() {
%1 = tail call i32* (...) @getNull()
store i32 1, i32* %1
ret void
}