xunge/DecIR huggingface dataset:
/* Type definitions */
typedef unsigned int uint8_t;

/* Variables and functions */
void bytestream_put_be24(uint8_t **b, const unsigned int value) {
  do {
    ((uint8_t *)(*b))[2] = (value);
    ((uint8_t *)(*b))[1] = (value) >> 8;
    ((uint8_t *)(*b))[0] = (value) >> 16;
  } while (0);
  (*b) += 3;
}


x86 assembly (clang, -O0):
<bytestream_put_be24>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%ecx
shr    $0x8,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,0x4(%rax)
mov    -0xc(%rbp),%ecx
shr    $0x10,%ecx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0xc,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bytestream_put_be24>:
mov    (%rdi),%rax
mov    %esi,0x8(%rax)
mov    %esi,%ecx
shr    $0x8,%ecx
mov    %ecx,0x4(%rax)
shr    $0x10,%esi
mov    %esi,(%rax)
add    $0xc,%rax
mov    %rax,(%rdi)
ret

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

LLVM IR (-O2):
define void @bytestream_put_be24(i32** nocapture %0, i32 %1) {
%3 = load i32*, i32** %0
%4 = getelementptr inbounds i32, i32* %3, i64 2
store i32 %1, i32* %4
%5 = lshr i32 %1, 8
%6 = getelementptr inbounds i32, i32* %3, i64 1
store i32 %5, i32* %6
%7 = lshr i32 %1, 16
store i32 %7, i32* %3
%8 = getelementptr inbounds i32, i32* %3, i64 3
store i32* %8, i32** %0
ret void
}
void a1bcdefghijklmnopqrstuvwxzy() {}


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

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

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

LLVM IR (-O2):
define void @a1bcdefghijklmnopqrstuvwxzy() {
ret void
}
void h() { return; }


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

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

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

LLVM IR (-O2):
define void @h() {
ret void
}
/* Type definitions */
typedef int uint64_t;

/* Variables and functions */
uint64_t ShiftMix(uint64_t val) { return val ^ (val >> 47); }


x86 assembly (clang, -O0):
<ShiftMix>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%edx
mov    $0x2f,%ecx
sar    %cl,%edx
mov    %edx,%ecx
xor    %ecx,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @ShiftMix(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = ashr i32 %4, 47
%6 = xor i32 %3, %5
ret i32 %6
}

LLVM IR (-O2):
define i32 @ShiftMix(i32 %0) {
ret i32 poison
}
void setchar(int line, int col, int c) {
  unsigned char *videoram = (unsigned char *)0xB8000;
  unsigned int idx = 2 * (line * 80 + col);
  videoram[idx] = c;
  videoram[idx + 1] = ((0) << 4 | (2));
}


x86 assembly (clang, -O0):
<setchar>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x18(%rbp)
imul   $0x50,-0x4(%rbp),%eax
add    -0x8(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x2,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<setchar>:
lea    (%rdi,%rdi,4),%eax
shl    $0x4,%eax
add    %esi,%eax
add    %eax,%eax
mov    %dl,0xb8000(%rax)
movb   $0x2,0xb8001(%rax)
ret

LLVM IR (-O0):
define void @setchar(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* inttoptr (i64 753664 to i8*), i8** %7
%9 = load i32, i32* %4
%10 = mul nsw i32 %9, 80
%11 = load i32, i32* %5
%12 = add nsw i32 %10, %11
%13 = mul nsw i32 2, %12
store i32 %13, i32* %8
%14 = load i32, i32* %6
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
%20 = load i8*, i8** %7
%21 = load i32, i32* %8
%22 = add i32 %21, 1
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
store i8 2, i8* %24
ret void
}

LLVM IR (-O2):
define void @setchar(i32 %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %0, 80
%5 = add nsw i32 %4, %1
%6 = shl nsw i32 %5, 1
%7 = trunc i32 %2 to i8
%8 = zext i32 %6 to i64
%9 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %8
store i8 %7, i8* %9
%10 = or i32 %6, 1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %11
store i8 2, i8* %12
ret void
}
/* Variables and functions */
int /*<<< orphan*/ closeDb();
int /*<<< orphan*/ writeUnwrittenDiffs();
void shutdownCapture() {
  writeUnwrittenDiffs();
  closeDb();
}


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

x86 assembly (clang, -O2):
<shutdownCapture>:
push   %rax
xor    %eax,%eax
call   1030 <writeUnwrittenDiffs@plt>
xor    %eax,%eax
pop    %rcx
jmp    1040 <closeDb@plt>

LLVM IR (-O0):
define void @shutdownCapture() {
%1 = call i32 (...) @writeUnwrittenDiffs()
%2 = call i32 (...) @closeDb()
ret void
}

LLVM IR (-O2):
define void @shutdownCapture() {
%1 = tail call i32 (...) @writeUnwrittenDiffs()
%2 = tail call i32 (...) @closeDb()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ SoundDriver_CD_Stop();
void CD_Stop(void) { SoundDriver_CD_Stop(); }


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

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

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

LLVM IR (-O2):
define void @CD_Stop() {
%1 = tail call i32 (...) @SoundDriver_CD_Stop()
ret void
}
int test_imm_30int8_mem(signed char *val) {
  return ((*val) & (-0x30 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_30int8_mem(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = and i32 %5, -48
%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_30int8_mem(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = and i8 %2, -48
%4 = icmp eq i8 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int quicktime_major() { return 2; }


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

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

LLVM IR (-O0):
define i32 @quicktime_major() {
ret i32 2
}

LLVM IR (-O2):
define i32 @quicktime_major() {
ret i32 2
}
/* Variables and functions */
int sqrt(int);
int isprime(int n) {
  int i, flag = 1;
  for (i = 2; i <= sqrt(n); i++)
    if (n % i == 0) {
      flag = 0;
      break;
    }
  return flag;
}


x86 assembly (clang, -O0):
<isprime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jg     1173 <isprime+0x63>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1160 <isprime+0x50>
movl   $0x0,-0xc(%rbp)
jmp    1173 <isprime+0x63>
jmp    1165 <isprime+0x55>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <isprime+0x19>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isprime>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <sqrt@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
jl     1150 <isprime+0x40>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %ebx,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     114e <isprime+0x3e>
mov    %ebx,%edi
call   1030 <sqrt@plt>
cmp    %eax,%ebp
jl     1130 <isprime+0x20>
mov    $0x1,%eax
jmp    1150 <isprime+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @isprime(i32 %0) {
%2 = tail call i32 @sqrt(i32 %0)
%3 = icmp slt i32 %2, 2
br i1 %3, label %12, label %8
4: ; preds = %8
%5 = add nuw nsw i32 %9, 1
%6 = tail call i32 @sqrt(i32 %0)
%7 = icmp slt i32 %9, %6
br i1 %7, label %8, label %12
8: ; preds = %1, %4
%9 = phi i32 [ %5, %4 ], [ 2, %1 ]
%10 = srem i32 %0, %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %4
12: ; preds = %4, %8, %1
%13 = phi i32 [ 1, %1 ], [ 0, %8 ], [ 1, %4 ]
ret i32 %13
}
/* Variables and functions */
void *memset(void *s __attribute__((unused)), int c __attribute__((unused)),
             unsigned int n __attribute__((unused))) {
  return 0;
}


x86 assembly (clang, -O0):
<memset>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i8* @memset(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @memset(i8* nocapture readnone %0, i32 %1, i32 %2) {
ret i8* null
}
/* Variables and functions */
float __ocml_rlen3_f32(float, float, float);
float rnorm3df(float x, float y, float z) { return __ocml_rlen3_f32(x, y, z); }


x86 assembly (clang, -O0):
<rnorm3df>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
call   1030 <__ocml_rlen3_f32@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rnorm3df>:
jmp    1030 <__ocml_rlen3_f32@plt>

LLVM IR (-O0):
define float @rnorm3df(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%7 = load float, float* %4
%8 = load float, float* %5
%9 = load float, float* %6
%10 = call float @__ocml_rlen3_f32(float %7, float %8, float %9)
ret float %10
}

LLVM IR (-O2):
define float @rnorm3df(float %0, float %1, float %2) {
%4 = tail call float @__ocml_rlen3_f32(float %0, float %1, float %2)
ret float %4
}
void op0x76(void) {}


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

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

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

LLVM IR (-O2):
define void @op0x76() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Absolute(int);
int /*<<< orphan*/ LSR8(int /*<<< orphan*/);
void Op4EM1(void) { LSR8(Absolute(3)); }


x86 assembly (clang, -O0):
<Op4EM1>:
push   %rbp
mov    %rsp,%rbp
mov    $0x3,%edi
call   1040 <Absolute@plt>
mov    %eax,%edi
call   1030 <LSR8@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Op4EM1>:
push   %rax
mov    $0x3,%edi
call   1040 <Absolute@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <LSR8@plt>

LLVM IR (-O0):
define void @Op4EM1() {
%1 = call i32 @Absolute(i32 3)
%2 = call i32 @LSR8(i32 %1)
ret void
}

LLVM IR (-O2):
define void @Op4EM1() {
%1 = tail call i32 @Absolute(i32 3)
%2 = tail call i32 @LSR8(i32 %1)
ret void
}
void bitset_ffs() {}


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

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

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

LLVM IR (-O2):
define void @bitset_ffs() {
ret void
}
int get_salt_size(void) { return 20; }


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

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

LLVM IR (-O0):
define i32 @get_salt_size() {
ret i32 20
}

LLVM IR (-O2):
define i32 @get_salt_size() {
ret i32 20
}
int wc_gcd(int a, int b) {
  int r;
  if (a == 0)
    return b;
  if (b == 0)
    return a;
  while (1) {
    r = a % b;
    if (r == 0)
      break;
    a = b;
    b = r;
  }
  return b;
}


x86 assembly (clang, -O0):
<wc_gcd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    111f <wc_gcd+0x1f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1169 <wc_gcd+0x69>
cmpl   $0x0,-0xc(%rbp)
jne    1134 <wc_gcd+0x34>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1169 <wc_gcd+0x69>
jmp    1139 <wc_gcd+0x39>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1152 <wc_gcd+0x52>
jmp    1163 <wc_gcd+0x63>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1139 <wc_gcd+0x39>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<wc_gcd>:
mov    %esi,%edx
test   %edi,%edi
je     111e <wc_gcd+0x1e>
mov    %edi,%eax
test   %edx,%edx
je     1120 <wc_gcd+0x20>
nopl   0x0(%rax)
mov    %edx,%ecx
cltd
idiv   %ecx
mov    %ecx,%eax
test   %edx,%edx
jne    1110 <wc_gcd+0x10>
mov    %ecx,%eax
ret
mov    %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @wc_gcd(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = icmp eq i32 %1, 0
br i1 %5, label %11, label %6
6: ; preds = %4, %6
%7 = phi i32 [ %8, %6 ], [ %0, %4 ]
%8 = phi i32 [ %9, %6 ], [ %1, %4 ]
%9 = srem i32 %7, %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %6
11: ; preds = %6, %4, %2
%12 = phi i32 [ %1, %2 ], [ %0, %4 ], [ %8, %6 ]
ret i32 %12
}
cbuf10(f, n) { return (cbuf(f, n, 10)); }


x86 assembly (clang, -O0):
<cbuf10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0xa,%edx
mov    $0x0,%al
call   1030 <cbuf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbuf10>:
mov    $0xa,%edx
xor    %eax,%eax
jmp    1030 <cbuf@plt>

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

LLVM IR (-O2):
define i32 @cbuf10(i32 %0, i32 %1) {
%3 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %0, i32 %1, i32 10)
ret i32 %3
}
/* Variables and functions */
double f(double);
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  double x = 4.0;
  double y = f(x);
  printf("y = %f\n", y);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movsd  0xed7(%rip),%xmm0
call   1030 <f@plt>
lea    0xed3(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"y = %f\0A\00"
define i32 @main() {
%1 = tail call double @f(double 4.000000e+00)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %1)
ret i32 0
}
int intFuncIntArg(int i) { return 42; }


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

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

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

LLVM IR (-O2):
define i32 @intFuncIntArg(i32 %0) {
ret i32 42
}
/* Variables and functions */
int /*<<< orphan*/ gcMark();
int /*<<< orphan*/ gcSweep();
void gc() {
  gcMark();
  gcSweep();
}


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

x86 assembly (clang, -O2):
<gc>:
push   %rax
xor    %eax,%eax
call   1040 <gcMark@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <gcSweep@plt>

LLVM IR (-O0):
define void @gc() {
%1 = call i32 (...) @gcMark()
%2 = call i32 (...) @gcSweep()
ret void
}

LLVM IR (-O2):
define void @gc() {
%1 = tail call i32 (...) @gcMark()
%2 = tail call i32 (...) @gcSweep()
ret void
}
cbuf29(f, n) { return (cbuf(f, n, 29)); }


x86 assembly (clang, -O0):
<cbuf29>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1d,%edx
mov    $0x0,%al
call   1030 <cbuf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cbuf29>:
mov    $0x1d,%edx
xor    %eax,%eax
jmp    1030 <cbuf@plt>

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

LLVM IR (-O2):
define i32 @cbuf29(i32 %0, i32 %1) {
%3 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @cbuf to i32 (i32, i32, i32, ...)*)(i32 %0, i32 %1, i32 29)
ret i32 %3
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ dp_disklock();
int /*<<< orphan*/ *fopen_orig(char const *, char const *);
FILE *fopen(const char *path, const char *mode) {
  dp_disklock();
  return (fopen_orig(path, mode));
}


x86 assembly (clang, -O0):
<fopen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <dp_disklock@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <fopen_orig@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fopen>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <dp_disklock@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <fopen_orig@plt>

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

LLVM IR (-O2):
define i32* @fopen(i8* %0, i8* %1) {
%3 = tail call i32 (...) @dp_disklock()
%4 = tail call i32* @fopen_orig(i8* %0, i8* %1)
ret i32* %4
}
/* Variables and functions */
int /*<<< orphan*/ __analyzer_eval(int);
void test_42(void) {
  int i;
  float f;
  i = 42;
  f = i;
  __analyzer_eval(f == 42.0);
}


x86 assembly (clang, -O0):
<test_42>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x2a,-0x4(%rbp)
cvtsi2ssl -0x4(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec6(%rip),%xmm1
ucomisd %xmm1,%xmm0
sete   %al
setnp  %cl
and    %cl,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <__analyzer_eval@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_42>:
mov    $0x1,%edi
jmp    1030 <__analyzer_eval@plt>

LLVM IR (-O0):
define void @test_42() {
%1 = alloca i32
%2 = alloca float
store i32 42, i32* %1
%3 = load i32, i32* %1
%4 = sitofp i32 %3 to float
store float %4, float* %2
%5 = load float, float* %2
%6 = fpext float %5 to double
%7 = fcmp oeq double %6, 4.200000e+01
%8 = zext i1 %7 to i32
%9 = call i32 @__analyzer_eval(i32 %8)
ret void
}

LLVM IR (-O2):
define void @test_42() {
%1 = tail call i32 @__analyzer_eval(i32 1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
void print_usage(char *command) {
  printf("Usage: %s --context <x> --from <y> --to <z> <value>\n"
         "\t--context: currently, <x> must be cpu\n"
         "\t--from and --to: allowed values for <y> and <z>:\n"
         "\t\tinterrupt-server\n\t\tdrc-index\n\t\tdrc-name\n"
         "\tif <value> is a drc-index or interrupt-server, it can be\n"
         "\tspecified in decimal, hex (with a leading 0x), or octal\n"
         "\t(with a leading 0); if it is a drc-name, it should be\n"
         "\tspecified as a string in double quotes\n\n",
         command);
  return;
}


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

x86 assembly (clang, -O2):
<print_usage>:
mov    %rdi,%rsi
lea    0xee6(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [395 x i8] c"Usage: %s --context <x> --from <y> --to <z> <value>\0A\09--context: currently, <x> must be cpu\0A\09--from and --to: allowed values for <y> and <z>:\0A\09\09interrupt-server\0A\09\09drc-index\0A\09\09drc-name\0A\09if <value> is a drc-index or interrupt-server, it can be\0A\09specified in decimal, hex (with a leading 0x), or octal\0A\09(with a leading 0); if it is a drc-name, it should be\0A\09specified as a string in double quotes\0A\0A\00"
define void @print_usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([395 x i8], [395 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [395 x i8] c"Usage: %s --context <x> --from <y> --to <z> <value>\0A\09--context: currently, <x> must be cpu\0A\09--from and --to: allowed values for <y> and <z>:\0A\09\09interrupt-server\0A\09\09drc-index\0A\09\09drc-name\0A\09if <value> is a drc-index or interrupt-server, it can be\0A\09specified in decimal, hex (with a leading 0x), or octal\0A\09(with a leading 0); if it is a drc-name, it should be\0A\09specified as a string in double quotes\0A\0A\00"
define void @print_usage(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([395 x i8], [395 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, size_t, int);
scalar_t__ getpid();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ writef(int, void const *, size_t);
ssize_t write(int d, const void *buf, size_t sz) {
  fprintf(stderr, "[%d] writing %zu bytes to %d\n", (int)getpid(), sz, d);
  return writef(d, buf, sz);
}


x86 assembly (clang, -O0):
<write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%edx
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%r8d
lea    0xe96(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <writef@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x2e9a(%rip),%rax
mov    (%rax),%r15d
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xea9(%rip),%rsi
mov    %r15d,%edi
mov    %eax,%edx
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1040 <fprintf@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <writef@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"[%d] writing %zu bytes to %d\0A\00"
define i32 @write(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i32, i32* @stderr
%8 = call i64 (...) @getpid()
%9 = trunc i64 %8 to i32
%10 = load i64, i64* %6
%11 = load i32, i32* %4
%12 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %9, i64 %10, i32 %11)
%13 = load i32, i32* %4
%14 = load i8*, i8** %5
%15 = load i64, i64* %6
%16 = call i32 @writef(i32 %13, i8* %14, i64 %15)
ret i32 %16
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"[%d] writing %zu bytes to %d\0A\00"
define i32 @write(i32 %0, i8* %1, i64 %2) {
%4 = load i32, i32* @stderr
%5 = tail call i64 (...) @getpid()
%6 = trunc i64 %5 to i32
%7 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %6, i64 %2, i32 %0)
%8 = tail call i32 @writef(i32 %0, i8* %1, i64 %2)
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ RTLD_LAZY;
int /*<<< orphan*/ dlclose(void *);
void *dlopen(char *, int /*<<< orphan*/);
scalar_t__ dlsym(void *, char *);
int /*<<< orphan*/ printf(char *, int);
int stub1();
int stub2();
void test(void) {
  void *dl = dlopen("/home/ollie/work/plhaskell/plhaskell.so", RTLD_LAZY);
  printf("%d\n", ((int (*)(void))dlsym(dl, "test"))());
  dlclose(dl);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
lea    0xea8(%rip),%rdi
call   1040 <dlopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1050 <dlsym@plt>
call   *%rax
mov    %eax,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <dlclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rbx
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
lea    0xeaf(%rip),%rdi
call   1040 <dlopen@plt>
mov    %rax,%rbx
lea    0xecc(%rip),%rsi
mov    %rax,%rdi
call   1050 <dlsym@plt>
call   *%rax
lea    0xeb7(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <dlclose@plt>

LLVM IR (-O0):
@.str = [40 x i8] c"/home/ollie/work/plhaskell/plhaskell.so\00"
@RTLD_LAZY = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [5 x i8] c"test\00"
define void @test() {
%1 = alloca i8*
%2 = load i32, i32* @RTLD_LAZY
%3 = call i8* @dlopen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %2)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = call i64 @dlsym(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%6 = inttoptr i64 %5 to i32 ()*
%7 = call i32 %6()
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %1
%10 = call i32 @dlclose(i8* %9)
ret void
}

LLVM IR (-O2):
@.str = [40 x i8] c"/home/ollie/work/plhaskell/plhaskell.so\00"
@RTLD_LAZY = global i32 0
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [5 x i8] c"test\00"
define void @test() {
%1 = load i32, i32* @RTLD_LAZY
%2 = tail call i8* @dlopen(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i64 @dlsym(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%4 = inttoptr i64 %3 to i32 ()*
%5 = tail call i32 %4()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @dlclose(i8* %2)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int lremovexattr(const char *__path, const char *__name) {
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<lremovexattr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lremovexattr>:
push   %rax
mov    0x2ed0(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@ENOSYS = global i32 0
define i32 @lremovexattr(i8* nocapture readnone %0, i8* nocapture readnone %1) {
%3 = load i32, i32* @ENOSYS
%4 = tail call i32 @__set_errno(i32 %3)
ret i32 -1
}
__attribute__((always_)) unsigned long wait_task_inactive(struct task_struct *p,
                                                          long match_state) {
  return 1;
}


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

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

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

LLVM IR (-O2):
%struct.task_struct = type opaque
define i64 @wait_task_inactive(%struct.task_struct* nocapture readnone %0, i64 %1) {
ret i64 1
}
/* Type definitions */
typedef int uint64_t;
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
uint64_t microsec_timer(void) {
  struct timespec ts;
  clock_gettime(CLOCK_MONOTONIC, &ts);
  return ((uint64_t)ts.tv_sec * 1000000) + ((uint64_t)ts.tv_nsec / 1000);
}


x86 assembly (clang, -O0):
<microsec_timer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x8(%rbp),%rax
imul   $0xf4240,%eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<microsec_timer>:
sub    $0x18,%rsp
mov    0x2ecd(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
imul   $0xf4240,0x10(%rsp),%ecx
movslq 0x8(%rsp),%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rax
add    %edx,%eax
add    %ecx,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
define i32 @microsec_timer() {
%1 = alloca %struct.timespec
%2 = load i32, i32* @CLOCK_MONOTONIC
%3 = call i32 @clock_gettime(i32 %2, %struct.timespec* %1)
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 1
%5 = load i64, i64* %4
%6 = trunc i64 %5 to i32
%7 = mul nsw i32 %6, 1000000
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i32 0, i32 0
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = sdiv i32 %10, 1000
%12 = add nsw i32 %7, %11
ret i32 %12
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@CLOCK_MONOTONIC = global i32 0
define i32 @microsec_timer() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_MONOTONIC
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%6 = load i64, i64* %5
%7 = trunc i64 %6 to i32
%8 = mul nsw i32 %7, 1000000
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%10 = load i64, i64* %9
%11 = trunc i64 %10 to i32
%12 = sdiv i32 %11, 1000
%13 = add nsw i32 %12, %8
ret i32 %13
}
void PDMCritSectIsInitialized(void) {}


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

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

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

LLVM IR (-O2):
define void @PDMCritSectIsInitialized() {
ret void
}
int __test_and_set_bit(long nr, volatile unsigned long *addr) {
  int oldbit;
  asm("bts %2,%1\n\t"
      "sbb %0,%0"
      : "=r"(oldbit), "+m"((*(volatile long *)addr))
      : "Ir"(nr));
  return oldbit;
}


x86 assembly (clang, -O0):
<__test_and_set_bit>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
bts    %rcx,(%rax)
sbb    %eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__test_and_set_bit>:
bts    %rdi,(%rsi)
sbb    %eax,%eax
ret

LLVM IR (-O0):
define i32 @__test_and_set_bit(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i32
store i64 %0, i64* %3
store i64* %1, i64** %4
%6 = load i64*, i64** %4
%7 = load i64, i64* %3
%8 = call i32 asm "bts $2,$1\0A\09sbb $0,$0", "=r,=*m,Ir,*m,~{dirflag},~{fpsr},~{flags}"(i64* elementtype(i64) %6, i64 %7, i64* elementtype(i64) %6)
store i32 %8, i32* %5
%9 = load i32, i32* %5
ret i32 %9
}

LLVM IR (-O2):
define i32 @__test_and_set_bit(i64 %0, i64* %1) {
%3 = tail call i32 asm "bts $2,$1\0A\09sbb $0,$0", "=r,=*m,Ir,*m,~{dirflag},~{fpsr},~{flags}"(i64* elementtype(i64) %1, i64 %0, i64* elementtype(i64) %1)
ret i32 %3
}
/* Type definitions */
typedef int mode_t;

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int O_WRONLY;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int open(char const *, int, int);
int File_openWrite(const char *str) {
  int f = O_CREAT | O_WRONLY | O_APPEND;
  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  return open(str, f, mode);
}


x86 assembly (clang, -O0):
<File_openWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ed5(%rip),%rax
mov    (%rax),%eax
mov    0x2e84(%rip),%rcx
or     (%rcx),%eax
mov    0x2e73(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e7f(%rip),%rax
mov    (%rax),%eax
mov    0x2e96(%rip),%rcx
or     (%rcx),%eax
mov    0x2e7d(%rip),%rcx
or     (%rcx),%eax
mov    0x2e6c(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <open@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_openWrite>:
mov    0x2ee1(%rip),%rax
mov    0x2e92(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e7f(%rip),%rax
or     (%rax),%esi
mov    0x2e8e(%rip),%rax
mov    0x2ea7(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e8c(%rip),%rax
or     (%rax),%edx
mov    0x2e7b(%rip),%rax
or     (%rax),%edx
jmp    1030 <open@plt>

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
define i32 @File_openWrite(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_WRONLY
%7 = or i32 %5, %6
%8 = load i32, i32* @O_APPEND
%9 = or i32 %7, %8
store i32 %9, i32* %3
%10 = load i32, i32* @S_IRUSR
%11 = load i32, i32* @S_IWUSR
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRGRP
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IROTH
%16 = or i32 %14, %15
store i32 %16, i32* %4
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @open(i8* %17, i32 %18, i32 %19)
ret i32 %20
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
define i32 @File_openWrite(i8* nocapture %0) {
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_WRONLY
%4 = or i32 %3, %2
%5 = load i32, i32* @O_APPEND
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IRUSR
%8 = load i32, i32* @S_IWUSR
%9 = or i32 %8, %7
%10 = load i32, i32* @S_IRGRP
%11 = or i32 %9, %10
%12 = load i32, i32* @S_IROTH
%13 = or i32 %11, %12
%14 = tail call i32 @open(i8* %0, i32 %6, i32 %13)
ret i32 %14
}
void ISRNmi(void) {
  while (1)
    ;
}


x86 assembly (clang, -O0):
<ISRNmi>:
push   %rbp
mov    %rsp,%rbp
jmp    1109 <ISRNmi+0x9>
jmp    1109 <ISRNmi+0x9>

x86 assembly (clang, -O2):
<ISRNmi>:
jmp    1100 <ISRNmi>

LLVM IR (-O0):
define void @ISRNmi() {
br label %1
1: ; preds = %0, %1
br label %1
}

LLVM IR (-O2):
define void @ISRNmi() {
br label %1
1: ; preds = %0, %1
br label %1
}
/* Variables and functions */
char *gai_strerror(int);
int /*<<< orphan*/ printf(char *, char const *, char *);
int _gai_strerror(char const *message, int value) {
  printf("%s: %s\n", message, gai_strerror(value));
  return 0;
}


x86 assembly (clang, -O0):
<_gai_strerror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x18(%rbp),%rsi
mov    %rax,%rdx
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_gai_strerror>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
call   1040 <gai_strerror@plt>
lea    0xece(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"%s: %s\0A\00"
define i32 @_gai_strerror(i8* %0, i32 %1) {
%3 = tail call i8* @gai_strerror(i32 %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %3)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ ccsynch_unlock(void *);
void ccsynch_delegate_unlock(void *lock) { ccsynch_unlock(lock); }


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

x86 assembly (clang, -O2):
<ccsynch_delegate_unlock>:
jmp    1030 <ccsynch_unlock@plt>

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

LLVM IR (-O2):
define void @ccsynch_delegate_unlock(i8* %0) {
%2 = tail call i32 @ccsynch_unlock(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isdigit(int);
void t_isdigit_0xb3() {
  Assert_real((isdigit(179) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isdigit.c",
              900, ("isdigit should be 0 for 0xb3"));
}


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

x86 assembly (clang, -O2):
<t_isdigit_0xb3>:
push   %rax
mov    $0xb3,%edi
call   1030 <isdigit@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf66(%rip),%rcx
mov    $0x384,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isdigit.c\00"
@.str.1 = [29 x i8] c"isdigit should be 0 for 0xb3\00"
define void @t_isdigit_0xb3() {
%1 = call i64 @isdigit(i32 179)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 900, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isdigit.c\00"
@.str.1 = [29 x i8] c"isdigit should be 0 for 0xb3\00"
define void @t_isdigit_0xb3() {
%1 = tail call i64 @isdigit(i32 179)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 900, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
void vymen(char *s, int i, int j) {
  int pom;
  pom = s[i];
  s[i] = s[j];
  s[j] = pom;
}


x86 assembly (clang, -O0):
<vymen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<vymen>:
movslq %esi,%rax
mov    (%rdi,%rax,1),%sil
movslq %edx,%rdx
mov    (%rdi,%rdx,1),%cl
mov    %cl,(%rdi,%rax,1)
mov    %sil,(%rdi,%rdx,1)
ret

LLVM IR (-O0):
define void @vymen(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
store i32 %13, i32* %7
%14 = load i8*, i8** %4
%15 = load i32, i32* %6
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
%23 = load i32, i32* %7
%24 = trunc i32 %23 to i8
%25 = load i8*, i8** %4
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 %24, i8* %28
ret void
}

LLVM IR (-O2):
define void @vymen(i8* nocapture %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
store i8 %9, i8* %5
store i8 %6, i8* %8
ret void
}
/* Type definitions */
struct array_s {
  int dummy;
};

/* Variables and functions */
int array_reserve_with_ratio(struct array_s *, unsigned long, double);
int array_reserve(struct array_s *a, unsigned long count) {
  return array_reserve_with_ratio(a, count, 2.0);
}


x86 assembly (clang, -O0):
<array_reserve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movsd  0xed0(%rip),%xmm0
call   1030 <array_reserve_with_ratio@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_reserve>:
movsd  0xee8(%rip),%xmm0
jmp    1030 <array_reserve_with_ratio@plt>

LLVM IR (-O0):
%struct.array_s = type { i32 }
define i32 @array_reserve(%struct.array_s* %0, i64 %1) {
%3 = alloca %struct.array_s*
%4 = alloca i64
store %struct.array_s* %0, %struct.array_s** %3
store i64 %1, i64* %4
%5 = load %struct.array_s*, %struct.array_s** %3
%6 = load i64, i64* %4
%7 = call i32 @array_reserve_with_ratio(%struct.array_s* %5, i64 %6, double 2.000000e+00)
ret i32 %7
}

LLVM IR (-O2):
%struct.array_s = type { i32 }
define i32 @array_reserve(%struct.array_s* %0, i64 %1) {
%3 = tail call i32 @array_reserve_with_ratio(%struct.array_s* %0, i64 %1, double 2.000000e+00)
ret i32 %3
}
int loadlibraryw(const unsigned short *name) {
  return name[0] + name[1] * 0x100 + name[2] * 0x10000;
}


x86 assembly (clang, -O0):
<loadlibraryw>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzwl (%rax),%eax
mov    -0x8(%rbp),%rcx
movzwl 0x2(%rcx),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
mov    -0x8(%rbp),%rcx
movzwl 0x4(%rcx),%ecx
shl    $0x10,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadlibraryw>:
movzwl (%rdi),%eax
movzwl 0x2(%rdi),%ecx
shl    $0x8,%ecx
add    %eax,%ecx
movzwl 0x4(%rdi),%eax
shl    $0x10,%eax
add    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @loadlibraryw(i16* %0) {
%2 = alloca i16*
store i16* %0, i16** %2
%3 = load i16*, i16** %2
%4 = getelementptr inbounds i16, i16* %3, i64 0
%5 = load i16, i16* %4
%6 = zext i16 %5 to i32
%7 = load i16*, i16** %2
%8 = getelementptr inbounds i16, i16* %7, i64 1
%9 = load i16, i16* %8
%10 = zext i16 %9 to i32
%11 = mul nsw i32 %10, 256
%12 = add nsw i32 %6, %11
%13 = load i16*, i16** %2
%14 = getelementptr inbounds i16, i16* %13, i64 2
%15 = load i16, i16* %14
%16 = zext i16 %15 to i32
%17 = mul nsw i32 %16, 65536
%18 = add nsw i32 %12, %17
ret i32 %18
}

LLVM IR (-O2):
define i32 @loadlibraryw(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = zext i16 %2 to i32
%4 = getelementptr inbounds i16, i16* %0, i64 1
%5 = load i16, i16* %4
%6 = zext i16 %5 to i32
%7 = shl nuw nsw i32 %6, 8
%8 = add nuw nsw i32 %7, %3
%9 = getelementptr inbounds i16, i16* %0, i64 2
%10 = load i16, i16* %9
%11 = zext i16 %10 to i32
%12 = shl nuw nsw i32 %11, 16
%13 = add nuw nsw i32 %8, %12
ret i32 %13
}