xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void print_integer(int *x) { printf("%d", *x); }


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

x86 assembly (clang, -O2):
<print_integer>:
mov    (%rdi),%esi
lea    0xee7(%rip),%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @print_integer(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
ret void
}
unsigned int perfctr_cstatus_nrctrs(unsigned int cstatus) {
  return (cstatus >> 8) & 0x7F;
}


x86 assembly (clang, -O0):
<perfctr_cstatus_nrctrs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x8,%eax
and    $0x7f,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<perfctr_cstatus_nrctrs>:
mov    %edi,%eax
shr    $0x8,%eax
and    $0x7f,%eax
ret

LLVM IR (-O0):
define i32 @perfctr_cstatus_nrctrs(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = lshr i32 %3, 8
%5 = and i32 %4, 127
ret i32 %5
}

LLVM IR (-O2):
define i32 @perfctr_cstatus_nrctrs(i32 %0) {
%2 = lshr i32 %0, 8
%3 = and i32 %2, 127
ret i32 %3
}
/* Type definitions */
typedef int /*<<< orphan*/ u_int32_t;

/* Variables and functions */
int FUTEX_CMP_REQUEUE;
int /*<<< orphan*/ SYS_futex;
int syscall(int /*<<< orphan*/, int /*<<< orphan*/ *, int, int, int,
            int /*<<< orphan*/ *, int /*<<< orphan*/);
int futex_cmp_requeue(u_int32_t *uaddr, u_int32_t val, u_int32_t *uaddr2,
                      int nr_wake, int nr_requeue, int opflags) {
  return syscall(SYS_futex, uaddr, FUTEX_CMP_REQUEUE | opflags, nr_wake,
                 nr_requeue, uaddr2, val);
}


x86 assembly (clang, -O0):
<futex_cmp_requeue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
or     -0x24(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    -0x18(%rbp),%r9
mov    -0xc(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <syscall@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<futex_cmp_requeue>:
push   %rax
mov    %rdx,%r10
mov    %rdi,%rdx
mov    0x2eba(%rip),%rdi
mov    (%rdi),%edi
mov    0x2eb9(%rip),%rax
or     (%rax),%r9d
mov    %esi,(%rsp)
mov    %rdx,%rsi
mov    %r9d,%edx
mov    %r10,%r9
call   1030 <syscall@plt>
pop    %rcx
ret

LLVM IR (-O0):
@SYS_futex = global i32 0
@FUTEX_CMP_REQUEUE = global i32 0
define i32 @futex_cmp_requeue(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = load i32, i32* @SYS_futex
%14 = load i32*, i32** %7
%15 = load i32, i32* @FUTEX_CMP_REQUEUE
%16 = load i32, i32* %12
%17 = or i32 %15, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = load i32*, i32** %9
%21 = load i32, i32* %8
%22 = call i32 @syscall(i32 %13, i32* %14, i32 %17, i32 %18, i32 %19, i32* %20, i32 %21)
ret i32 %22
}

LLVM IR (-O2):
@SYS_futex = global i32 0
@FUTEX_CMP_REQUEUE = global i32 0
define i32 @futex_cmp_requeue(i32* %0, i32 %1, i32* %2, i32 %3, i32 %4, i32 %5) {
%7 = load i32, i32* @SYS_futex
%8 = load i32, i32* @FUTEX_CMP_REQUEUE
%9 = or i32 %8, %5
%10 = tail call i32 @syscall(i32 %7, i32* %0, i32 %9, i32 %3, i32 %4, i32* %2, i32 %1)
ret i32 %10
}
/* Type definitions */
typedef char *uint64_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
__attribute__((always_)) uint64_t sel4bench_private_rdpmc(uint32_t counter) {
  uint64_t counter_val;
  asm volatile("rdpmc" : "=A"(counter_val) : "c"(counter));
  return counter_val;
}


x86 assembly (clang, -O0):
<sel4bench_private_rdpmc>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
rdpmc
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sel4bench_private_rdpmc>:
mov    %edi,%ecx
rdpmc
ret

LLVM IR (-O0):
define i8* @sel4bench_private_rdpmc(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i8* asm sideeffect "rdpmc", "=A,{cx},~{dirflag},~{fpsr},~{flags}"(i32 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
ret i8* %6
}

LLVM IR (-O2):
define i8* @sel4bench_private_rdpmc(i32 %0) {
%2 = tail call i8* asm sideeffect "rdpmc", "=A,{cx},~{dirflag},~{fpsr},~{flags}"(i32 %0)
ret i8* %2
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
void doit() { exit(77); }


x86 assembly (clang, -O0):
<doit>:
push   %rbp
mov    %rsp,%rbp
mov    $0x4d,%edi
call   1030 <exit@plt>

x86 assembly (clang, -O2):
<doit>:
push   %rax
mov    $0x4d,%edi
call   1030 <exit@plt>

LLVM IR (-O0):
define void @doit() {
%1 = call i32 @exit(i32 77)
unreachable
}

LLVM IR (-O2):
define void @doit() {
%1 = tail call i32 @exit(i32 77)
unreachable
}
/* Variables and functions */
unsigned char const *Z_NULL;
unsigned long crc32(unsigned long, unsigned char const *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
unsigned long checksum(char *data) {
  unsigned long crc = crc32(0L, Z_NULL, 0);
  crc = crc32(crc, (const unsigned char *)data, strlen(data));
  return crc;
}


x86 assembly (clang, -O0):
<checksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edi
xor    %edx,%edx
call   1030 <crc32@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <crc32@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checksum>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2eb2(%rip),%rax
mov    (%rax),%rsi
xor    %edi,%edi
xor    %edx,%edx
call   1030 <crc32@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <crc32@plt>

LLVM IR (-O0):
@Z_NULL = global i8* null
define i64 @checksum(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
store i8* %0, i8** %2
%4 = load i8*, i8** @Z_NULL
%5 = call i64 @crc32(i64 0, i8* %4, i32 0)
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = call i64 @crc32(i64 %6, i8* %7, i32 %9)
store i64 %10, i64* %3
%11 = load i64, i64* %3
ret i64 %11
}

LLVM IR (-O2):
@Z_NULL = global i8* null
define i64 @checksum(i8* %0) {
%2 = load i8*, i8** @Z_NULL
%3 = tail call i64 @crc32(i64 0, i8* %2, i32 0)
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i64 @crc32(i64 %3, i8* %0, i32 %4)
ret i64 %5
}
void RTAvlroGCPtrGetLeft(void) {}


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

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

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

LLVM IR (-O2):
define void @RTAvlroGCPtrGetLeft() {
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
uint8_t implicitUnsignedTruncation(uint32_t argc) {
  fprintf(stderr, "TEST\n");
  return argc;
}


x86 assembly (clang, -O0):
<implicitUnsignedTruncation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ebe(%rip),%rax
mov    (%rax),%edi
lea    0xed5(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<implicitUnsignedTruncation>:
push   %rbx
mov    %edi,%ebx
mov    0x2ec6(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
call   1030 <fprintf@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [6 x i8] c"TEST\0A\00"
define i32 @implicitUnsignedTruncation(i32 returned %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
ret i32 %0
}
int SDL_imageFilterNormalizeLinearMMX(unsigned char *Src1, unsigned char *Dest,
                                      unsigned int SrcLength, int Cmin,
                                      int Cmax, int Nmin, int Nmax) {
  return (-1);
}


x86 assembly (clang, -O0):
<SDL_imageFilterNormalizeLinearMMX>:
push   %rbp
mov    %rsp,%rbp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    $0xffffffff,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @SDL_imageFilterNormalizeLinearMMX(i8* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
ret i32 -1
}

LLVM IR (-O2):
define i32 @SDL_imageFilterNormalizeLinearMMX(i8* nocapture readnone %0, i8* nocapture readnone %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
ret i32 -1
}
/* Variables and functions */
int link(char const *, char const *);
int txc_libc_link(const char *oldpath, const char *newpath) {
  return link(oldpath, newpath);
}


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

x86 assembly (clang, -O2):
<txc_libc_link>:
jmp    1030 <link@plt>

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

LLVM IR (-O2):
define i32 @txc_libc_link(i8* %0, i8* %1) {
%3 = tail call i32 @link(i8* %0, i8* %1)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ free(char *);
void cgiStringArrayFree(char **stringArray) {
  char *p;
  p = *stringArray;
  while (p) {
    free(p);
    stringArray++;
    p = *stringArray;
  }
}


x86 assembly (clang, -O0):
<cgiStringArrayFree>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1157 <cgiStringArrayFree+0x47>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    1127 <cgiStringArrayFree+0x17>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cgiStringArrayFree>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1131 <cgiStringArrayFree+0x21>
add    $0x8,%rbx
call   1030 <free@plt>
mov    (%rbx),%rdi
add    $0x8,%rbx
test   %rdi,%rdi
jne    1120 <cgiStringArrayFree+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @cgiStringArrayFree(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
store i8** %0, i8*** %2
%4 = load i8**, i8*** %2
%5 = load i8*, i8** %4
store i8* %5, i8** %3
br label %6
6: ; preds = %9, %1
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i8*, i8** %3
%11 = call i32 @free(i8* %10)
%12 = load i8**, i8*** %2
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %2
%14 = load i8**, i8*** %2
%15 = load i8*, i8** %14
store i8* %15, i8** %3
br label %6
16: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @cgiStringArrayFree(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = icmp eq i8* %2, null
br i1 %3, label %11, label %4
4: ; preds = %1, %4
%5 = phi i8* [ %9, %4 ], [ %2, %1 ]
%6 = phi i8** [ %8, %4 ], [ %0, %1 ]
%7 = tail call i32 @free(i8* %5)
%8 = getelementptr inbounds i8*, i8** %6, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %4
11: ; preds = %4, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ funlockfile(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void unlock_stderr(void) { funlockfile(stderr); }


x86 assembly (clang, -O0):
<unlock_stderr>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
call   1030 <funlockfile@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlock_stderr>:
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
jmp    1030 <funlockfile@plt>

LLVM IR (-O0):
@stderr = global i32 0
define void @unlock_stderr() {
%1 = load i32, i32* @stderr
%2 = call i32 @funlockfile(i32 %1)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
define void @unlock_stderr() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @funlockfile(i32 %1)
ret void
}
/* Variables and functions */
unsigned long pci_read_config32(int);
int /*<<< orphan*/ print_debug(char *);
int cpu_init_detected(void) {
  unsigned long dcl;
  int cpu_init;
  unsigned long htic;
  htic = pci_read_config32(((((0) & 0xFF) << 16) | (((0x18) & 0x1f) << 11) |
                            (((0) & 0x07) << 8) | ((0x6c) & 0xFF)));
  cpu_init = (htic & (1 << 6));
  if (cpu_init) {
    print_debug("CPU INIT Detected.\r\n");
  }
  return cpu_init;
}


x86 assembly (clang, -O0):
<cpu_init_detected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0xc06c,%edi
call   1030 <pci_read_config32@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0x40,%rax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1157 <cpu_init_detected+0x37>
lea    0xeae(%rip),%rdi
call   1040 <print_debug@plt>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpu_init_detected>:
push   %rbx
mov    $0xc06c,%edi
call   1030 <pci_read_config32@plt>
mov    %rax,%rbx
and    $0x40,%ebx
je     113f <cpu_init_detected+0x1f>
lea    0xec6(%rip),%rdi
call   1040 <print_debug@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"CPU INIT Detected.\0D\0A\00"
define i32 @cpu_init_detected() {
%1 = alloca i64
%2 = alloca i32
%3 = alloca i64
%4 = call i64 @pci_read_config32(i32 49260)
store i64 %4, i64* %3
%5 = load i64, i64* %3
%6 = and i64 %5, 64
%7 = trunc i64 %6 to i32
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @print_debug(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %0
%13 = load i32, i32* %2
ret i32 %13
}

LLVM IR (-O2):
@.str = [21 x i8] c"CPU INIT Detected.\0D\0A\00"
define i32 @cpu_init_detected() {
%1 = tail call i64 @pci_read_config32(i32 49260)
%2 = trunc i64 %1 to i32
%3 = and i32 %2, 64
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @print_debug(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
ret i32 %3
}
int length(int number) {
  if (number == 0) {
    return 1;
  }
  int length = 0;
  while (number != 0) {
    number /= 10;
    length++;
  }
  return length;
}


x86 assembly (clang, -O0):
<length>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    111d <length+0x1d>
movl   $0x1,-0x4(%rbp)
jmp    1150 <length+0x50>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     114a <length+0x4a>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1124 <length+0x24>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<length>:
test   %edi,%edi
je     1133 <length+0x33>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
movslq %edi,%rcx
imul   $0x66666667,%rcx,%rdi
mov    %rdi,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rdi
add    %edx,%edi
add    $0x1,%eax
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1110 <length+0x10>
ret
mov    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @length(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %10, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %7, %3 ], [ 0, %1 ]
%5 = phi i32 [ %6, %3 ], [ %0, %1 ]
%6 = sdiv i32 %5, 10
%7 = add nuw nsw i32 %4, 1
%8 = add i32 %5, 9
%9 = icmp ult i32 %8, 19
br i1 %9, label %10, label %3
10: ; preds = %3, %1
%11 = phi i32 [ 1, %1 ], [ %7, %3 ]
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int /*<<< orphan*/);
void putstr(const char *str) { write(1, str, strlen(str)); }


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

x86 assembly (clang, -O2):
<putstr>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
pop    %rbx
jmp    1030 <write@plt>

LLVM IR (-O0):
define void @putstr(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = call i32 @write(i32 1, i8* %3, i32 %5)
ret void
}

LLVM IR (-O2):
define void @putstr(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = tail call i32 @write(i32 1, i8* %0, i32 %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ CAN0_IRQ1_DriverIRQHandler();
__attribute__((weak)) void CAN0_IRQ1_IRQHandler(void) {
  CAN0_IRQ1_DriverIRQHandler();
}


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

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

LLVM IR (-O0):
define weak void @CAN0_IRQ1_IRQHandler() {
%1 = call i32 (...) @CAN0_IRQ1_DriverIRQHandler()
ret void
}

LLVM IR (-O2):
define weak void @CAN0_IRQ1_IRQHandler() {
%1 = tail call i32 (...) @CAN0_IRQ1_DriverIRQHandler()
ret void
}
/* Variables and functions */
int rand();
int randRange(int from, int to) {
  int x = rand();
  x = x < 0 ? -x : x;
  return (x) % (to - from) + from;
}


x86 assembly (clang, -O0):
<randRange>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    113f <randRange+0x2f>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    1145 <randRange+0x35>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    -0x4(%rbp),%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<randRange>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <rand@plt>
mov    %eax,%ecx
neg    %ecx
cmovns %ecx,%eax
sub    %ebp,%ebx
cltd
idiv   %ebx
add    %edx,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @randRange(i32 %0, i32 %1) {
%3 = tail call i32 (...) @rand()
%4 = tail call i32 @llvm.abs.i32(i32 %3, i1 true)
%5 = sub nsw i32 %1, %0
%6 = srem i32 %4, %5
%7 = add nsw i32 %6, %0
ret i32 %7
}
/* Type definitions */
typedef int /*<<< orphan*/ z_stream;

/* Variables and functions */
int /*<<< orphan*/ Z_DEFLATED;
int deflateInit2(int /*<<< orphan*/ *, int, int /*<<< orphan*/, int, int, int);
int streaming_commons_deflate_init2(z_stream *stream, int level, int methodBits,
                                    int memlevel, int strategy) {
  return deflateInit2(stream, level, Z_DEFLATED, methodBits, memlevel,
                      strategy);
}


x86 assembly (clang, -O0):
<streaming_commons_deflate_init2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2ea9(%rip),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x18(%rbp),%r9d
call   1030 <deflateInit2@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<streaming_commons_deflate_init2>:
mov    %r8d,%r9d
mov    %ecx,%r8d
mov    %edx,%ecx
mov    0x2ec1(%rip),%rax
mov    (%rax),%edx
jmp    1030 <deflateInit2@plt>

LLVM IR (-O0):
@Z_DEFLATED = global i32 0
define i32 @streaming_commons_deflate_init2(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32*, i32** %6
%12 = load i32, i32* %7
%13 = load i32, i32* @Z_DEFLATED
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = load i32, i32* %10
%17 = call i32 @deflateInit2(i32* %11, i32 %12, i32 %13, i32 %14, i32 %15, i32 %16)
ret i32 %17
}

LLVM IR (-O2):
@Z_DEFLATED = global i32 0
define i32 @streaming_commons_deflate_init2(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = load i32, i32* @Z_DEFLATED
%7 = tail call i32 @deflateInit2(i32* %0, i32 %1, i32 %6, i32 %2, i32 %3, i32 %4)
ret i32 %7
}
unsigned int g(unsigned int x) { return x + 3; }


x86 assembly (clang, -O0):
<g>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<g>:
lea    0x3(%rdi),%eax
ret

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

LLVM IR (-O2):
define i32 @g(i32 %0) {
%2 = add i32 %0, 3
ret i32 %2
}
void gdk_x11_colormap_get_xcolormap() {}


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

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

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

LLVM IR (-O2):
define void @gdk_x11_colormap_get_xcolormap() {
ret void
}
float mapfloat(float x, float in_min, float in_max, float out_min,
               float out_max) {
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}


x86 assembly (clang, -O0):
<mapfloat>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  %xmm4,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
subss  -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm1
subss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
addss  -0x10(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<mapfloat>:
subss  %xmm1,%xmm0
subss  %xmm3,%xmm4
mulss  %xmm4,%xmm0
subss  %xmm1,%xmm2
divss  %xmm2,%xmm0
addss  %xmm3,%xmm0
ret

LLVM IR (-O0):
define float @mapfloat(float %0, float %1, float %2, float %3, float %4) {
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float %0, float* %6
store float %1, float* %7
store float %2, float* %8
store float %3, float* %9
store float %4, float* %10
%11 = load float, float* %6
%12 = load float, float* %7
%13 = fsub float %11, %12
%14 = load float, float* %10
%15 = load float, float* %9
%16 = fsub float %14, %15
%17 = fmul float %13, %16
%18 = load float, float* %8
%19 = load float, float* %7
%20 = fsub float %18, %19
%21 = fdiv float %17, %20
%22 = load float, float* %9
%23 = fadd float %21, %22
ret float %23
}

LLVM IR (-O2):
define float @mapfloat(float %0, float %1, float %2, float %3, float %4) {
%6 = fsub float %0, %1
%7 = fsub float %4, %3
%8 = fmul float %6, %7
%9 = fsub float %2, %1
%10 = fdiv float %8, %9
%11 = fadd float %10, %3
ret float %11
}
_Noreturn void f(void) {}


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

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

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

LLVM IR (-O2):
define void @f() {
ret void
}
/* Variables and functions */
int gcd(int, int);
int lcm(int m, int n) { return m / gcd(m, n) * n; }


x86 assembly (clang, -O0):
<lcm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <gcd@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
imul   -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcm>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <gcd@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
imul   %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @lcm(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %3
%7 = load i32, i32* %4
%8 = call i32 @gcd(i32 %6, i32 %7)
%9 = sdiv i32 %5, %8
%10 = load i32, i32* %4
%11 = mul nsw i32 %9, %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @lcm(i32 %0, i32 %1) {
%3 = tail call i32 @gcd(i32 %0, i32 %1)
%4 = sdiv i32 %0, %3
%5 = mul nsw i32 %4, %1
ret i32 %5
}
int fun348() { return 348; }


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

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

LLVM IR (-O0):
define i32 @fun348() {
ret i32 348
}

LLVM IR (-O2):
define i32 @fun348() {
ret i32 348
}
void max17058_update_rcomp(int temp) {}


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

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

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

LLVM IR (-O2):
define void @max17058_update_rcomp(i32 %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void print_pattern2(int ile_gwiazdek) {
  for (int i = 1; i <= ile_gwiazdek; i++) {
    putchar('*');
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_pattern2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1156 <print_pattern2+0x36>
mov    $0x2a,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1132 <print_pattern2+0x12>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define void @print_pattern2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %4
4: ; preds = %10, %1
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = icmp sle i32 %5, %6
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = call i32 @putchar(i8 signext 42)
br label %10
10: ; preds = %8
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
br label %4
13: ; preds = %4
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @print_pattern2(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %3, label %5
3: ; preds = %5, %1
%4 = tail call i32 bitcast (i32 (i8)* @putchar to i32 (i32)*)(i32 10)
ret void
5: ; preds = %1, %5
%6 = phi i32 [ %8, %5 ], [ 1, %1 ]
%7 = tail call i32 @putchar(i8 signext 42)
%8 = add nuw i32 %6, 1
%9 = icmp eq i32 %6, %0
br i1 %9, label %3, label %5
}
/* Variables and functions */
char getchar();
void clearInput(void) {
  while (getchar() != '\n') {
  }
}


x86 assembly (clang, -O0):
<clearInput>:
push   %rbp
mov    %rsp,%rbp
jmp    1119 <clearInput+0x9>
mov    $0x0,%al
call   1030 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1131 <clearInput+0x21>
jmp    1119 <clearInput+0x9>
pop    %rbp
ret

x86 assembly (clang, -O2):
<clearInput>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    $0xa,%al
jne    1120 <clearInput+0x10>
pop    %rax
ret

LLVM IR (-O0):
define void @clearInput() {
br label %1
1: ; preds = %5, %0
%2 = call signext i8 (...) @getchar()
%3 = sext i8 %2 to i32
%4 = icmp ne i32 %3, 10
br i1 %4, label %5, label %6
5: ; preds = %1
br label %1
6: ; preds = %1
ret void
}

LLVM IR (-O2):
define void @clearInput() {
br label %1
1: ; preds = %1, %0
%2 = tail call signext i8 (...) @getchar()
%3 = icmp eq i8 %2, 10
br i1 %3, label %4, label %1
4: ; preds = %1
ret void
}
void f(void) {
  int *p;
  *p = 3;
  *p = 3.4;
  *p = 3.4f;
  p[1] = 3;
  p[1] = 3.4;
  p[1] = 3.4f;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,0x4(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,0x4(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
define void @f() {
%1 = alloca i32*
%2 = load i32*, i32** %1
store i32 3, i32* %2
%3 = load i32*, i32** %1
store i32 3, i32* %3
%4 = load i32*, i32** %1
store i32 3, i32* %4
%5 = load i32*, i32** %1
%6 = getelementptr inbounds i32, i32* %5, i64 1
store i32 3, i32* %6
%7 = load i32*, i32** %1
%8 = getelementptr inbounds i32, i32* %7, i64 1
store i32 3, i32* %8
%9 = load i32*, i32** %1
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 3, i32* %10
ret void
}

LLVM IR (-O2):
foo() { return (int)-1; }


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

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

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

LLVM IR (-O2):
define i32 @foo() {
ret i32 -1
}
/* Variables and functions */
int /*<<< orphan*/ glNormal3d(double, double, double);
void Normal3d(double x, double y, double z) { glNormal3d(x, y, z); }


x86 assembly (clang, -O0):
<Normal3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
call   1030 <glNormal3d@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Normal3d>:
jmp    1030 <glNormal3d@plt>

LLVM IR (-O0):
define void @Normal3d(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* %4
%8 = load double, double* %5
%9 = load double, double* %6
%10 = call i32 @glNormal3d(double %7, double %8, double %9)
ret void
}

LLVM IR (-O2):
define void @Normal3d(double %0, double %1, double %2) {
%4 = tail call i32 @glNormal3d(double %0, double %1, double %2)
ret void
}
/* Variables and functions */
int assert(int);
int main() {
  assert(16 / 2 * 2 / 2 * 2) == 16;
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x10,%edi
call   1030 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @assert(i32 16)
%3 = icmp eq i32 %2, 16
%4 = zext i1 %3 to i32
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 @assert(i32 16)
ret i32 0
}
/* Type definitions */
struct ubi_volume_desc {
  int dummy;
};

/* Variables and functions */
int ubi_leb_write(struct ubi_volume_desc *, int, void const *, int, int);
int ubi_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
              int offset, int len) {
  return ubi_leb_write(desc, lnum, buf, offset, len);
}


x86 assembly (clang, -O0):
<ubi_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <ubi_leb_write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ubi_write>:
jmp    1030 <ubi_leb_write@plt>

LLVM IR (-O0):
%struct.ubi_volume_desc = type { i32 }
define i32 @ubi_write(%struct.ubi_volume_desc* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca %struct.ubi_volume_desc*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store %struct.ubi_volume_desc* %0, %struct.ubi_volume_desc** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load %struct.ubi_volume_desc*, %struct.ubi_volume_desc** %6
%12 = load i32, i32* %7
%13 = load i8*, i8** %8
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = call i32 @ubi_leb_write(%struct.ubi_volume_desc* %11, i32 %12, i8* %13, i32 %14, i32 %15)
ret i32 %16
}

LLVM IR (-O2):
%struct.ubi_volume_desc = type { i32 }
define i32 @ubi_write(%struct.ubi_volume_desc* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = tail call i32 @ubi_leb_write(%struct.ubi_volume_desc* %0, i32 %1, i8* %2, i32 %3, i32 %4)
ret i32 %6
}
/* Variables and functions */
double sqrt(double);
double TH_rsqrt(double x) { return 1.0 / sqrt(x); }


x86 assembly (clang, -O0):
<TH_rsqrt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xece(%rip),%xmm0
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TH_rsqrt>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1121 <TH_rsqrt+0x11>
sqrtsd %xmm0,%xmm0
jmp    1126 <TH_rsqrt+0x16>
call   1030 <sqrt@plt>
movsd  0xed2(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @TH_rsqrt(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call double @sqrt(double %3)
%5 = fdiv double 1.000000e+00, %4
ret double %5
}

LLVM IR (-O2):
define double @TH_rsqrt(double %0) {
%2 = tail call double @sqrt(double %0)
%3 = fdiv double 1.000000e+00, %2
ret double %3
}
/* Variables and functions */
int /*<<< orphan*/ read(int, char *, int);
void read_into_buffer(int fd) {
  char buf[10];
  read(fd, buf, 1000);
}


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

x86 assembly (clang, -O2):
<read_into_buffer>:
sub    $0x18,%rsp
lea    0xe(%rsp),%rsi
mov    $0x3e8,%edx
call   1030 <read@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @read_into_buffer(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i8]
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = call i32 @read(i32 %4, i8* %5, i32 1000)
ret void
}

LLVM IR (-O2):
define void @read_into_buffer(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = call i32 @read(i32 %0, i8* %3, i32 1000)
ret void
}
/* Variables and functions */
int htons(short);
short mkls(int x) {
  x = htons((short)x);
  return (short)(((x >> 8) & 0xFF) | ((x & 0xFF) << 8));
}


x86 assembly (clang, -O0):
<mkls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
movswl %ax,%edi
call   1030 <htons@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
cwtl
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkls>:
push   %rax
movswl %di,%edi
call   1030 <htons@plt>
rol    $0x8,%ax
pop    %rcx
ret

LLVM IR (-O0):
define signext i16 @mkls(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = trunc i32 %3 to i16
%5 = call i32 @htons(i16 signext %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = ashr i32 %6, 8
%8 = and i32 %7, 255
%9 = load i32, i32* %2
%10 = and i32 %9, 255
%11 = shl i32 %10, 8
%12 = or i32 %8, %11
%13 = trunc i32 %12 to i16
ret i16 %13
}

LLVM IR (-O2):
define signext i16 @mkls(i32 %0) {
%2 = trunc i32 %0 to i16
%3 = tail call i32 @htons(i16 signext %2)
%4 = trunc i32 %3 to i16
%5 = tail call i16 @llvm.bswap.i16(i16 %4)
ret i16 %5
}
/* Variables and functions */
int get_retval();
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("C seems to be working.\n");
  return get_retval();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <get_retval@plt>
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [24 x i8] c"C seems to be working.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @get_retval()
ret i32 %3
}

LLVM IR (-O2):
@str = [23 x i8] c"C seems to be working.\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @get_retval()
ret i32 %2
}
void record_free_skb_body(struct sk_buff *skb) {}


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

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

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

LLVM IR (-O2):
%struct.sk_buff = type opaque
define void @record_free_skb_body(%struct.sk_buff* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ geteuid();
int seteuid(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int escalate() {
  if (seteuid(0) == -1 || geteuid() != 0) {
    fprintf(stderr, "Failed to escalate privileges.\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<escalate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
call   1050 <seteuid@plt>
cmp    $0xffffffff,%eax
je     1159 <escalate+0x29>
mov    $0x0,%al
call   1030 <geteuid@plt>
cmp    $0x0,%rax
je     117a <escalate+0x4a>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1181 <escalate+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escalate>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
call   1050 <seteuid@plt>
cmp    $0xffffffff,%eax
je     114b <escalate+0x1b>
xor    %eax,%eax
call   1030 <geteuid@plt>
test   %rax,%rax
je     1165 <escalate+0x35>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xea5(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Failed to escalate privileges.\0A\00"
define i32 @escalate() {
%1 = alloca i32
%2 = call i32 @seteuid(i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = call i64 (...) @geteuid()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %4, %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %11
10: ; preds = %4
store i32 0, i32* %1
br label %11
11: ; preds = %10, %7
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Failed to escalate privileges.\0A\00"
define i32 @escalate() {
%1 = tail call i32 @seteuid(i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i64 (...) @geteuid()
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3, %0
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %3, %6
%10 = phi i32 [ 1, %6 ], [ 0, %3 ]
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double foo();
int main() {
  if (foo() != 1.0)
    abort();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <foo@plt>
movsd  0xeb2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1163 <main+0x33>
jp     1163 <main+0x33>
jmp    116a <main+0x3a>
mov    $0x0,%al
call   1030 <abort@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <foo@plt>
ucomisd 0xec0(%rip),%xmm0
jne    1144 <main+0x14>
jnp    114b <main+0x1b>
xor    %eax,%eax
call   1030 <abort@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call double (...) @foo()
%3 = fcmp une double %2, 1.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 (...) @abort()
unreachable
6: ; preds = %0
%7 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call double (...) @foo()
%2 = fcmp une double %1, 1.000000e+00
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %0
%6 = tail call i32 @exit(i32 0)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ itoa(int, char *, int);
char *SCClItoa(int number) {
  static char buffer[32];
  itoa(number, buffer, 10);
  return buffer;
}


x86 assembly (clang, -O0):
<SCClItoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    0x2f1b(%rip),%rsi
mov    $0xa,%edx
call   1030 <itoa@plt>
lea    0x2f0a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SCClItoa>:
push   %rbx
lea    0x2f28(%rip),%rbx
mov    %rbx,%rsi
mov    $0xa,%edx
call   1030 <itoa@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@SCClItoa.buffer = internal global [32 x i8] zeroinitializer
define i8* @SCClItoa(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @itoa(i32 %3, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @SCClItoa.buffer, i64 0, i64 0), i32 10)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @SCClItoa.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@SCClItoa.buffer = internal global [32 x i8] zeroinitializer
define i8* @SCClItoa(i32 %0) {
%2 = tail call i32 @itoa(i32 %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @SCClItoa.buffer, i64 0, i64 0), i32 10)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @SCClItoa.buffer, i64 0, i64 0)
}
/* Variables and functions */
int /*<<< orphan*/ test_exit();
int main() {
  test_exit();
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @test_exit()
ret i32 0
}
int test_imm_E0uint32_reg(unsigned int val) {
  return ((val) & (0xE0 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_E0uint32_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
and    $0xe0,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @test_imm_E0uint32_reg(i32 %0) {
%2 = and i32 %0, 224
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
void string_dummy(char *dummy) {}


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

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

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

LLVM IR (-O2):
define void @string_dummy(i8* nocapture %0) {
ret void
}
int pid2tss_sel(int pid) { return (5 + pid) << 3; }


x86 assembly (clang, -O0):
<pid2tss_sel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5,%eax
shl    $0x3,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pid2tss_sel>:
lea    0x28(,%rdi,8),%eax
ret

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

LLVM IR (-O2):
define i32 @pid2tss_sel(i32 %0) {
%2 = shl i32 %0, 3
%3 = add i32 %2, 40
ret i32 %3
}