xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ printf(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(int argc, char **argv) {
  printf("check_random | test=1\n");
  srand(getpid());
  return rand() % 4;
}


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    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%edi
call   1050 <srand@plt>
xor    %eax,%eax
call   1060 <rand@plt>
lea    0x3(%rax),%ecx
test   %eax,%eax
cmovns %eax,%ecx
and    $0xfffffffc,%ecx
sub    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"check_random | test=1\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 ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @getpid()
%8 = call i32 @srand(i32 %7)
%9 = call i32 (...) @rand()
%10 = srem i32 %9, 4
ret i32 %10
}

LLVM IR (-O2):
@str = [22 x i8] c"check_random | test=1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (...) @getpid()
%5 = tail call i32 @srand(i32 %4)
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 4
ret i32 %7
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isprint(int);
void t_isprint_0xde() {
  Assert_real((isprint(222) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isprint.c",
              1115, ("isprint should be 0 for 0xde"));
}


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

x86 assembly (clang, -O2):
<t_isprint_0xde>:
push   %rax
mov    $0xde,%edi
call   1030 <isprint@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf66(%rip),%rcx
mov    $0x45b,%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_isprint.c\00"
@.str.1 = [29 x i8] c"isprint should be 0 for 0xde\00"
define void @t_isprint_0xde() {
%1 = call i64 @isprint(i32 222)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 1115, 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_isprint.c\00"
@.str.1 = [29 x i8] c"isprint should be 0 for 0xde\00"
define void @t_isprint_0xde() {
%1 = tail call i64 @isprint(i32 222)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 1115, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ __cond_resched();
scalar_t__ need_resched();
void cond_resched(void) {
  if (need_resched())
    __cond_resched();
}


x86 assembly (clang, -O0):
<cond_resched>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <need_resched@plt>
cmp    $0x0,%rax
je     113c <cond_resched+0x1c>
mov    $0x0,%al
call   1040 <__cond_resched@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<cond_resched>:
push   %rax
xor    %eax,%eax
call   1030 <need_resched@plt>
test   %rax,%rax
je     1135 <cond_resched+0x15>
xor    %eax,%eax
pop    %rcx
jmp    1040 <__cond_resched@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @cond_resched() {
%1 = call i64 (...) @need_resched()
%2 = icmp ne i64 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = call i32 (...) @__cond_resched()
br label %5
5: ; preds = %3, %0
ret void
}

LLVM IR (-O2):
define void @cond_resched() {
%1 = tail call i64 (...) @need_resched()
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (...) @__cond_resched()
br label %5
5: ; preds = %3, %0
ret void
}
/* Variables and functions */
int /*<<< orphan*/ U_WMRNOTIMPLEMENTED_swap(char *, int);
void U_WMR95_swap(char *record, int torev) {
  U_WMRNOTIMPLEMENTED_swap(record, torev);
}


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

x86 assembly (clang, -O2):
<U_WMR95_swap>:
jmp    1030 <U_WMRNOTIMPLEMENTED_swap@plt>

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

LLVM IR (-O2):
define void @U_WMR95_swap(i8* %0, i32 %1) {
%3 = tail call i32 @U_WMRNOTIMPLEMENTED_swap(i8* %0, i32 %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Atm128Rfa1SerialP__Uart1Interrupts__txInterruptHandler();
void Atm128Rfa1Uart1InterruptsP__Uart1Interrupts__txInterruptHandler(void) {
  Atm128Rfa1SerialP__Uart1Interrupts__txInterruptHandler();
}


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

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

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

LLVM IR (-O2):
define void @Atm128Rfa1Uart1InterruptsP__Uart1Interrupts__txInterruptHandler() {
%1 = tail call i32 (...) @Atm128Rfa1SerialP__Uart1Interrupts__txInterruptHandler()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ *strchr(char *, int);
int tui_getk();
int /*<<< orphan*/ usleep(int);
int tui_wait_for_key(char *s) {
  int c;
  while (1) {
    while ((c = tui_getk()) != 0) {
      if (strchr(s, c) != NULL)
        return c;
    }
    usleep(10000);
  }
}


x86 assembly (clang, -O0):
<tui_wait_for_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
jmp    1141 <tui_wait_for_key+0x11>
mov    $0x0,%al
call   1040 <tui_getk@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1178 <tui_wait_for_key+0x48>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     1173 <tui_wait_for_key+0x43>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    1141 <tui_wait_for_key+0x11>
mov    $0x2710,%edi
call   1050 <usleep@plt>
jmp    113c <tui_wait_for_key+0xc>

x86 assembly (clang, -O2):
<tui_wait_for_key>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
jmp    114a <tui_wait_for_key+0x1a>
nopl   0x0(%rax,%rax,1)
mov    $0x2710,%edi
call   1050 <usleep@plt>
xor    %eax,%eax
call   1040 <tui_getk@plt>
test   %eax,%eax
je     1140 <tui_wait_for_key+0x10>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     114a <tui_wait_for_key+0x1a>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @tui_wait_for_key(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
br label %4
4: ; preds = %1, %16
br label %5
5: ; preds = %15, %4
%6 = call i32 (...) @tui_getk()
store i32 %6, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = call i32* @strchr(i8* %9, i32 %10)
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = load i32, i32* %3
ret i32 %14
15: ; preds = %8
br label %5
16: ; preds = %5
%17 = call i32 @usleep(i32 10000)
br label %4
}

LLVM IR (-O2):
define i32 @tui_wait_for_key(i8* %0) {
br label %2
2: ; preds = %8, %1
%3 = tail call i32 (...) @tui_getk()
%4 = icmp eq i32 %3, 0
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32* @strchr(i8* %0, i32 %3)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %5, %10
br label %2
9: ; preds = %5
ret i32 %3
10: ; preds = %2
%11 = tail call i32 @usleep(i32 10000)
br label %8
}
/* Variables and functions */
int sqrt(int);
int isPrime(int a) {
  int b, i;
  b = sqrt(a);
  for (i = 2; i <= b; i++) {
    if (a % i == 0)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1168 <isPrime+0x58>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1155 <isPrime+0x45>
movl   $0x0,-0x4(%rbp)
jmp    116f <isPrime+0x5f>
jmp    115a <isPrime+0x4a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <isPrime+0x1d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrime>:
push   %rbx
mov    %edi,%ebx
call   1030 <sqrt@plt>
mov    $0x1,%ecx
cmp    $0x2,%eax
jl     114f <isPrime+0x3f>
mov    %eax,%esi
neg    %esi
mov    $0x2,%edi
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
cltd
idiv   %edi
test   %edx,%edx
je     114d <isPrime+0x3d>
lea    (%rsi,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    1130 <isPrime+0x20>
jmp    114f <isPrime+0x3f>
xor    %ecx,%ecx
mov    %ecx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @isPrime(i32 %0) {
%2 = tail call i32 @sqrt(i32 %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %11, label %7
4: ; preds = %7
%5 = add nuw i32 %8, 1
%6 = icmp eq i32 %8, %2
br i1 %6, label %11, label %7
7: ; preds = %1, %4
%8 = phi i32 [ %5, %4 ], [ 2, %1 ]
%9 = srem i32 %0, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %4
11: ; preds = %7, %4, %1
%12 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 0, %7 ]
ret i32 %12
}
/* Type definitions */
struct string_formatter {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ output_char(struct string_formatter *, int /*<<< orphan*/);
void output_string(struct string_formatter *formatter, const char *str) {
  while (*str)
    output_char(formatter, *str++);
}


x86 assembly (clang, -O0):
<output_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     114d <output_string+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%esi
call   1030 <output_char@plt>
jmp    1120 <output_string+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_string>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%al
test   %al,%al
je     1146 <output_string+0x36>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <output_char@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <output_string+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.string_formatter = type { i32 }
define void @output_string(%struct.string_formatter* %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %11, %5 ], [ %3, %2 ]
%7 = phi i8* [ %8, %5 ], [ %1, %2 ]
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = sext i8 %6 to i32
%10 = tail call i32 @output_char(%struct.string_formatter* %0, i32 %9)
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5, %2
ret void
}
/* Type definitions */
typedef int off_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int seek_end(int fd) {
  off_t l_ret;
  if ((l_ret = lseek(fd, 0, SEEK_END)) == -1) {
    perror("lseek");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<seek_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1030 <lseek@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    1174 <seek_end+0x44>
lea    0xe9f(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seek_end>:
push   %rax
mov    0x2eb0(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1030 <lseek@plt>
cmp    $0xffffffff,%eax
je     114a <seek_end+0x1a>
xor    %eax,%eax
pop    %rcx
ret
lea    0xeaf(%rip),%rdi
call   1040 <perror@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SEEK_END = global i32 0
@.str = [6 x i8] c"lseek\00"
@EXIT_FAILURE = global i32 0
define i32 @seek_end(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = load i32, i32* @SEEK_END
%6 = call i32 @lseek(i32 %4, i32 0, i32 %5)
store i32 %6, i32* %3
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
ret i32 0
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@.str = [6 x i8] c"lseek\00"
@EXIT_FAILURE = global i32 0
define i32 @seek_end(i32 %0) {
%2 = load i32, i32* @SEEK_END
%3 = tail call i32 @lseek(i32 %0, i32 0, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void main() {
  int a;
  a = 2;
  int b;
  b = 5;
  int c;
  c = 0;
  int d;
  d = 0;
  while (a < b) {
    if (c) {
      a += 1;
    } else if (d) {
      printf("%s", "d was true");
    } else {
      b -= 1;
    }
  }
  printf("%d", b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x2,-0x4(%rbp)
movl   $0x5,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <main+0x7f>
cmpl   $0x0,-0xc(%rbp)
je     1158 <main+0x48>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    118a <main+0x7a>
cmpl   $0x0,-0x10(%rbp)
je     117c <main+0x6c>
lea    0xe97(%rip),%rdi
lea    0xe93(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <main+0x75>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118a <main+0x7a>
jmp    1134 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
lea    0xee9(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%d\00"
define void @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
ret void
}
void FanChannelConfigAuto(unsigned long ulBase, unsigned long ulChannel,
                          unsigned long ulConfig) {
  ;
  ;
  (*((volatile unsigned long *)(ulBase + 0x00000010 + (ulChannel * 0x10)))) =
      ~0x00000001 & ulConfig;
}


x86 assembly (clang, -O0):
<FanChannelConfigAuto>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
and    $0xfffffffffffffffe,%rcx
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    -0x10(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<FanChannelConfigAuto>:
and    $0xfffffffffffffffe,%rdx
shl    $0x4,%rsi
mov    %rdx,0x10(%rdi,%rsi,1)
ret

LLVM IR (-O0):
define void @FanChannelConfigAuto(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %6
%8 = and i64 -2, %7
%9 = load i64, i64* %4
%10 = add i64 %9, 16
%11 = load i64, i64* %5
%12 = mul i64 %11, 16
%13 = add i64 %10, %12
%14 = inttoptr i64 %13 to i64*
store volatile i64 %8, i64* %14
ret void
}

LLVM IR (-O2):
define void @FanChannelConfigAuto(i64 %0, i64 %1, i64 %2) {
%4 = and i64 %2, -2
%5 = add i64 %0, 16
%6 = shl i64 %1, 4
%7 = add i64 %5, %6
%8 = inttoptr i64 %7 to i64*
store volatile i64 %4, i64* %8
ret void
}
int inc_ctrl(int c) {
  if (c == 0xff)
    c = 0;
  else
    c++;
  if (c == 12)
    c = 0xff;
  return c;
}


x86 assembly (clang, -O0):
<inc_ctrl>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0xff,-0x4(%rbp)
jne    1120 <inc_ctrl+0x20>
movl   $0x0,-0x4(%rbp)
jmp    1129 <inc_ctrl+0x29>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xc,-0x4(%rbp)
jne    113a <inc_ctrl+0x3a>
movl   $0xff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<inc_ctrl>:
lea    0x1(%rdi),%eax
xor    %ecx,%ecx
cmp    $0xff,%edi
cmovne %eax,%ecx
cmp    $0xc,%ecx
mov    $0xff,%eax
cmovne %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @inc_ctrl(i32 %0) {
%2 = icmp eq i32 %0, 255
%3 = add nsw i32 %0, 1
%4 = select i1 %2, i32 0, i32 %3
%5 = icmp eq i32 %4, 12
%6 = select i1 %5, i32 255, i32 %4
ret i32 %6
}
unsigned int fast_ftol1023(float v) {
  v += 1024.f;
  int r = *((int *)(&v));
  r &= ~0xFF800000;
  r >>= (23 - 3);
  return r;
}


x86 assembly (clang, -O0):
<fast_ftol1023>:
push   %rbp
mov    %rsp,%rbp
movss  %xmm0,-0x4(%rbp)
movss  0xeef(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x7fffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x14,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fast_ftol1023>:
addss  0xef8(%rip),%xmm0
movd   %xmm0,%eax
shr    $0x14,%eax
and    $0x7,%eax
ret

LLVM IR (-O0):
define i32 @fast_ftol1023(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = load float, float* %2
%5 = fadd float %4, 1.024000e+03
store float %5, float* %2
%6 = bitcast float* %2 to i32*
%7 = load i32, i32* %6
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = and i32 %8, 8388607
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = ashr i32 %10, 20
store i32 %11, i32* %3
%12 = load i32, i32* %3
ret i32 %12
}

LLVM IR (-O2):
define i32 @fast_ftol1023(float %0) {
%2 = fadd float %0, 1.024000e+03
%3 = bitcast float %2 to i32
%4 = lshr i32 %3, 20
%5 = and i32 %4, 7
ret i32 %5
}
main() {
  int k, l;
  int r = 2;
  if (l == 0) {
    r = 3;
    l = 2;
    k = 5;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1131 <main+0x31>
movl   $0x3,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x5,-0x8(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int truncate(char *, int);
int main() {
  int res = truncate("hello.txt", 50);
  if (res == 0)
    printf("Truncated!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x32,%esi
call   1040 <truncate@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1159 <main+0x39>
lea    0xeb6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0x32,%esi
call   1040 <truncate@plt>
test   %eax,%eax
jne    1142 <main+0x22>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"hello.txt\00"
@.str.1 = [12 x i8] c"Truncated!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @truncate(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 50)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"hello.txt\00"
@str = [11 x i8] c"Truncated!\00"
define i32 @main() {
%1 = tail call i32 @truncate(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 50)
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
ret i32 0
}
int aim_imin(int a, int b) { return a > b ? b : a; }


x86 assembly (clang, -O0):
<aim_imin>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1121 <aim_imin+0x21>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1127 <aim_imin+0x27>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<aim_imin>:
mov    %edi,%eax
cmp    %esi,%edi
cmovg  %esi,%eax
ret

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

LLVM IR (-O2):
define i32 @aim_imin(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
%4 = select i1 %3, i32 %1, i32 %0
ret i32 %4
}
int align(int n, int blocksize) {
  return n % blocksize == 0 ? n : blocksize * ((n / blocksize) + 1);
}


x86 assembly (clang, -O0):
<align>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1125 <align+0x25>
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1140 <align+0x40>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<align>:
mov    %edi,%eax
cltd
idiv   %esi
add    $0x1,%eax
imul   %esi,%eax
test   %edx,%edx
cmove  %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @align(i32 %0, i32 %1) {
%3 = srem i32 %0, %1
%4 = sdiv i32 %0, %1
%5 = icmp eq i32 %3, 0
%6 = add nsw i32 %4, 1
%7 = mul nsw i32 %6, %1
%8 = select i1 %5, i32 %0, i32 %7
ret i32 %8
}
/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
struct t_relay_weechat_msg {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ relay_weechat_msg_add_bytes(struct t_relay_weechat_msg *,
                                               int /*<<< orphan*/ *, int);
void relay_weechat_msg_add_int(struct t_relay_weechat_msg *msg, int value) {
  uint32_t value32;
  value32 = htonl((uint32_t)value);
  relay_weechat_msg_add_bytes(msg, &value32, 4);
}


x86 assembly (clang, -O0):
<relay_weechat_msg_add_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <relay_weechat_msg_add_bytes@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<relay_weechat_msg_add_int>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %esi,%edi
call   1040 <htonl@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <relay_weechat_msg_add_bytes@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.t_relay_weechat_msg = type { i32 }
define void @relay_weechat_msg_add_int(%struct.t_relay_weechat_msg* %0, i32 %1) {
%3 = alloca %struct.t_relay_weechat_msg*
%4 = alloca i32
%5 = alloca i32
store %struct.t_relay_weechat_msg* %0, %struct.t_relay_weechat_msg** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = call i32 @htonl(i32 %6)
store i32 %7, i32* %5
%8 = load %struct.t_relay_weechat_msg*, %struct.t_relay_weechat_msg** %3
%9 = call i32 @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %8, i32* %5, i32 4)
ret void
}

LLVM IR (-O2):
%struct.t_relay_weechat_msg = type { i32 }
define void @relay_weechat_msg_add_int(%struct.t_relay_weechat_msg* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @htonl(i32 %1)
store i32 %5, i32* %3
%6 = call i32 @relay_weechat_msg_add_bytes(%struct.t_relay_weechat_msg* %0, i32* %3, i32 4)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ server_start(int /*<<< orphan*/);
int /*<<< orphan*/ strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  if (argc != 2) {
    usage();
  }
  server_start(strtol(argv[1], NULL, 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)
cmpl   $0x2,-0x8(%rbp)
je     1157 <main+0x27>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,%edi
call   1030 <server_start@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1140 <main+0x10>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x8(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <strtol@plt>
mov    %eax,%edi
call   1030 <server_start@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
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 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 (...) @usage()
br label %10
10: ; preds = %8, %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strtol(i8* %13, i32* null, i32 0)
%15 = call i32 @server_start(i32 %14)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strtol(i8* nocapture %8, i32* null, i32 0)
%10 = tail call i32 @server_start(i32 %9)
ret i32 0
}
int foo(int x) { return x + 10; }


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

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

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

LLVM IR (-O2):
define i32 @foo(i32 %0) {
%2 = add nsw i32 %0, 10
ret i32 %2
}
/* Variables and functions */
int PROT_EXEC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ _SC_PAGESIZE;
int mprotect(void *, size_t, int);
long sysconf(int /*<<< orphan*/);
int subhook_unprotect(void *address, size_t size) {
  long pagesize;
  pagesize = sysconf(_SC_PAGESIZE);
  address = (void *)((long)address & ~(pagesize - 1));
  return mprotect(address, size, (PROT_READ | PROT_WRITE | PROT_EXEC));
}


x86 assembly (clang, -O0):
<subhook_unprotect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e90(%rip),%rax
mov    (%rax),%edx
mov    0x2e57(%rip),%rax
or     (%rax),%edx
mov    0x2e5e(%rip),%rax
or     (%rax),%edx
call   1030 <mprotect@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<subhook_unprotect>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    0x2eb9(%rip),%rcx
mov    0x2e82(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
neg    %rax
and    %rax,%rbx
mov    0x2e81(%rip),%rax
or     (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <mprotect@plt>

LLVM IR (-O0):
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
define i32 @subhook_unprotect(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = load i32, i32* @_SC_PAGESIZE
%7 = call i64 @sysconf(i32 %6)
store i64 %7, i64* %5
%8 = load i8*, i8** %3
%9 = ptrtoint i8* %8 to i64
%10 = load i64, i64* %5
%11 = sub nsw i64 %10, 1
%12 = xor i64 %11, -1
%13 = and i64 %9, %12
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = load i64, i64* %4
%17 = load i32, i32* @PROT_READ
%18 = load i32, i32* @PROT_WRITE
%19 = or i32 %17, %18
%20 = load i32, i32* @PROT_EXEC
%21 = or i32 %19, %20
%22 = call i32 @mprotect(i8* %15, i64 %16, i32 %21)
ret i32 %22
}

LLVM IR (-O2):
@_SC_PAGESIZE = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@PROT_EXEC = global i32 0
define i32 @subhook_unprotect(i8* %0, i64 %1) {
%3 = load i32, i32* @_SC_PAGESIZE
%4 = tail call i64 @sysconf(i32 %3)
%5 = ptrtoint i8* %0 to i64
%6 = sub i64 0, %4
%7 = and i64 %6, %5
%8 = inttoptr i64 %7 to i8*
%9 = load i32, i32* @PROT_READ
%10 = load i32, i32* @PROT_WRITE
%11 = or i32 %10, %9
%12 = load i32, i32* @PROT_EXEC
%13 = or i32 %11, %12
%14 = tail call i32 @mprotect(i8* %8, i64 %1, i32 %13)
ret i32 %14
}
int main(void) {
  "hello"[0] = 'x';
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movb   $0x78,0xeee(%rip)
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ init();
int /*<<< orphan*/ start();
int main(int argc, char *argv[]) {
  init();
  start();
  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)
mov    $0x0,%al
call   1040 <init@plt>
mov    $0x0,%al
call   1030 <start@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <init@plt>
xor    %eax,%eax
call   1030 <start@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**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @init()
%7 = call i32 (...) @start()
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init()
%4 = tail call i32 (...) @start()
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ my_func(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdout;
int main(void) {
  FILE *log = stdout;
  my_func(log);
  return 0;
}


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

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

LLVM IR (-O0):
@stdout = global i32* null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = load i32*, i32** @stdout
store i32* %3, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @my_func(i32* %4)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32* null
define i32 @main() {
%1 = load i32*, i32** @stdout
%2 = tail call i32 @my_func(i32* %1)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ PauseAudio298(unsigned long);
void pauseaudio(unsigned long id) { PauseAudio298(id); }


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

x86 assembly (clang, -O2):
<pauseaudio>:
jmp    1030 <PauseAudio298@plt>

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

LLVM IR (-O2):
define void @pauseaudio(i64 %0) {
%2 = tail call i32 @PauseAudio298(i64 %0)
ret void
}
void ARGBShadeRow_SSE2() {}


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

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

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

LLVM IR (-O2):
define void @ARGBShadeRow_SSE2() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _exit_cb();
bool cmd_exit(const char *arg) {
  _exit_cb();
  return false;
}


x86 assembly (clang, -O0):
<cmd_exit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <_exit_cb@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @cmd_exit(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 (...) @_exit_cb()
ret i32 0
}

LLVM IR (-O2):
define i32 @cmd_exit(i8* nocapture readnone %0) {
%2 = tail call i32 (...) @_exit_cb()
ret i32 0
}
/* Type definitions */
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ streamtowrite(int, void const *, int /*<<< orphan*/,
                                 int /*<<< orphan*/);
int32_t tcptowrite(int sock, const void *buff, uint32_t leng, uint32_t msecto) {
  return streamtowrite(sock, buff, leng, msecto);
}


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

x86 assembly (clang, -O2):
<tcptowrite>:
jmp    1030 <streamtowrite@plt>

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

LLVM IR (-O2):
define i32 @tcptowrite(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i32 @streamtowrite(i32 %0, i8* %1, i32 %2, i32 %3)
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ __startrek_entry_pt_OSEK_Task_Background();
void cil_keeperOSEK_Task_Background(void) {
  {
    __startrek_entry_pt_OSEK_Task_Background();
    return;
  }
}


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

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

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

LLVM IR (-O2):
define void @cil_keeperOSEK_Task_Background() {
%1 = tail call i32 (...) @__startrek_entry_pt_OSEK_Task_Background()
ret void
}
void minhafuncao() {
  int x = 0;
  x++;
}


x86 assembly (clang, -O0):
<minhafuncao>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @minhafuncao() {
ret void
}
int pat(int *const p __attribute__((pass_object_size(3))), int n) {
  return p[n];
}


x86 assembly (clang, -O0):
<pat>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pat>:
movslq %edx,%rax
mov    (%rdi,%rax,4),%eax
ret

LLVM IR (-O0):
define i32 @pat(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %6
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i32, i32* %7, i64 %9
%11 = load i32, i32* %10
ret i32 %11
}

LLVM IR (-O2):
define i32 @pat(i32* nocapture %0, i64 %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = getelementptr inbounds i32, i32* %0, i64 %4
%6 = load i32, i32* %5
ret i32 %6
}
/* Variables and functions */
int /*<<< orphan*/ printn(int);
void main() {
  int o_ll = 000101;
  int m = 000000;
  int l = 000007;
  printn(o_ll);
  printn(m);
  printn(l);
  if ((o_ll - m) / 2 > l)
    m = m + (o_ll - m) / 2;
  else
    m = m + l;
  printn(m);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x41,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <printn@plt>
mov    -0x8(%rbp),%edi
call   1030 <printn@plt>
mov    -0xc(%rbp),%edi
call   1030 <printn@plt>
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    -0xc(%rbp),%eax
jle    117f <main+0x6f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
jmp    1188 <main+0x78>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <printn@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x41,%edi
call   1030 <printn@plt>
xor    %edi,%edi
call   1030 <printn@plt>
mov    $0x7,%edi
call   1030 <printn@plt>
mov    $0x20,%edi
pop    %rax
jmp    1030 <printn@plt>

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 65, i32* %1
store i32 0, i32* %2
store i32 7, i32* %3
%4 = load i32, i32* %1
%5 = call i32 @printn(i32 %4)
%6 = load i32, i32* %2
%7 = call i32 @printn(i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @printn(i32 %8)
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = sub nsw i32 %10, %11
%13 = sdiv i32 %12, 2
%14 = load i32, i32* %3
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %0
%17 = load i32, i32* %2
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = sub nsw i32 %18, %19
%21 = sdiv i32 %20, 2
%22 = add nsw i32 %17, %21
store i32 %22, i32* %2
br label %27
23: ; preds = %0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = add nsw i32 %24, %25
store i32 %26, i32* %2
br label %27
27: ; preds = %23, %16
%28 = load i32, i32* %2
%29 = call i32 @printn(i32 %28)
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @printn(i32 65)
%2 = tail call i32 @printn(i32 0)
%3 = tail call i32 @printn(i32 7)
%4 = tail call i32 @printn(i32 32)
ret void
}
/* Variables and functions */
int mod5();
int /*<<< orphan*/ printf(char *, ...);
int mod1() {
  printf("mod1\n");
  printf("mod5=%d\n", mod5());
  return 1;
}


x86 assembly (clang, -O0):
<mod1>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <mod5@plt>
mov    %eax,%esi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<mod1>:
push   %rax
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <mod5@plt>
lea    0xeb5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str.1 = [9 x i8] c"mod5=%d\0A\00"
@str = [5 x i8] c"mod1\00"
define i32 @mod1() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @mod5()
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %2)
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void cerror() {
  printf("Compression scheme unknown, using selection as default\n");
}


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

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

LLVM IR (-O0):
@.str = [56 x i8] c"Compression scheme unknown, using selection as default\0A\00"
define void @cerror() {
%1 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [55 x i8] c"Compression scheme unknown, using selection as default\00"
define void @cerror() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str, i64 0, i64 0))
ret void
}
void maincpu_generic_dma(void) {}


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

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

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

LLVM IR (-O2):
define void @maincpu_generic_dma() {
ret void
}