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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
__attribute__((
    deprecated("use ut_string_match_prefix from ut_file_close"))) void
rs_file_close(FILE **file) {
  if (NULL == file || NULL == *file)
    return;
  fclose(*file);
  *file = NULL;
}


x86 assembly (clang, -O0):
<rs_file_close>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
je     1137 <rs_file_close+0x27>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%rax
jne    113c <rs_file_close+0x2c>
jmp    1153 <rs_file_close+0x43>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <fclose@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs_file_close>:
push   %rbx
test   %rdi,%rdi
je     112d <rs_file_close+0x1d>
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     112d <rs_file_close+0x1d>
call   1030 <fclose@plt>
movq   $0x0,(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @rs_file_close(i32** %0) {
%2 = icmp eq i32** %0, null
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = load i32*, i32** %0
%5 = icmp eq i32* %4, null
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @fclose(i32* %4)
store i32* null, i32** %0
br label %8
8: ; preds = %1, %3, %6
ret void
}
/* Variables and functions */
int syscall_getpid();
int getpid() { return syscall_getpid(); }


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

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

LLVM IR (-O0):
define i32 @getpid() {
%1 = call i32 (...) @syscall_getpid()
ret i32 %1
}

LLVM IR (-O2):
define i32 @getpid() {
%1 = tail call i32 (...) @syscall_getpid()
ret i32 %1
}
/* Type definitions */
typedef int uint8_t;

/* Variables and functions */
uint8_t *deserialize_int(uint8_t *serialbuf, int *val) {
  *val = (serialbuf[0] << 24) | (serialbuf[1] << 16) | (serialbuf[2] << 8) |
         serialbuf[3];
  return serialbuf + 4;
}


x86 assembly (clang, -O0):
<deserialize_int>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
shl    $0x18,%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x10,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
shl    $0x8,%eax
or     %eax,%ecx
mov    -0x8(%rbp),%rax
or     0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<deserialize_int>:
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
shl    $0x18,%eax
shl    $0x10,%ecx
or     %eax,%ecx
mov    0x8(%rdi),%eax
shl    $0x8,%eax
or     %ecx,%eax
or     0xc(%rdi),%eax
mov    %eax,(%rsi)
lea    0x10(%rdi),%rax
ret

LLVM IR (-O0):
define i32* @deserialize_int(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 = getelementptr inbounds i32, i32* %5, i64 0
%7 = load i32, i32* %6
%8 = shl i32 %7, 24
%9 = load i32*, i32** %3
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = load i32, i32* %10
%12 = shl i32 %11, 16
%13 = or i32 %8, %12
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 2
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = or i32 %13, %17
%19 = load i32*, i32** %3
%20 = getelementptr inbounds i32, i32* %19, i64 3
%21 = load i32, i32* %20
%22 = or i32 %18, %21
%23 = load i32*, i32** %4
store i32 %22, i32* %23
%24 = load i32*, i32** %3
%25 = getelementptr inbounds i32, i32* %24, i64 4
ret i32* %25
}

LLVM IR (-O2):
define i32* @deserialize_int(i32* %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* %0
%4 = shl i32 %3, 24
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = load i32, i32* %5
%7 = shl i32 %6, 16
%8 = or i32 %7, %4
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = shl i32 %10, 8
%12 = or i32 %8, %11
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %13
%15 = or i32 %12, %14
store i32 %15, i32* %1
%16 = getelementptr inbounds i32, i32* %0, i64 4
ret i32* %16
}
int triggerGenRestore(struct LSD_SceneNodeInst const *inst, void *instData) {
  int *castData = (int *)instData;
  *castData = 0;
  return 0;
}


x86 assembly (clang, -O0):
<triggerGenRestore>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<triggerGenRestore>:
movl   $0x0,(%rsi)
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct.LSD_SceneNodeInst = type opaque
define i32 @triggerGenRestore(%struct.LSD_SceneNodeInst* %0, i8* %1) {
%3 = alloca %struct.LSD_SceneNodeInst*
%4 = alloca i8*
%5 = alloca i32*
store %struct.LSD_SceneNodeInst* %0, %struct.LSD_SceneNodeInst** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = bitcast i8* %6 to i32*
store i32* %7, i32** %5
%8 = load i32*, i32** %5
store i32 0, i32* %8
ret i32 0
}

LLVM IR (-O2):
%struct.LSD_SceneNodeInst = type opaque
define i32 @triggerGenRestore(%struct.LSD_SceneNodeInst* nocapture readnone %0, i8* nocapture writeonly %1) {
%3 = bitcast i8* %1 to i32*
store i32 0, i32* %3
ret i32 0
}
int main(int argc, char const *argv[]) { return (int)argv[1]; }


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    0x8(%rsi),%eax
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 i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 1
%8 = load i8*, i8** %7
%9 = ptrtoint i8* %8 to i32
ret i32 %9
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = ptrtoint i8* %4 to i64
%6 = trunc i64 %5 to i32
ret i32 %6
}
/* Variables and functions */
double sin(double);
double asin(double x) { return -sin(x); }


x86 assembly (clang, -O0):
<asin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asin>:
push   %rax
call   1030 <sin@plt>
xorps  0xee3(%rip),%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
define double @asin(double %0) {
%2 = tail call double @sin(double %0)
%3 = fneg double %2
ret double %3
}
double id(double x) { return x; }


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

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

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

LLVM IR (-O2):
define double @id(double returned %0) {
ret double %0
}
int test_imm_EDuint64_midword_mem(unsigned long long *val) {
  return ((*val >> 16) & (0xED << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_EDuint64_midword_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
shr    $0x10,%rdx
and    $0xed,%rdx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_EDuint64_midword_mem>:
testb  $0xed,0x2(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_EDuint64_midword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 15532032
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
scalar_t__ UARTCharGet(int);
int bwgetc() { return (int)UARTCharGet(((0x44E09000))); }


x86 assembly (clang, -O0):
<bwgetc>:
push   %rbp
mov    %rsp,%rbp
mov    $0x44e09000,%edi
call   1030 <UARTCharGet@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<bwgetc>:
mov    $0x44e09000,%edi
jmp    1030 <UARTCharGet@plt>

LLVM IR (-O0):
define i32 @bwgetc() {
%1 = call i64 @UARTCharGet(i32 1155567616)
%2 = trunc i64 %1 to i32
ret i32 %2
}

LLVM IR (-O2):
define i32 @bwgetc() {
%1 = tail call i64 @UARTCharGet(i32 1155567616)
%2 = trunc i64 %1 to i32
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ preload_seq(int);
void main(void) { preload_seq(167); }


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0xa7,%edi
call   1030 <preload_seq@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0xa7,%edi
jmp    1030 <preload_seq@plt>

LLVM IR (-O0):
define void @main() {
%1 = call i32 @preload_seq(i32 167)
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @preload_seq(i32 167)
ret void
}
unsigned f4(unsigned long c, int shamt) { return 1U << (c << shamt); }


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

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

LLVM IR (-O0):
define i32 @f4(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
%5 = load i64, i64* %3
%6 = load i32, i32* %4
%7 = zext i32 %6 to i64
%8 = shl i64 %5, %7
%9 = trunc i64 %8 to i32
%10 = shl i32 1, %9
ret i32 %10
}

LLVM IR (-O2):
define i32 @f4(i64 %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = shl i64 %0, %3
%5 = trunc i64 %4 to i32
%6 = shl nuw i32 1, %5
ret i32 %6
}
/* Variables and functions */
unsigned int atomic_decrement_val(unsigned int volatile *);
unsigned int atomic_dec_uint_nv(volatile unsigned int *target) {
  return atomic_decrement_val(target) - 1;
}


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

x86 assembly (clang, -O2):
<atomic_dec_uint_nv>:
push   %rax
call   1030 <atomic_decrement_val@plt>
add    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @atomic_dec_uint_nv(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @atomic_decrement_val(i32* %3)
%5 = sub i32 %4, 1
ret i32 %5
}

LLVM IR (-O2):
define i32 @atomic_dec_uint_nv(i32* %0) {
%2 = tail call i32 @atomic_decrement_val(i32* %0)
%3 = add i32 %2, -1
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ readPWM(int /*<<< orphan*/);
void PWM_ISR_0() { readPWM(0); }


x86 assembly (clang, -O0):
<PWM_ISR_0>:
push   %rbp
mov    %rsp,%rbp
xor    %edi,%edi
call   1030 <readPWM@plt>
pop    %rbp
ret

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

LLVM IR (-O0):
define void @PWM_ISR_0() {
%1 = call i32 @readPWM(i32 0)
ret void
}

LLVM IR (-O2):
define void @PWM_ISR_0() {
%1 = tail call i32 @readPWM(i32 0)
ret void
}
/* Type definitions */
struct timespec {
  int dummy;
};
typedef int /*<<< orphan*/ clockid_t;

/* Variables and functions */
int /*<<< orphan*/ SYS_clock_gettime;
long errno;
long syscall(int /*<<< orphan*/, int /*<<< orphan*/, struct timespec *);
int clock_gettime(clockid_t clk_id, struct timespec *tp) {
  long rv = syscall(SYS_clock_gettime, clk_id, tp);
  if (rv < 0) {
    errno = -rv;
    return -1;
  }
  return rv;
}


x86 assembly (clang, -O0):
<clock_gettime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2eca(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1030 <syscall@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    1161 <clock_gettime+0x51>
xor    %eax,%eax
mov    %eax,%ecx
sub    -0x18(%rbp),%rcx
mov    0x2e86(%rip),%rax
mov    %rcx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    1168 <clock_gettime+0x58>
mov    -0x18(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clock_gettime>:
push   %rax
mov    %rsi,%rdx
mov    %edi,%esi
mov    0x2ed3(%rip),%rax
mov    (%rax),%edi
call   1030 <syscall@plt>
test   %rax,%rax
js     112b <clock_gettime+0x1b>
pop    %rcx
ret
neg    %rax
mov    0x2ea3(%rip),%rcx
mov    %rax,(%rcx)
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timespec = type { i32 }
@SYS_clock_gettime = global i32 0
@errno = global i64 0
define i32 @clock_gettime(i32 %0, %struct.timespec* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca %struct.timespec*
%6 = alloca i64
store i32 %0, i32* %4
store %struct.timespec* %1, %struct.timespec** %5
%7 = load i32, i32* @SYS_clock_gettime
%8 = load i32, i32* %4
%9 = load %struct.timespec*, %struct.timespec** %5
%10 = call i64 @syscall(i32 %7, i32 %8, %struct.timespec* %9)
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i64, i64* %6
%15 = sub nsw i64 0, %14
store i64 %15, i64* @errno
store i32 -1, i32* %3
br label %19
16: ; preds = %2
%17 = load i64, i64* %6
%18 = trunc i64 %17 to i32
store i32 %18, i32* %3
br label %19
19: ; preds = %16, %13
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
%struct.timespec = type { i32 }
@SYS_clock_gettime = global i32 0
@errno = global i64 0
define i32 @clock_gettime(i32 %0, %struct.timespec* %1) {
%3 = load i32, i32* @SYS_clock_gettime
%4 = tail call i64 @syscall(i32 %3, i32 %0, %struct.timespec* %1)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = sub nsw i64 0, %4
store i64 %7, i64* @errno
br label %10
8: ; preds = %2
%9 = trunc i64 %4 to i32
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ -1, %6 ], [ %9, %8 ]
ret i32 %11
}
int SetSocketTypeOfService(const int fd __attribute__((__unused__)),
                           const int tosType __attribute__((__unused__))) {
  ;
  ;
  return (-1);
}


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

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

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

LLVM IR (-O2):
define i32 @SetSocketTypeOfService(i32 %0, i32 %1) {
ret i32 -1
}
/* Variables and functions */
size_t _span_class_from_page_count(size_t page_count) {
  ;
  return ((page_count + 4 - 1) / 4) - 1;
}


x86 assembly (clang, -O0):
<_span_class_from_page_count>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
sub    $0x1,%rax
shr    $0x2,%rax
sub    $0x1,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_span_class_from_page_count>:
lea    0x3(%rdi),%rax
shr    $0x2,%rax
add    $0xffffffffffffffff,%rax
ret

LLVM IR (-O0):
define i64 @_span_class_from_page_count(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = add i64 %3, 4
%5 = sub i64 %4, 1
%6 = udiv i64 %5, 4
%7 = sub i64 %6, 1
ret i64 %7
}

LLVM IR (-O2):
define i64 @_span_class_from_page_count(i64 %0) {
%2 = add i64 %0, 3
%3 = lshr i64 %2, 2
%4 = add nsw i64 %3, -1
ret i64 %4
}
int foo(int *f) { return *f; }


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

x86 assembly (clang, -O2):
<foo>:
mov    (%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 = load i32, i32* %3
ret i32 %4
}

LLVM IR (-O2):
define i32 @foo(i32* nocapture %0) {
%2 = load i32, i32* %0
ret i32 %2
}
/* Variables and functions */
long syscall(int, int, unsigned long, unsigned long const *,
             unsigned long const *);
long migrate_pages(int pid, unsigned long maxnode,
                   const unsigned long *frommask, const unsigned long *tomask) {
  return syscall(256, pid, maxnode, frommask, tomask);
}


x86 assembly (clang, -O0):
<migrate_pages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    $0x100,%edi
call   1030 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<migrate_pages>:
mov    %rcx,%r8
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %edi,%esi
mov    $0x100,%edi
jmp    1030 <syscall@plt>

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

LLVM IR (-O2):
define i64 @migrate_pages(i32 %0, i64 %1, i64* %2, i64* %3) {
%5 = tail call i64 @syscall(i32 256, i32 %0, i64 %1, i64* %2, i64* %3)
ret i64 %5
}
int test_imm_BFuint8_mem(unsigned char *val) {
  return ((*val) & (0xBF << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_BFuint8_mem>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%edx
and    $0xbf,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_BFuint8_mem>:
testb  $0xbf,(%rdi)
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_BFuint8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = and i8 %2, -65
%4 = icmp eq i8 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
void close_descriptor(int *i) {
  if (*i != -1) {
    close(*i);
  }
}


x86 assembly (clang, -O0):
<close_descriptor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0xffffffff,(%rax)
je     1134 <close_descriptor+0x24>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <close@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<close_descriptor>:
mov    (%rdi),%edi
cmp    $0xffffffff,%edi
je     111c <close_descriptor+0xc>
jmp    1030 <close@plt>
ret

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

LLVM IR (-O2):
define void @close_descriptor(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, -1
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @close(i32 %2)
br label %6
6: ; preds = %4, %1
ret void
}
long add_long(long x, long y) { return x + y; }


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

x86 assembly (clang, -O2):
<add_long>:
lea    (%rdi,%rsi,1),%rax
ret

LLVM IR (-O0):
define i64 @add_long(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = load i64, i64* %4
%7 = add nsw i64 %5, %6
ret i64 %7
}

LLVM IR (-O2):
define i64 @add_long(i64 %0, i64 %1) {
%3 = add nsw i64 %1, %0
ret i64 %3
}
/* Type definitions */
struct SN_env {
  int dummy;
};

/* Variables and functions */
struct SN_env *SN_create_env(int /*<<< orphan*/, int, int /*<<< orphan*/);
extern struct SN_env *portuguese_UTF_8_create_env(void) {
  return SN_create_env(0, 3, 0);
}


x86 assembly (clang, -O0):
<portuguese_UTF_8_create_env>:
push   %rbp
mov    %rsp,%rbp
xor    %edx,%edx
mov    $0x3,%esi
mov    %edx,%edi
call   1030 <SN_create_env@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<portuguese_UTF_8_create_env>:
xor    %edi,%edi
mov    $0x3,%esi
xor    %edx,%edx
jmp    1030 <SN_create_env@plt>

LLVM IR (-O0):
%struct.SN_env = type { i32 }
define %struct.SN_env* @portuguese_UTF_8_create_env() {
%1 = call %struct.SN_env* @SN_create_env(i32 0, i32 3, i32 0)
ret %struct.SN_env* %1
}

LLVM IR (-O2):
%struct.SN_env = type { i32 }
define %struct.SN_env* @portuguese_UTF_8_create_env() {
%1 = tail call %struct.SN_env* @SN_create_env(i32 0, i32 3, i32 0)
ret %struct.SN_env* %1
}
/* Variables and functions */
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ system(char *);
int edit_loader_conf(void) {
  endwin();
  system(" /usr/bin/ee "
         " /boot/loader.conf");
  return 0;
}


x86 assembly (clang, -O0):
<edit_loader_conf>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <endwin@plt>
lea    0xece(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<edit_loader_conf>:
push   %rax
xor    %eax,%eax
call   1040 <endwin@plt>
lea    0xed1(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [32 x i8] c" /usr/bin/ee /boot/loader.conf\00"
define i32 @edit_loader_conf() {
%1 = call i32 (...) @endwin()
%2 = call i32 @system(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [32 x i8] c" /usr/bin/ee /boot/loader.conf\00"
define i32 @edit_loader_conf() {
%1 = tail call i32 (...) @endwin()
%2 = tail call i32 @system(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
ret i32 0
}
int test_validate_pack() { return 100; }


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

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

LLVM IR (-O0):
define i32 @test_validate_pack() {
ret i32 100
}

LLVM IR (-O2):
define i32 @test_validate_pack() {
ret i32 100
}
/* Variables and functions */
int /*<<< orphan*/ LOG_INFO;
int LOG_NDELAY;
int LOG_PID;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char const *);
void logmsg(const char *msg) {
  openlog("firejail", LOG_NDELAY | LOG_PID, LOG_USER);
  syslog(LOG_INFO, "%s\n", msg);
  closelog();
}


x86 assembly (clang, -O0):
<logmsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    0x2e8c(%rip),%rax
or     (%rax),%esi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
lea    0xea2(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe92(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logmsg>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e85(%rip),%rax
mov    0x2e96(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdx
call   1040 <syslog@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"firejail\00"
@LOG_NDELAY = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define void @logmsg(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @LOG_NDELAY
%4 = load i32, i32* @LOG_PID
%5 = or i32 %3, %4
%6 = load i32, i32* @LOG_USER
%7 = call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* @LOG_INFO
%9 = load i8*, i8** %2
%10 = call i32 @syslog(i32 %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"firejail\00"
@LOG_NDELAY = global i32 0
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
define void @logmsg(i8* %0) {
%2 = load i32, i32* @LOG_NDELAY
%3 = load i32, i32* @LOG_PID
%4 = or i32 %3, %2
%5 = load i32, i32* @LOG_USER
%6 = tail call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
%7 = load i32, i32* @LOG_INFO
%8 = tail call i32 @syslog(i32 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = tail call i32 (...) @closelog()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char const *, int);
int read_chunk(const char *ptr, char *buffer, int size) {
  memcpy(buffer, ptr, size);
  return size;
}


x86 assembly (clang, -O0):
<read_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_chunk>:
push   %rbx
mov    %edx,%ebx
mov    %rdi,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <memcpy@plt>
mov    %ebx,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @read_chunk(i8* %0, i8* %1, i32 returned %2) {
%4 = tail call i32 @memcpy(i8* %1, i8* %0, i32 %2)
ret i32 %2
}
int test_imm_C7uint8_reg(unsigned char val) {
  return ((val) & (-0xC7 << 0)) ? -20 : -40;
}


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

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

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

LLVM IR (-O2):
define i32 @test_imm_C7uint8_reg(i8 zeroext %0) {
%2 = and i8 %0, 57
%3 = icmp eq i8 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
/* Type definitions */
struct iovec {
  int dummy;
};
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ __NR_writev;
int /*<<< orphan*/ syscall(int /*<<< orphan*/, int, struct iovec const *, int);
__attribute__((always_)) ssize_t
_syscall_writev(int fd, const struct iovec *iov, int iovcnt) {
  return syscall(__NR_writev, fd, iov, iovcnt);
}


x86 assembly (clang, -O0):
<_syscall_writev>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    0x2eb7(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
call   1030 <syscall@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_syscall_writev>:
mov    %edx,%ecx
mov    %rsi,%rdx
mov    %edi,%esi
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
%struct.iovec = type { i32 }
@__NR_writev = global i32 0
define i32 @_syscall_writev(i32 %0, %struct.iovec* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.iovec*
%6 = alloca i32
store i32 %0, i32* %4
store %struct.iovec* %1, %struct.iovec** %5
store i32 %2, i32* %6
%7 = load i32, i32* @__NR_writev
%8 = load i32, i32* %4
%9 = load %struct.iovec*, %struct.iovec** %5
%10 = load i32, i32* %6
%11 = call i32 @syscall(i32 %7, i32 %8, %struct.iovec* %9, i32 %10)
ret i32 %11
}

LLVM IR (-O2):
%struct.iovec = type { i32 }
@__NR_writev = global i32 0
define i32 @_syscall_writev(i32 %0, %struct.iovec* %1, i32 %2) {
%4 = load i32, i32* @__NR_writev
%5 = tail call i32 @syscall(i32 %4, i32 %0, %struct.iovec* %1, i32 %2)
ret i32 %5
}
/* Variables and functions */
scalar_t__ log10(double);
int digits(int x) { return (int)log10((double)x) + 1; }


x86 assembly (clang, -O0):
<digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
call   1030 <log10@plt>
add    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digits>:
push   %rax
cvtsi2sd %edi,%xmm0
call   1030 <log10@plt>
add    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @digits(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sitofp i32 %3 to double
%5 = call i64 @log10(double %4)
%6 = trunc i64 %5 to i32
%7 = add nsw i32 %6, 1
ret i32 %7
}

LLVM IR (-O2):
define i32 @digits(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = tail call i64 @log10(double %2)
%4 = trunc i64 %3 to i32
%5 = add nsw i32 %4, 1
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ CG_WeaponIndex(int, int *, int *);
int getNextWeapInBank(int, int);
int getNextWeapInBankBynum(int weapnum) {
  int bank, cycle;
  if (!CG_WeaponIndex(weapnum, &bank, &cycle)) {
    return weapnum;
  }
  return getNextWeapInBank(bank, cycle);
}


x86 assembly (clang, -O0):
<getNextWeapInBankBynum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1040 <CG_WeaponIndex@plt>
cmp    $0x0,%eax
jne    114f <getNextWeapInBankBynum+0x2f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115d <getNextWeapInBankBynum+0x3d>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <getNextWeapInBank@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getNextWeapInBankBynum>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <CG_WeaponIndex@plt>
test   %eax,%eax
je     1149 <getNextWeapInBankBynum+0x29>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
call   1030 <getNextWeapInBank@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @getNextWeapInBankBynum(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 @CG_WeaponIndex(i32 %6, i32* %4, i32* %5)
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = load i32, i32* %3
store i32 %10, i32* %2
br label %15
11: ; preds = %1
%12 = load i32, i32* %4
%13 = load i32, i32* %5
%14 = call i32 @getNextWeapInBank(i32 %12, i32 %13)
store i32 %14, i32* %2
br label %15
15: ; preds = %11, %9
%16 = load i32, i32* %2
ret i32 %16
}

LLVM IR (-O2):
define i32 @getNextWeapInBankBynum(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i32 @CG_WeaponIndex(i32 %0, i32* %2, i32* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 @getNextWeapInBank(i32 %9, i32 %10)
br label %12
12: ; preds = %1, %8
%13 = phi i32 [ %11, %8 ], [ %0, %1 ]
ret i32 %13
}
/* Variables and functions */
int /*<<< orphan*/ func4();
void func3(void) { func4(); }


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

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

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

LLVM IR (-O2):
define void @func3() {
%1 = tail call i32 (...) @func4()
ret void
}
/* Variables and functions */
size_t MEMPOOL_BLOCK_QUANTIFY(size_t x) {
  size_t bs = (1 << 8) * (8 * sizeof(size_t));
  int n = (int)((x + bs - 1) / bs);
  return n * ((8 * sizeof(size_t))) * (1 << (8));
}


x86 assembly (clang, -O0):
<MEMPOOL_BLOCK_QUANTIFY>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x4000,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
sub    $0x1,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x6,%rax
shl    $0x8,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<MEMPOOL_BLOCK_QUANTIFY>:
shl    $0x12,%rdi
mov    $0xfffc0000,%eax
add    %rdi,%rax
sar    $0x12,%rax
and    $0xffffffffffffc000,%rax
ret

LLVM IR (-O0):
define i64 @MEMPOOL_BLOCK_QUANTIFY(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %2
store i64 16384, i64* %3
%5 = load i64, i64* %2
%6 = load i64, i64* %3
%7 = add i64 %5, %6
%8 = sub i64 %7, 1
%9 = load i64, i64* %3
%10 = udiv i64 %8, %9
%11 = trunc i64 %10 to i32
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 64
%15 = mul i64 %14, 256
ret i64 %15
}

LLVM IR (-O2):
define i64 @MEMPOOL_BLOCK_QUANTIFY(i64 %0) {
%2 = shl i64 %0, 18
%3 = add i64 %2, 4294705152
%4 = ashr exact i64 %3, 18
%5 = and i64 %4, -16384
ret i64 %5
}
/* Type definitions */
typedef unsigned char uint16_t;

/* Variables and functions */
uint16_t get_uint16(unsigned char *data, int offset) {
  uint16_t temp;
  temp = data[offset] | (data[offset + 1] << 8);
  return temp;
}


x86 assembly (clang, -O0):
<get_uint16>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
mov    -0x8(%rbp),%rcx
mov    -0xc(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %al,-0xd(%rbp)
movzbl -0xd(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_uint16>:
movslq %esi,%rax
mov    (%rdi,%rax,1),%al
ret

LLVM IR (-O0):
define zeroext i8 @get_uint16(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 8
%20 = or i32 %11, %19
%21 = trunc i32 %20 to i8
store i8 %21, i8* %5
%22 = load i8, i8* %5
ret i8 %22
}

LLVM IR (-O2):
define zeroext i8 @get_uint16(i8* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
ret i8 %5
}
/* Variables and functions */
scalar_t__ malloc(int);
int *string() {
  int *p = (int *)malloc(5 * sizeof(int));
  p[0] = 1;
  p[1] = 2;
  p[2] = 3;
  p[3] = 4;
  p[4] = 0;
  return p;
}


x86 assembly (clang, -O0):
<string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x14,%edi
call   1030 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3,0x8(%rax)
mov    -0x8(%rbp),%rax
movl   $0x4,0xc(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,0x10(%rax)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string>:
push   %rax
mov    $0x14,%edi
call   1030 <malloc@plt>
movaps 0xede(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x0,0x10(%rax)
pop    %rcx
ret

LLVM IR (-O0):
define i32* @string() {
%1 = alloca i32*
%2 = call i64 @malloc(i32 20)
%3 = inttoptr i64 %2 to i32*
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = getelementptr inbounds i32, i32* %4, i64 0
store i32 1, i32* %5
%6 = load i32*, i32** %1
%7 = getelementptr inbounds i32, i32* %6, i64 1
store i32 2, i32* %7
%8 = load i32*, i32** %1
%9 = getelementptr inbounds i32, i32* %8, i64 2
store i32 3, i32* %9
%10 = load i32*, i32** %1
%11 = getelementptr inbounds i32, i32* %10, i64 3
store i32 4, i32* %11
%12 = load i32*, i32** %1
%13 = getelementptr inbounds i32, i32* %12, i64 4
store i32 0, i32* %13
%14 = load i32*, i32** %1
ret i32* %14
}

LLVM IR (-O2):
define i32* @string() {
%1 = tail call i64 @malloc(i32 20)
%2 = inttoptr i64 %1 to i32*
%3 = inttoptr i64 %1 to <4 x i32>*
store <4 x i32> <i32 1, i32 2, i32 3, i32 4>, <4 x i32>* %3
%4 = getelementptr inbounds i32, i32* %2, i64 4
store i32 0, i32* %4
ret i32* %2
}
/* Type definitions */
typedef int uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
void st103_set_epreg(uint8_t ep_num, uint16_t value) {
  uint16_t *reg_p = (uint16_t *)((0x40005C00UL) + ep_num * 4);
  *reg_p = value;
}


x86 assembly (clang, -O0):
<st103_set_epreg>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
cltq
add    $0x40005c00,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<st103_set_epreg>:
movslq %edi,%rax
mov    %esi,0x40005c00(,%rax,4)
ret

LLVM IR (-O0):
define void @st103_set_epreg(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = mul nsw i32 %6, 4
%8 = sext i32 %7 to i64
%9 = add i64 1073765376, %8
%10 = inttoptr i64 %9 to i32*
store i32* %10, i32** %5
%11 = load i32, i32* %4
%12 = load i32*, i32** %5
store i32 %11, i32* %12
ret void
}

LLVM IR (-O2):
define void @st103_set_epreg(i32 %0, i32 %1) {
%3 = shl nsw i32 %0, 2
%4 = sext i32 %3 to i64
%5 = add nsw i64 %4, 1073765376
%6 = inttoptr i64 %5 to i32*
store i32 %1, i32* %6
ret void
}
/* Variables and functions */
double fabs(double);
double t4(double x) { return fabs(x); }


x86 assembly (clang, -O0):
<t4>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xeeb(%rip),%xmm1
pand   %xmm1,%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<t4>:
andps  0xef9(%rip),%xmm0
ret

LLVM IR (-O0):
define double @t4(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = call double @llvm.fabs.f64(double %3)
ret double %4
}

LLVM IR (-O2):
define double @t4(double %0) {
%2 = tail call double @llvm.fabs.f64(double %0)
ret double %2
}
/* Variables and functions */
int fred(int, int);
int /*<<< orphan*/ printn(int);
void main() {
  int x;
  x = fred(4, 5);
  printn(x);
  x = fred(2, 6);
  printn(x);
  x = fred(1, 1);
  printn(x);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
mov    $0x5,%esi
call   1040 <fred@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <printn@plt>
mov    $0x2,%edi
mov    $0x6,%esi
call   1040 <fred@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <printn@plt>
mov    $0x1,%esi
mov    %esi,%edi
call   1040 <fred@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <printn@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x4,%edi
mov    $0x5,%esi
call   1040 <fred@plt>
mov    %eax,%edi
call   1030 <printn@plt>
mov    $0x2,%edi
mov    $0x6,%esi
call   1040 <fred@plt>
mov    %eax,%edi
call   1030 <printn@plt>
mov    $0x1,%edi
mov    $0x1,%esi
call   1040 <fred@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <printn@plt>

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = call i32 @fred(i32 4, i32 5)
store i32 %2, i32* %1
%3 = load i32, i32* %1
%4 = call i32 @printn(i32 %3)
%5 = call i32 @fred(i32 2, i32 6)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = call i32 @printn(i32 %6)
%8 = call i32 @fred(i32 1, i32 1)
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = call i32 @printn(i32 %9)
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @fred(i32 4, i32 5)
%2 = tail call i32 @printn(i32 %1)
%3 = tail call i32 @fred(i32 2, i32 6)
%4 = tail call i32 @printn(i32 %3)
%5 = tail call i32 @fred(i32 1, i32 1)
%6 = tail call i32 @printn(i32 %5)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int expensive_function(int y) {
  printf("very expensive identity\n");
  return y;
}


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

x86 assembly (clang, -O2):
<expensive_function>:
push   %rbx
mov    %edi,%ebx
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"very expensive identity\0A\00"
define i32 @expensive_function(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
ret i32 %4
}

LLVM IR (-O2):
@str = [24 x i8] c"very expensive identity\00"
define i32 @expensive_function(i32 returned %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
ret i32 %0
}
/* Variables and functions */
int foo(int *, int *);
int moo(int *, int *);
int main() {
  int a = 1, b = 2;
  int *p = &a;
  int *q = &b;
  int *c = q;
  *q = foo(&a, &b);
  *p = moo(p, c);
  moo(p, c);
  return 1 / a;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <foo@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <moo@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <moo@plt>
mov    $0x1,%eax
cltd
idivl  -0x8(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x1,(%rsp)
movl   $0x2,0x4(%rsp)
mov    %rsp,%rbx
lea    0x4(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <foo@plt>
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <moo@plt>
mov    %eax,(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <moo@plt>
mov    (%rsp),%ecx
lea    0x1(%rcx),%edx
xor    %eax,%eax
cmp    $0x3,%edx
cmovb  %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32 0, i32* %1
store i32 1, i32* %2
store i32 2, i32* %3
store i32* %2, i32** %4
store i32* %3, i32** %5
%7 = load i32*, i32** %5
store i32* %7, i32** %6
%8 = call i32 @foo(i32* %2, i32* %3)
%9 = load i32*, i32** %5
store i32 %8, i32* %9
%10 = load i32*, i32** %4
%11 = load i32*, i32** %6
%12 = call i32 @moo(i32* %10, i32* %11)
%13 = load i32*, i32** %4
store i32 %12, i32* %13
%14 = load i32*, i32** %4
%15 = load i32*, i32** %6
%16 = call i32 @moo(i32* %14, i32* %15)
%17 = load i32, i32* %2
%18 = sdiv i32 1, %17
ret i32 %18
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 2, i32* %2
%5 = call i32 @foo(i32* %1, i32* %2)
store i32 %5, i32* %2
%6 = call i32 @moo(i32* %1, i32* %2)
store i32 %6, i32* %1
%7 = call i32 @moo(i32* %1, i32* %2)
%8 = load i32, i32* %1
%9 = add i32 %8, 1
%10 = icmp ult i32 %9, 3
%11 = select i1 %10, i32 %8, i32 0
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ abort();
void nn_err_abort(void) { abort(); }


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

x86 assembly (clang, -O2):
<nn_err_abort>:
push   %rax
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @nn_err_abort() {
%1 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
define void @nn_err_abort() {
%1 = tail call i32 (...) @abort()
unreachable
}
void __unused_vector(void) {}


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

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

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

LLVM IR (-O2):
define void @__unused_vector() {
ret void
}
int fibo(int n) {
  if (n == 1)
    return 1;
  else
    return fibo(n - 1) + fibo(n - 2);
}


x86 assembly (clang, -O0):
<fibo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1131 <fibo+0x21>
movl   $0x1,-0x4(%rbp)
jmp    1154 <fibo+0x44>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <fibo@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x2,%edi
call   1030 <fibo@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fibo>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
cmp    $0x1,%edi
je     1141 <fibo+0x31>
mov    %edi,%ebp
add    $0xffffffff,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%edi
call   1030 <fibo@plt>
add    %eax,%ebx
add    $0xfffffffe,%ebp
jne    1130 <fibo+0x20>
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @fibo(i32 %0) {
%2 = icmp eq i32 %0, 1
br i1 %2, label %13, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %8, %3 ], [ %0, %1 ]
%5 = phi i32 [ %9, %3 ], [ 0, %1 ]
%6 = add nsw i32 %4, -1
%7 = tail call i32 @fibo(i32 %6)
%8 = add nsw i32 %4, -2
%9 = add nsw i32 %7, %5
%10 = icmp eq i32 %8, 1
br i1 %10, label %11, label %3
11: ; preds = %3
%12 = add i32 %9, 1
br label %13
13: ; preds = %11, %1
%14 = phi i32 [ 1, %1 ], [ %12, %11 ]
ret i32 %14
}