xunge/DecIR huggingface dataset:
/* Type definitions */
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/);
unsigned int get_current_time() {
  struct timeval tv;
  gettimeofday(&tv, 0);
  return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}


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

x86 assembly (clang, -O2):
<get_current_time>:
push   %rax
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
imul   $0x3e8,(%rsp),%ecx
movslq 0x4(%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
add    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
define i32 @get_current_time() {
%1 = alloca %struct.timeval
%2 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%4 = load i32, i32* %3
%5 = mul nsw i32 %4, 1000
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%7 = load i32, i32* %6
%8 = sdiv i32 %7, 1000
%9 = add nsw i32 %5, %8
ret i32 %9
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define i32 @get_current_time() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
%3 = call i32 @gettimeofday(%struct.timeval* %1, i32 0)
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = load i32, i32* %4
%6 = mul nsw i32 %5, 1000
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%8 = load i32, i32* %7
%9 = sdiv i32 %8, 1000
%10 = add nsw i32 %9, %6
ret i32 %10
}
unsigned long low_sign_extend(x, len)
unsigned int x, len;
{ return (int)((x & 0x1 ? (-1 << (len - 1)) : 0) | x >> 1); }


x86 assembly (clang, -O0):
<low_sign_extend>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     112e <low_sign_extend+0x2e>
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <low_sign_extend+0x38>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <low_sign_extend+0x38>
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
shr    $0x1,%ecx
or     %ecx,%eax
cltq
pop    %rbp
ret

x86 assembly (clang, -O2):
<low_sign_extend>:
mov    %edi,%eax
and    $0x1,%eax
neg    %eax
lea    -0x1(%rsi),%ecx
shr    %cl,%eax
shl    %cl,%eax
shr    %edi
or     %eax,%edi
movslq %edi,%rax
ret

LLVM IR (-O0):
define i64 @low_sign_extend(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 = and i32 %5, 1
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* %4
%10 = sub i32 %9, 1
%11 = shl i32 -1, %10
br label %13
12: ; preds = %2
br label %13
13: ; preds = %12, %8
%14 = phi i32 [ %11, %8 ], [ 0, %12 ]
%15 = load i32, i32* %3
%16 = lshr i32 %15, 1
%17 = or i32 %14, %16
%18 = sext i32 %17 to i64
ret i64 %18
}

LLVM IR (-O2):
define i64 @low_sign_extend(i32 %0, i32 %1) {
%3 = and i32 %0, 1
%4 = icmp eq i32 %3, 0
%5 = add i32 %1, -1
%6 = shl nsw i32 -1, %5
%7 = select i1 %4, i32 0, i32 %6
%8 = lshr i32 %0, 1
%9 = or i32 %7, %8
%10 = sext i32 %9 to i64
ret i64 %10
}
/* Type definitions */
typedef int /*<<< orphan*/ optval;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int SO_REUSEADDR;
int SO_REUSEPORT;
int /*<<< orphan*/ perror(char *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int, int *, int);
void tcp_reuse(int sfd) {
  int optval = 1;
  if (setsockopt(sfd, SOL_SOCKET, (SO_REUSEPORT | SO_REUSEADDR), &optval,
                 sizeof(optval)) < 0) {
    perror("tcp reuse failed.");
    return;
  }
  return;
}


x86 assembly (clang, -O0):
<tcp_reuse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2eac(%rip),%rax
mov    (%rax),%esi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
mov    0x2e82(%rip),%rax
or     (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    117a <tcp_reuse+0x5a>
lea    0xe90(%rip),%rdi
call   1040 <perror@plt>
jmp    117f <tcp_reuse+0x5f>
jmp    117f <tcp_reuse+0x5f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_reuse>:
push   %rax
movl   $0x1,0x4(%rsp)
mov    0x2eb8(%rip),%rax
mov    (%rax),%esi
mov    0x2ea7(%rip),%rax
mov    0x2e90(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     115b <tcp_reuse+0x3b>
pop    %rax
ret
lea    0xe9e(%rip),%rdi
call   1040 <perror@plt>
pop    %rax
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_REUSEPORT = global i32 0
@SO_REUSEADDR = global i32 0
@.str = [18 x i8] c"tcp reuse failed.\00"
define void @tcp_reuse(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @SOL_SOCKET
%6 = load i32, i32* @SO_REUSEPORT
%7 = load i32, i32* @SO_REUSEADDR
%8 = or i32 %6, %7
%9 = call i64 @setsockopt(i32 %4, i32 %5, i32 %8, i32* %3, i32 4)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %14
13: ; preds = %1
br label %14
14: ; preds = %13, %11
ret void
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_REUSEPORT = global i32 0
@SO_REUSEADDR = global i32 0
@.str = [18 x i8] c"tcp reuse failed.\00"
define void @tcp_reuse(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = load i32, i32* @SOL_SOCKET
%5 = load i32, i32* @SO_REUSEPORT
%6 = load i32, i32* @SO_REUSEADDR
%7 = or i32 %6, %5
%8 = call i64 @setsockopt(i32 %0, i32 %4, i32 %7, i32* %2, i32 4)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %1, %10
ret void
}
/* Variables and functions */
int /*<<< orphan*/ send_and_capture_uint8(char);
char strlen(char *);
void send_and_capture_string(char *s) {
  send_and_capture_uint8(strlen(s));
  while (*s != '\0') {
    send_and_capture_uint8(*s);
    s++;
  }
}


x86 assembly (clang, -O0):
<send_and_capture_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
movsbl %al,%edi
call   1040 <send_and_capture_uint8@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116a <send_and_capture_string+0x4a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <send_and_capture_uint8@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113d <send_and_capture_string+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_and_capture_string>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
movsbl %al,%edi
call   1040 <send_and_capture_uint8@plt>
mov    (%rbx),%al
test   %al,%al
je     1153 <send_and_capture_string+0x33>
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1040 <send_and_capture_uint8@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <send_and_capture_string+0x20>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @send_and_capture_string(i8* %0) {
%2 = tail call signext i8 @strlen(i8* %0)
%3 = tail call i32 @send_and_capture_uint8(i8 signext %2)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %1, %6
%7 = phi i8 [ %11, %6 ], [ %4, %1 ]
%8 = phi i8* [ %10, %6 ], [ %0, %1 ]
%9 = tail call i32 @send_and_capture_uint8(i8 signext %7)
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %6
13: ; preds = %6, %1
ret void
}
void put_prev_task_stop(struct rq *rq, struct task_struct *prev) {}


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

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

LLVM IR (-O0):
%struct.rq = type opaque
%struct.task_struct = type opaque
define void @put_prev_task_stop(%struct.rq* %0, %struct.task_struct* %1) {
%3 = alloca %struct.rq*
%4 = alloca %struct.task_struct*
store %struct.rq* %0, %struct.rq** %3
store %struct.task_struct* %1, %struct.task_struct** %4
ret void
}

LLVM IR (-O2):
%struct.rq = type opaque
%struct.task_struct = type opaque
define void @put_prev_task_stop(%struct.rq* nocapture %0, %struct.task_struct* nocapture %1) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ LOG_ERR;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int parse_header(char *header) {
  if (strncmp("KDB\n", header, 3)) {
    syslog(LOG_ERR, "bad file format\n");
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     116c <parse_header+0x4c>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
call   1040 <syslog@plt>
movl   $0x0,-0x4(%rbp)
jmp    1173 <parse_header+0x53>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_header>:
push   %rax
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1153 <parse_header+0x33>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"KDB\0A\00"
@LOG_ERR = global i32 0
@.str.1 = [17 x i8] c"bad file format\0A\00"
define i32 @parse_header(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %4, i32 3)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @LOG_ERR
%9 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %11
10: ; preds = %1
store i32 1, i32* %2
br label %11
11: ; preds = %10, %7
%12 = load i32, i32* %2
ret i32 %12
}

LLVM IR (-O2):
@.str = [5 x i8] c"KDB\0A\00"
@LOG_ERR = global i32 0
@.str.1 = [17 x i8] c"bad file format\0A\00"
define i32 @parse_header(i8* %0) {
%2 = tail call i64 @strncmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0, i32 3)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* @LOG_ERR
%6 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ 0, %4 ], [ 1, %1 ]
ret i32 %8
}
int Bematech_FI_CancelaImpressaoCheque(Retorno) {
  char Var[3];
  return Formata("\x1b|62|49|\x1b", Var, Retorno);
}


x86 assembly (clang, -O0):
<Bematech_FI_CancelaImpressaoCheque>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x7(%rbp),%rsi
mov    -0x4(%rbp),%edx
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <Formata@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Bematech_FI_CancelaImpressaoCheque>:
push   %rax
mov    %edi,%edx
lea    0xee6(%rip),%rdi
lea    0x5(%rsp),%rsi
xor    %eax,%eax
call   1030 <Formata@plt>
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\1B|62|49|\1B\00"
define i32 @Bematech_FI_CancelaImpressaoCheque(i32 %0) {
%2 = alloca i32
%3 = alloca [3 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %2
%6 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Formata to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %5)
ret i32 %6
}

LLVM IR (-O2):
@.str = [10 x i8] c"\1B|62|49|\1B\00"
define i32 @Bematech_FI_CancelaImpressaoCheque(i32 %0) {
%2 = alloca [3 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%4 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Formata to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %0)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int /*<<< orphan*/);
int handle_i2c(int fd) {
  const char *cmd = "i2c 40 write 02 read 2\n";
  write(fd, cmd, strlen(cmd));
  return 0;
}


x86 assembly (clang, -O0):
<handle_i2c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xece(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_i2c>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xed3(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [24 x i8] c"i2c 40 write 02 read 2\0A\00"
define i32 @handle_i2c(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i32, i32* %2
%5 = load i8*, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strlen(i8* %6)
%8 = call i32 @write(i32 %4, i8* %5, i32 %7)
ret i32 0
}

LLVM IR (-O2):
@.str = [24 x i8] c"i2c 40 write 02 read 2\0A\00"
define i32 @handle_i2c(i32 %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %2)
ret i32 0
}
/* Type definitions */
typedef int uint32_t;
typedef scalar_t__ uint16_t;

/* Variables and functions */
scalar_t__ read_word(int, int);
int /*<<< orphan*/ write_word(int, int, scalar_t__);
uint16_t ahci_mem_alloc(void) {
  uint16_t base_mem_kb;
  uint16_t ahci_seg;
  base_mem_kb = read_word(0x00, 0x0413);
  ;
  if (base_mem_kb == 0)
    return 0;
  base_mem_kb--;
  ahci_seg = (((uint32_t)base_mem_kb * 1024) >> 4);
  write_word(0x00, 0x0413, base_mem_kb);
  return ahci_seg;
}


x86 assembly (clang, -O0):
<ahci_mem_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %edi,%edi
mov    $0x413,%esi
call   1030 <read_word@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1150 <ahci_mem_alloc+0x30>
movq   $0x0,-0x8(%rbp)
jmp    1184 <ahci_mem_alloc+0x64>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0xa,%eax
sar    $0x4,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
xor    %edi,%edi
mov    $0x413,%esi
call   1040 <write_word@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ahci_mem_alloc>:
push   %rbx
xor    %ebx,%ebx
xor    %edi,%edi
mov    $0x413,%esi
call   1030 <read_word@plt>
test   %rax,%rax
je     114f <ahci_mem_alloc+0x2f>
add    $0xffffffffffffffff,%rax
mov    %eax,%ecx
shl    $0x6,%ecx
movslq %ecx,%rbx
xor    %edi,%edi
mov    $0x413,%esi
mov    %rax,%rdx
call   1040 <write_word@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i64 @ahci_mem_alloc() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = call i64 @read_word(i32 0, i32 1043)
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %0
store i64 0, i64* %1
br label %19
8: ; preds = %0
%9 = load i64, i64* %2
%10 = add nsw i64 %9, -1
store i64 %10, i64* %2
%11 = load i64, i64* %2
%12 = trunc i64 %11 to i32
%13 = mul nsw i32 %12, 1024
%14 = ashr i32 %13, 4
%15 = sext i32 %14 to i64
store i64 %15, i64* %3
%16 = load i64, i64* %2
%17 = call i32 @write_word(i32 0, i32 1043, i64 %16)
%18 = load i64, i64* %3
store i64 %18, i64* %1
br label %19
19: ; preds = %8, %7
%20 = load i64, i64* %1
ret i64 %20
}

LLVM IR (-O2):
define i64 @ahci_mem_alloc() {
%1 = tail call i64 @read_word(i32 0, i32 1043)
%2 = icmp eq i64 %1, 0
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = add nsw i64 %1, -1
%5 = trunc i64 %4 to i32
%6 = shl nsw i32 %5, 6
%7 = sext i32 %6 to i64
%8 = tail call i32 @write_word(i32 0, i32 1043, i64 %4)
br label %9
9: ; preds = %0, %3
%10 = phi i64 [ %7, %3 ], [ 0, %0 ]
ret i64 %10
}
/* Variables and functions */
int /*<<< orphan*/ shell_var_set_text(char *, char *);
void init_statements(void) {
  shell_var_set_text("path",
                     ".:/:/boot:/boot/bin:/amnt0:/amnt0/bin:/amnt1:/amnt1/bin:/"
                     "amnt2:/amnt2/bin:/amnt0/etc:/amnt1/etc:/amnt2/etc");
}


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

x86 assembly (clang, -O2):
<init_statements>:
lea    0xee9(%rip),%rdi
lea    0xee7(%rip),%rsi
jmp    1030 <shell_var_set_text@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"path\00"
@.str.1 = [107 x i8] c".:/:/boot:/boot/bin:/amnt0:/amnt0/bin:/amnt1:/amnt1/bin:/amnt2:/amnt2/bin:/amnt0/etc:/amnt1/etc:/amnt2/etc\00"
define void @init_statements() {
%1 = call i32 @shell_var_set_text(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"path\00"
@.str.1 = [107 x i8] c".:/:/boot:/boot/bin:/amnt0:/amnt0/bin:/amnt1:/amnt1/bin:/amnt2:/amnt2/bin:/amnt0/etc:/amnt1/etc:/amnt2/etc\00"
define void @init_statements() {
%1 = tail call i32 @shell_var_set_text(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef unsigned int uint32_t;

/* Variables and functions */
uint32_t _dl_hwcaps_subdirs_build_bitmask(int subdirs, int active) {
  int inactive = subdirs - active;
  if (inactive == 32)
    return 0;
  uint32_t mask;
  if (subdirs != 32)
    mask = (1 << subdirs) - 1;
  else
    mask = -1;
  return mask ^ ((1U << inactive) - 1);
}


x86 assembly (clang, -O0):
<_dl_hwcaps_subdirs_build_bitmask>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jne    1129 <_dl_hwcaps_subdirs_build_bitmask+0x29>
movl   $0x0,-0x4(%rbp)
jmp    1166 <_dl_hwcaps_subdirs_build_bitmask+0x66>
cmpl   $0x20,-0x8(%rbp)
je     1148 <_dl_hwcaps_subdirs_build_bitmask+0x48>
mov    -0x8(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114f <_dl_hwcaps_subdirs_build_bitmask+0x4f>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
sub    $0x1,%ecx
xor    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_dl_hwcaps_subdirs_build_bitmask>:
mov    %edi,%edx
sub    %esi,%edx
xor    %eax,%eax
cmp    $0x20,%edx
je     112a <_dl_hwcaps_subdirs_build_bitmask+0x2a>
mov    $0xffffffff,%r8d
mov    $0xffffffff,%esi
mov    %edi,%ecx
shl    %cl,%esi
mov    %edx,%ecx
shl    %cl,%r8d
xor    %eax,%eax
cmp    $0x20,%edi
cmovne %esi,%eax
xor    %r8d,%eax
ret

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

LLVM IR (-O2):
define i32 @_dl_hwcaps_subdirs_build_bitmask(i32 %0, i32 %1) {
%3 = sub nsw i32 %0, %1
%4 = icmp eq i32 %3, 32
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = icmp eq i32 %0, 32
%7 = shl nsw i32 -1, %0
%8 = shl nsw i32 -1, %3
%9 = select i1 %6, i32 0, i32 %7
%10 = xor i32 %9, %8
br label %11
11: ; preds = %2, %5
%12 = phi i32 [ %10, %5 ], [ 0, %2 ]
ret i32 %12
}
/* Variables and functions */
int /*<<< orphan*/ ems1Stok(char const *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void emsSetl(const char *token, int lvalue) {
  char str[200 + 1];
  ;
  if (lvalue)
    (void)strcpy(str, "TRUE");
  else
    (void)strcpy(str, "FALSE");
  ems1Stok(token, str);
  return;
}


x86 assembly (clang, -O0):
<emsSetl>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1154 <emsSetl+0x34>
lea    -0xe0(%rbp),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1167 <emsSetl+0x47>
lea    -0xe0(%rbp),%rdi
lea    0xea3(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <ems1Stok@plt>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emsSetl>:
push   %r14
push   %rbx
sub    $0xd8,%rsp
mov    %rdi,%rbx
test   %esi,%esi
lea    0xecf(%rip),%rax
lea    0xec3(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <ems1Stok@plt>
add    $0xd8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"TRUE\00"
@.str.1 = [6 x i8] c"FALSE\00"
define void @emsSetl(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [201 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = getelementptr inbounds [201 x i8], [201 x i8]* %5, i64 0, i64 0
%10 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %14
11: ; preds = %2
%12 = getelementptr inbounds [201 x i8], [201 x i8]* %5, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [201 x i8], [201 x i8]* %5, i64 0, i64 0
%17 = call i32 @ems1Stok(i8* %15, i8* %16)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"TRUE\00"
@.str.1 = [6 x i8] c"FALSE\00"
define void @emsSetl(i8* %0, i32 %1) {
%3 = alloca [201 x i8]
%4 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %1, 0
%6 = select i1 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%7 = call i32 @strcpy(i8* %4, i8* %6)
%8 = call i32 @ems1Stok(i8* %0, i8* %4)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ handle_58(int /*<<< orphan*/);
int gen_58() { handle_58(0); }


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

x86 assembly (clang, -O2):
<gen_58>:
xor    %edi,%edi
jmp    1030 <handle_58@plt>

LLVM IR (-O0):
define i32 @gen_58() {
%1 = alloca i32
%2 = call i32 @handle_58(i32 0)
%3 = load i32, i32* %1
ret i32 %3
}

LLVM IR (-O2):
define i32 @gen_58() {
%1 = tail call i32 @handle_58(i32 0)
ret i32 undef
}
int main() {
  char *s1[10];
  char *s2[10];
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @main() {
%1 = alloca [10 x i8*]
%2 = alloca [10 x i8*]
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  printf("HelloWorld\n");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [12 x i8] c"HelloWorld\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 ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [11 x i8] c"HelloWorld\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ strcpy(char *, char *);
int boom(char *argv[]) {
  char a[200];
  strcpy(a, argv[1]);
  return 1;
}


x86 assembly (clang, -O0):
<boom>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boom>:
sub    $0xc8,%rsp
mov    0x8(%rdi),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    $0x1,%eax
add    $0xc8,%rsp
ret

LLVM IR (-O0):
define i32 @boom(i8** %0) {
%2 = alloca i8**
%3 = alloca [200 x i8]
store i8** %0, i8*** %2
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = load i8**, i8*** %2
%6 = getelementptr inbounds i8*, i8** %5, i64 1
%7 = load i8*, i8** %6
%8 = call i32 @strcpy(i8* %4, i8* %7)
ret i32 1
}

LLVM IR (-O2):
define i32 @boom(i8** nocapture %0) {
%2 = alloca [200 x i8]
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8*, i8** %0, i64 1
%5 = load i8*, i8** %4
%6 = call i32 @strcpy(i8* %3, i8* %5)
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int pa_memblock_release() {
  printf("NOT IMPLEMENTED:"
         "pa_memblock_release"
         "\n");
}


x86 assembly (clang, -O0):
<pa_memblock_release>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [37 x i8] c"NOT IMPLEMENTED:pa_memblock_release\0A\00"
define i32 @pa_memblock_release() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* %1
ret i32 %3
}

LLVM IR (-O2):
@str = [36 x i8] c"NOT IMPLEMENTED:pa_memblock_release\00"
define i32 @pa_memblock_release() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
ret i32 undef
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *stdin;
FILE *__ghdl_get_stdin(void) { return stdin; }


x86 assembly (clang, -O0):
<__ghdl_get_stdin>:
push   %rbp
mov    %rsp,%rbp
mov    0x2edd(%rip),%rax
mov    (%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ghdl_get_stdin>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%rax
ret

LLVM IR (-O0):
@stdin = global i32* null
define i32* @__ghdl_get_stdin() {
%1 = load i32*, i32** @stdin
ret i32* %1
}

LLVM IR (-O2):
@stdin = global i32* null
define i32* @__ghdl_get_stdin() {
%1 = load i32*, i32** @stdin
ret i32* %1
}
/* Variables and functions */
int LOG_CONS;
int /*<<< orphan*/ LOG_DAEMON;
int LOG_PID;
int /*<<< orphan*/ openlog(char const *, int, int /*<<< orphan*/);
void log_open(const char *name) {
  openlog(name, LOG_PID | LOG_CONS, LOG_DAEMON);
}


x86 assembly (clang, -O0):
<log_open>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2eb1(%rip),%rax
mov    (%rax),%esi
mov    0x2ea0(%rip),%rax
or     (%rax),%esi
mov    0x2eaf(%rip),%rax
mov    (%rax),%edx
call   1030 <openlog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_open>:
mov    0x2ec1(%rip),%rax
mov    0x2eb2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2ebf(%rip),%rax
mov    (%rax),%edx
jmp    1030 <openlog@plt>

LLVM IR (-O0):
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
define void @log_open(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i32, i32* @LOG_PID
%5 = load i32, i32* @LOG_CONS
%6 = or i32 %4, %5
%7 = load i32, i32* @LOG_DAEMON
%8 = call i32 @openlog(i8* %3, i32 %6, i32 %7)
ret void
}

LLVM IR (-O2):
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_DAEMON = global i32 0
define void @log_open(i8* %0) {
%2 = load i32, i32* @LOG_PID
%3 = load i32, i32* @LOG_CONS
%4 = or i32 %3, %2
%5 = load i32, i32* @LOG_DAEMON
%6 = tail call i32 @openlog(i8* %0, i32 %4, i32 %5)
ret void
}
/* Variables and functions */
float sqrtf(float);
__attribute__((__weak__, __always___)) float softboundcets_sqrtf(float x) {
  return sqrtf(x);
}


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

x86 assembly (clang, -O2):
<softboundcets_sqrtf>:
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     111d <softboundcets_sqrtf+0xd>
sqrtss %xmm0,%xmm0
ret
jmp    1030 <sqrtf@plt>

LLVM IR (-O0):
define weak float @softboundcets_sqrtf(float %0) {
%2 = alloca float
store float %0, float* %2
%3 = load float, float* %2
%4 = call float @sqrtf(float %3)
ret float %4
}

LLVM IR (-O2):
define weak float @softboundcets_sqrtf(float %0) {
%2 = tail call float @sqrtf(float %0)
ret float %2
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
void bit_toggle(uint8_t *byte, uint8_t n) { *byte ^= 1 << n; }


x86 assembly (clang, -O0):
<bit_toggle>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
xor    (%rax),%ecx
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_toggle>:
mov    %esi,%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    %eax,(%rdi)
ret

LLVM IR (-O0):
define void @bit_toggle(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = shl i32 1, %5
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = xor i32 %8, %6
store i32 %9, i32* %7
ret void
}

LLVM IR (-O2):
define void @bit_toggle(i32* nocapture %0, i32 %1) {
%3 = shl nuw i32 1, %1
%4 = load i32, i32* %0
%5 = xor i32 %4, %3
store i32 %5, i32* %0
ret void
}
int binary(int a) {
  int n = 0;
  while (a != 0) {
    int temp = a % 2;
    a = a / 2;
    if (temp == 1)
      n++;
  }
  return n;
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     114c <binary+0x4c>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1147 <binary+0x47>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    110e <binary+0xe>
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
xor    %eax,%eax
test   %edi,%edi
je     1136 <binary+0x36>
cs nopw 0x0(%rax,%rax,1)
mov    %edi,%ecx
shr    $0x1f,%ecx
add    %edi,%ecx
mov    %ecx,%edx
sar    %edx
and    $0xfffffffe,%ecx
mov    %edi,%esi
sub    %ecx,%esi
xor    %ecx,%ecx
cmp    $0x1,%esi
sete   %cl
add    %ecx,%eax
add    $0x1,%edi
cmp    $0x2,%edi
mov    %edx,%edi
ja     1110 <binary+0x10>
ret

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

LLVM IR (-O2):
define i32 @binary(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %13, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %7, %3 ], [ %0, %1 ]
%5 = phi i32 [ %10, %3 ], [ 0, %1 ]
%6 = srem i32 %4, 2
%7 = sdiv i32 %4, 2
%8 = icmp eq i32 %6, 1
%9 = zext i1 %8 to i32
%10 = add nuw nsw i32 %5, %9
%11 = add i32 %4, 1
%12 = icmp ult i32 %11, 3
br i1 %12, label %13, label %3
13: ; preds = %3, %1
%14 = phi i32 [ 0, %1 ], [ %10, %3 ]
ret i32 %14
}
unsigned char get_inst(unsigned char c) { return c >> 5; }


x86 assembly (clang, -O0):
<get_inst>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
sar    $0x5,%eax
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_inst>:
mov    %edi,%eax
shr    $0x5,%al
ret

LLVM IR (-O0):
define zeroext i8 @get_inst(i8 zeroext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = ashr i32 %4, 5
%6 = trunc i32 %5 to i8
ret i8 %6
}

LLVM IR (-O2):
define zeroext i8 @get_inst(i8 zeroext %0) {
%2 = lshr i8 %0, 5
ret i8 %2
}
void uksm_cow_page(struct vm_area_struct *vma, struct page *page) {}


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

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

LLVM IR (-O0):
%struct.vm_area_struct = type opaque
%struct.page = type opaque
define void @uksm_cow_page(%struct.vm_area_struct* %0, %struct.page* %1) {
%3 = alloca %struct.vm_area_struct*
%4 = alloca %struct.page*
store %struct.vm_area_struct* %0, %struct.vm_area_struct** %3
store %struct.page* %1, %struct.page** %4
ret void
}

LLVM IR (-O2):
%struct.vm_area_struct = type opaque
%struct.page = type opaque
define void @uksm_cow_page(%struct.vm_area_struct* nocapture %0, %struct.page* nocapture %1) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ schedule_ra(int /*<<< orphan*/ *, int, int);
int setup_ra_socket();
int ra_setup() {
  int rc;
  rc = setup_ra_socket();
  if (rc < 0) {
    perror("setup_ra_socket");
    return rc;
  }
  schedule_ra(NULL, 1, 1);
  return 1;
}


x86 assembly (clang, -O0):
<ra_setup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <setup_ra_socket@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1163 <ra_setup+0x33>
lea    0xead(%rip),%rdi
call   1050 <perror@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117a <ra_setup+0x4a>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <schedule_ra@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ra_setup>:
push   %rbx
xor    %eax,%eax
call   1030 <setup_ra_socket@plt>
test   %eax,%eax
js     1156 <ra_setup+0x26>
mov    $0x1,%ebx
xor    %edi,%edi
mov    $0x1,%esi
mov    $0x1,%edx
call   1040 <schedule_ra@plt>
mov    %ebx,%eax
pop    %rbx
ret
mov    %eax,%ebx
lea    0xea1(%rip),%rdi
call   1050 <perror@plt>
jmp    1152 <ra_setup+0x22>

LLVM IR (-O0):
@.str = [16 x i8] c"setup_ra_socket\00"
define i32 @ra_setup() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @setup_ra_socket()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
store i32 %8, i32* %1
br label %11
9: ; preds = %0
%10 = call i32 @schedule_ra(i32* null, i32 1, i32 1)
store i32 1, i32* %1
br label %11
11: ; preds = %9, %6
%12 = load i32, i32* %1
ret i32 %12
}

LLVM IR (-O2):
@.str = [16 x i8] c"setup_ra_socket\00"
define i32 @ra_setup() {
%1 = tail call i32 (...) @setup_ra_socket()
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %7
5: ; preds = %0
%6 = tail call i32 @schedule_ra(i32* null, i32 1, i32 1)
br label %7
7: ; preds = %5, %3
%8 = phi i32 [ %1, %3 ], [ 1, %5 ]
ret i32 %8
}
/* Variables and functions */
char *convertTOchar(int);
int sceKernelLibcTime(void *);
char *getYear() {
  int tempy = sceKernelLibcTime((void *)0);
  int year = (tempy / 31536000) + 1970;
  static char *yr;
  yr = convertTOchar(year);
  return yr;
}


x86 assembly (clang, -O0):
<getYear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1030 <sceKernelLibcTime@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1e13380,%ecx
cltd
idiv   %ecx
add    $0x7b2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <convertTOchar@plt>
mov    %rax,0x2ee2(%rip)
mov    0x2edb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getYear>:
push   %rax
xor    %edi,%edi
call   1030 <sceKernelLibcTime@plt>
cltq
imul   $0x4418a47b,%rax,%rax
mov    %rax,%rcx
sar    $0x37,%rcx
shr    $0x3f,%rax
lea    (%rcx,%rax,1),%edi
add    $0x7b2,%edi
call   1040 <convertTOchar@plt>
mov    %rax,0x2ee7(%rip)
pop    %rcx
ret

LLVM IR (-O0):
@getYear.yr = internal global i8* null
define i8* @getYear() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @sceKernelLibcTime(i8* null)
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = sdiv i32 %4, 31536000
%6 = add nsw i32 %5, 1970
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = call i8* @convertTOchar(i32 %7)
store i8* %8, i8** @getYear.yr
%9 = load i8*, i8** @getYear.yr
ret i8* %9
}

LLVM IR (-O2):
@getYear.yr = internal unnamed_addr global i8* null
define i8* @getYear() {
%1 = tail call i32 @sceKernelLibcTime(i8* null)
%2 = sdiv i32 %1, 31536000
%3 = add nsw i32 %2, 1970
%4 = tail call i8* @convertTOchar(i32 %3)
store i8* %4, i8** @getYear.yr
ret i8* %4
}
/* Variables and functions */
char *strstr(char *, char *);
int searchstring(char searchstr[], char sourcestr[]) {
  char *ptrtostr;
  int foundat;
  foundat = -1;
  ptrtostr = strstr(sourcestr, searchstr);
  if (ptrtostr != NULL) {
    foundat = (int)((ptrtostr - sourcestr));
  }
  return foundat;
}


x86 assembly (clang, -O0):
<searchstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1151 <searchstring+0x41>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<searchstring>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
mov    %rbx,%rdi
call   1030 <strstr@plt>
mov    %eax,%ecx
sub    %ebx,%ecx
cmp    $0x1,%rax
sbb    %eax,%eax
or     %ecx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @searchstring(i8* nocapture %0, i8* %1) {
%3 = tail call i8* @strstr(i8* dereferenceable(1) %1, i8* dereferenceable(1) %0)
%4 = icmp eq i8* %3, null
%5 = ptrtoint i8* %3 to i64
%6 = ptrtoint i8* %1 to i64
%7 = sub i64 %5, %6
%8 = trunc i64 %7 to i32
%9 = select i1 %4, i32 -1, i32 %8
ret i32 %9
}
int bob_test_liba_test() {
  if (1337 != 1337)
    return -1;
  return 42;
}


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

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

LLVM IR (-O0):
define i32 @bob_test_liba_test() {
ret i32 42
}

LLVM IR (-O2):
define i32 @bob_test_liba_test() {
ret i32 42
}
int AKMemoryGetBit(unsigned char *data, int pos) {
  int posByte = pos / 8;
  int posBit = pos % 8;
  unsigned char valByte = data[posByte];
  int valInt = valByte >> (8 - (posBit + 1)) & 0x0001;
  return valInt;
}


x86 assembly (clang, -O0):
<AKMemoryGetBit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
movzbl -0x15(%rbp),%eax
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    $0x8,%ecx
sub    %edx,%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<AKMemoryGetBit>:
lea    0x7(%rsi),%eax
test   %esi,%esi
cmovns %esi,%eax
mov    %eax,%ecx
and    $0xfffffff8,%ecx
sub    %ecx,%esi
sar    $0x3,%eax
cltq
movzbl (%rdi,%rax,1),%eax
mov    $0x7,%cl
sub    %sil,%cl
shr    %cl,%eax
and    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @AKMemoryGetBit(i8* nocapture %0, i32 %1) {
%3 = sdiv i32 %1, 8
%4 = srem i32 %1, 8
%5 = sext i32 %3 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = sub nsw i32 7, %4
%10 = lshr i32 %8, %9
%11 = and i32 %10, 1
ret i32 %11
}
/* Type definitions */
typedef scalar_t__ uint32_t;

/* Variables and functions */
int is_null(uint32_t i) { return i == 0; }


x86 assembly (clang, -O0):
<is_null>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_null>:
xor    %eax,%eax
test   %rdi,%rdi
sete   %al
ret

LLVM IR (-O0):
define i32 @is_null(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp eq i64 %3, 0
%5 = zext i1 %4 to i32
ret i32 %5
}

LLVM IR (-O2):
define i32 @is_null(i64 %0) {
%2 = icmp eq i64 %0, 0
%3 = zext i1 %2 to i32
ret i32 %3
}
int mkstemp(char *template) {
  anvil_syslog(0, "%s unimplemented\n", __FUNCTION__);
  while (1)
    ;
  return 0;
}


x86 assembly (clang, -O0):
<mkstemp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %edi,%edi
lea    0xedb(%rip),%rsi
lea    0xee6(%rip),%rdx
mov    $0x0,%al
call   1030 <anvil_syslog@plt>
jmp    1133 <mkstemp+0x23>

x86 assembly (clang, -O2):
<mkstemp>:
push   %rax
lea    0xee8(%rip),%rsi
lea    0xef3(%rip),%rdx
xor    %edi,%edi
xor    %eax,%eax
call   1030 <anvil_syslog@plt>
nopl   0x0(%rax,%rax,1)
jmp    1130 <mkstemp+0x20>

LLVM IR (-O0):
@.str = [18 x i8] c"%s unimplemented\0A\00"
@__FUNCTION__.mkstemp = [8 x i8] c"mkstemp\00"
define i32 @mkstemp(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @anvil_syslog to i32 (i32, i8*, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__FUNCTION__.mkstemp, i64 0, i64 0))
br label %4
4: ; preds = %1, %4
br label %4
}

LLVM IR (-O2):
@.str = [18 x i8] c"%s unimplemented\0A\00"
@__FUNCTION__.mkstemp = [8 x i8] c"mkstemp\00"
define i32 @mkstemp(i8* nocapture readnone %0) {
%2 = tail call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @anvil_syslog to i32 (i32, i8*, i8*, ...)*)(i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__FUNCTION__.mkstemp, i64 0, i64 0))
br label %3
3: ; preds = %1, %3
br label %3
}
/* Type definitions */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
void time_now(struct timeval *tr) { gettimeofday(tr, NULL); }


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

x86 assembly (clang, -O2):
<time_now>:
xor    %esi,%esi
jmp    1030 <gettimeofday@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @time_now(%struct.timeval* %0) {
%2 = alloca %struct.timeval*
store %struct.timeval* %0, %struct.timeval** %2
%3 = load %struct.timeval*, %struct.timeval** %2
%4 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define void @time_now(%struct.timeval* nocapture %0) {
%2 = tail call i32 @gettimeofday(%struct.timeval* %0, i32* null)
ret void
}