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

/* Variables and functions */
int32_t psf_get_be24(uint8_t *ptr, int offset) {
  int32_t value;
  value = ((uint32_t)ptr[offset]) << 24;
  value += ptr[offset + 1] << 16;
  value += ptr[offset + 2] << 8;
  return value;
}


x86 assembly (clang, -O0):
<psf_get_be24>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x18,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x10,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x8,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<psf_get_be24>:
movslq %esi,%rax
mov    (%rdi,%rax,4),%ecx
mov    0x4(%rdi,%rax,4),%edx
shl    $0x18,%ecx
shl    $0x10,%edx
add    %ecx,%edx
mov    0x8(%rdi,%rax,4),%eax
shl    $0x8,%eax
add    %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @psf_get_be24(i32* nocapture %0, i32 %1) {
%3 = sext i32 %1 to i64
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
%6 = shl i32 %5, 24
%7 = add nsw i32 %1, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = shl i32 %10, 16
%12 = add nsw i32 %11, %6
%13 = add nsw i32 %1, 2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = shl i32 %16, 8
%18 = add nsw i32 %12, %17
ret i32 %18
}
/* Type definitions */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ __NR_gettid;
int /*<<< orphan*/ syscall(int /*<<< orphan*/);
pid_t gettid() { return syscall(__NR_gettid); }


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

x86 assembly (clang, -O2):
<gettid>:
mov    0x2ed1(%rip),%rax
mov    (%rax),%edi
jmp    1030 <syscall@plt>

LLVM IR (-O0):
@__NR_gettid = global i32 0
define i32 @gettid() {
%1 = load i32, i32* @__NR_gettid
%2 = call i32 @syscall(i32 %1)
ret i32 %2
}

LLVM IR (-O2):
@__NR_gettid = global i32 0
define i32 @gettid() {
%1 = load i32, i32* @__NR_gettid
%2 = tail call i32 @syscall(i32 %1)
ret i32 %2
}
/* Type definitions */
struct hostent {
  int dummy;
};

/* Variables and functions */
struct hostent *_gethostbynis(const char *name, char *map, int af) {
  return (NULL);
}


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

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

LLVM IR (-O0):
%struct.hostent = type { i32 }
define %struct.hostent* @_gethostbynis(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
ret %struct.hostent* null
}

LLVM IR (-O2):
%struct.hostent = type { i32 }
define noalias %struct.hostent* @_gethostbynis(i8* nocapture readnone %0, i8* nocapture readnone %1, i32 %2) {
ret %struct.hostent* null
}
__attribute__((no, noclone)) int foo1(int x, int y) { return x - y; }


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

x86 assembly (clang, -O2):
<foo1>:
mov    %edi,%eax
sub    %esi,%eax
ret

LLVM IR (-O0):
define i32 @foo1(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 = sub nsw i32 %5, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @foo1(i32 %0, i32 %1) {
%3 = sub nsw i32 %0, %1
ret i32 %3
}
int final(int arg) { return arg + 1; }


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

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

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

LLVM IR (-O2):
define i32 @final(i32 %0) {
%2 = add nsw i32 %0, 1
ret i32 %2
}
/* Variables and functions */
scalar_t__ func1(int);
__attribute__((optimize(0))) int main(int argc, char **argv) {
  int counter = 0;
  int i;
  for (i = 0; i < 100; ++i)
    counter += func1(i);
  return counter;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    1161 <main+0x51>
mov    -0x18(%rbp),%edi
call   1030 <func1@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1134 <main+0x24>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <func1@plt>
add    %eax,%ebp
add    $0x1,%ebx
cmp    $0x64,%ebx
jne    1120 <main+0x10>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 100
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %7
%13 = call i64 @func1(i32 %12)
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %6
br label %18
18: ; preds = %11
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %8
21: ; preds = %8
%22 = load i32, i32* %6
ret i32 %22
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %9, %3 ]
%5 = phi i32 [ 0, %2 ], [ %8, %3 ]
%6 = tail call i64 @func1(i32 %4)
%7 = trunc i64 %6 to i32
%8 = add i32 %5, %7
%9 = add nuw nsw i32 %4, 1
%10 = icmp eq i32 %9, 100
br i1 %10, label %11, label %3
11: ; preds = %3
ret i32 %8
}
/* Variables and functions */
int /*<<< orphan*/ _SC_NPROCESSORS_CONF;
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sysconf(int /*<<< orphan*/);
void test_ncpus(void) { printf("NCPUs: %ld\n", sysconf(_SC_NPROCESSORS_CONF)); }


x86 assembly (clang, -O0):
<test_ncpus>:
push   %rbp
mov    %rsp,%rbp
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
mov    %eax,%esi
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ncpus>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
call   1040 <sysconf@plt>
lea    0xeca(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"NCPUs: %ld\0A\00"
@_SC_NPROCESSORS_CONF = global i32 0
define void @test_ncpus() {
%1 = load i32, i32* @_SC_NPROCESSORS_CONF
%2 = call i32 @sysconf(i32 %1)
%3 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"NCPUs: %ld\0A\00"
@_SC_NPROCESSORS_CONF = global i32 0
define void @test_ncpus() {
%1 = load i32, i32* @_SC_NPROCESSORS_CONF
%2 = tail call i32 @sysconf(i32 %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2)
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
void ADCComparatorRegionSet(uint32_t ui32Base, uint32_t ui32Comp,
                            uint32_t ui32LowRef, uint32_t ui32HighRef) {
  ;
  ;
  ;
  ;
  (*((volatile uint32_t *)(ui32Base + 0x00000E40 + (ui32Comp * 4)))) =
      ((ui32HighRef << 16) | ui32LowRef);
}


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

x86 assembly (clang, -O2):
<ADCComparatorRegionSet>:
shl    $0x10,%ecx
or     %edx,%ecx
movslq %edi,%rax
movslq %esi,%rdx
mov    %ecx,0xe40(%rax,%rdx,4)
ret

LLVM IR (-O0):
define void @ADCComparatorRegionSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %8
%10 = shl i32 %9, 16
%11 = load i32, i32* %7
%12 = or i32 %10, %11
%13 = load i32, i32* %5
%14 = add nsw i32 %13, 3648
%15 = load i32, i32* %6
%16 = mul nsw i32 %15, 4
%17 = add nsw i32 %14, %16
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
store volatile i32 %12, i32* %19
ret void
}

LLVM IR (-O2):
define void @ADCComparatorRegionSet(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %3, 16
%6 = or i32 %5, %2
%7 = add nsw i32 %0, 3648
%8 = shl nsw i32 %1, 2
%9 = add nsw i32 %7, %8
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
store volatile i32 %6, i32* %11
ret void
}
void swap(char *dst, char *src) {
  char tmp = *dst;
  *dst = *src;
  *src = tmp;
  return;
}


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

x86 assembly (clang, -O2):
<swap>:
mov    (%rdi),%al
mov    (%rsi),%cl
mov    %cl,(%rdi)
mov    %al,(%rsi)
ret

LLVM IR (-O0):
define void @swap(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
store i8 %7, i8* %5
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = load i8*, i8** %3
store i8 %9, i8* %10
%11 = load i8, i8* %5
%12 = load i8*, i8** %4
store i8 %11, i8* %12
ret void
}

LLVM IR (-O2):
define void @swap(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
store i8 %4, i8* %0
store i8 %3, i8* %1
ret void
}
/* Variables and functions */
double M_PI;
double sin(double);
double _sinc(double x) { return (sin(M_PI * x) / (M_PI * x)); }


x86 assembly (clang, -O0):
<_sinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    0x2ec4(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <sin@plt>
mov    0x2eaf(%rip),%rax
movsd  (%rax),%xmm1
mulsd  -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sinc>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
mov    0x2ec2(%rip),%rbx
movsd  (%rbx),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <sin@plt>
movsd  0x8(%rsp),%xmm1
mulsd  (%rbx),%xmm1
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @_sinc(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* @M_PI
%4 = load double, double* %2
%5 = fmul double %3, %4
%6 = call double @sin(double %5)
%7 = load double, double* @M_PI
%8 = load double, double* %2
%9 = fmul double %7, %8
%10 = fdiv double %6, %9
ret double %10
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @_sinc(double %0) {
%2 = load double, double* @M_PI
%3 = fmul double %2, %0
%4 = tail call double @sin(double %3)
%5 = load double, double* @M_PI
%6 = fmul double %5, %0
%7 = fdiv double %4, %6
ret double %7
}
unsigned long round_up(unsigned long val, unsigned long boundary) {
  return ((val + boundary - 1) & ~(boundary - 1));
}


x86 assembly (clang, -O0):
<round_up>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
xor    $0xffffffffffffffff,%rcx
and    %rcx,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_up>:
lea    (%rdi,%rsi,1),%rax
add    $0xffffffffffffffff,%rax
neg    %rsi
and    %rsi,%rax
ret

LLVM IR (-O0):
define i64 @round_up(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 i64 %5, %6
%8 = sub i64 %7, 1
%9 = load i64, i64* %4
%10 = sub i64 %9, 1
%11 = xor i64 %10, -1
%12 = and i64 %8, %11
ret i64 %12
}

LLVM IR (-O2):
define i64 @round_up(i64 %0, i64 %1) {
%3 = add i64 %0, -1
%4 = add i64 %3, %1
%5 = sub i64 0, %1
%6 = and i64 %4, %5
ret i64 %6
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ datagramTxOut(int /*<<< orphan*/ const *, int);
void datagramTxOutByte(const uint8_t c) { datagramTxOut(&c, 1); }


x86 assembly (clang, -O0):
<datagramTxOutByte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
mov    $0x1,%esi
call   1030 <datagramTxOut@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<datagramTxOutByte>:
push   %rax
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
call   1030 <datagramTxOut@plt>
pop    %rax
ret

LLVM IR (-O0):
define void @datagramTxOutByte(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @datagramTxOut(i32* %2, i32 1)
ret void
}

LLVM IR (-O2):
define void @datagramTxOutByte(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @datagramTxOut(i32* %2, i32 1)
ret void
}
int sum3(int i1, int i2, int i3) { return i1 + i2 + i3; }


x86 assembly (clang, -O0):
<sum3>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<sum3>:
lea    (%rdi,%rsi,1),%eax
add    %edx,%eax
ret

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

LLVM IR (-O2):
define i32 @sum3(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, %0
%5 = add nsw i32 %4, %2
ret i32 %5
}
/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
double systime_cpu() { return (double)clock() / CLOCKS_PER_SEC; }


x86 assembly (clang, -O0):
<systime_cpu>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2ec1(%rip),%rax
divsd  (%rax),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<systime_cpu>:
push   %rax
xor    %eax,%eax
call   1030 <clock@plt>
cvtsi2sd %rax,%xmm0
mov    0x2ec4(%rip),%rax
divsd  (%rax),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @systime_cpu() {
%1 = call i64 (...) @clock()
%2 = sitofp i64 %1 to double
%3 = load double, double* @CLOCKS_PER_SEC
%4 = fdiv double %2, %3
ret double %4
}

LLVM IR (-O2):
@CLOCKS_PER_SEC = global double 0.000000e+00
define double @systime_cpu() {
%1 = tail call i64 (...) @clock()
%2 = sitofp i64 %1 to double
%3 = load double, double* @CLOCKS_PER_SEC
%4 = fdiv double %2, %3
ret double %4
}
/* Type definitions */
typedef int uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
uint8_t nsfGet_456B(uint16_t addr) {
  (void)addr;
  return 0x6A;
}


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

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

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

LLVM IR (-O2):
define i32 @nsfGet_456B(i32 %0) {
ret i32 106
}
/* Variables and functions */
int strlen(char *);
int sDiv(char *opt) {
  int l = strlen(opt) / 12;
  return l;
}


x86 assembly (clang, -O0):
<sDiv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0xc,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sDiv>:
push   %rax
call   1030 <strlen@plt>
cltq
imul   $0x2aaaaaab,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @sDiv(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @strlen(i8* %4)
%6 = sdiv i32 %5, 12
store i32 %6, i32* %3
%7 = load i32, i32* %3
ret i32 %7
}

LLVM IR (-O2):
define i32 @sDiv(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sdiv i32 %2, 12
ret i32 %3
}
/* Variables and functions */
int getloadavg(double *, int);
double get_load_avg(void) {
  double loadavg[1];
  int n = getloadavg(loadavg, 1);
  if (n < 1)
    return 1000.0;
  else
    return loadavg[0];
}


x86 assembly (clang, -O0):
<get_load_avg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <getloadavg@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1145 <get_load_avg+0x35>
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    114f <get_load_avg+0x3f>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_load_avg>:
push   %rax
mov    %rsp,%rdi
mov    $0x1,%esi
call   1030 <getloadavg@plt>
test   %eax,%eax
jle    1129 <get_load_avg+0x19>
movsd  (%rsp),%xmm0
pop    %rax
ret
movsd  0xecf(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @get_load_avg() {
%1 = alloca double
%2 = alloca [1 x double]
%3 = alloca i32
%4 = getelementptr inbounds [1 x double], [1 x double]* %2, i64 0, i64 0
%5 = call i32 @getloadavg(double* %4, i32 1)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store double 1.000000e+03, double* %1
br label %12
9: ; preds = %0
%10 = getelementptr inbounds [1 x double], [1 x double]* %2, i64 0, i64 0
%11 = load double, double* %10
store double %11, double* %1
br label %12
12: ; preds = %9, %8
%13 = load double, double* %1
ret double %13
}

LLVM IR (-O2):
define double @get_load_avg() {
%1 = alloca [1 x double]
%2 = bitcast [1 x double]* %1 to i8*
%3 = getelementptr inbounds [1 x double], [1 x double]* %1, i64 0, i64 0
%4 = call i32 @getloadavg(double* %3, i32 1)
%5 = icmp slt i32 %4, 1
%6 = load double, double* %3
%7 = select i1 %5, double 1.000000e+03, double %6
ret double %7
}
/* Variables and functions */
int abs(float);
float calc_yaw(float currentbearing, float prevbearing, float turn) {
  float yaw = (currentbearing - prevbearing);
  if (abs(yaw) > (180)) {
    yaw = turn * ((360) - abs(yaw));
  }
  return yaw;
}


x86 assembly (clang, -O0):
<calc_yaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
cmp    $0xb4,%eax
jle    117a <calc_yaw+0x6a>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
call   1030 <abs@plt>
movss  -0x14(%rbp),%xmm0
mov    %eax,%ecx
mov    $0x168,%eax
sub    %ecx,%eax
cvtsi2ss %eax,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_yaw>:
push   %rax
movss  %xmm2,0x4(%rsp)
subss  %xmm1,%xmm0
movss  %xmm0,(%rsp)
call   1030 <abs@plt>
cmp    $0xb5,%eax
jl     114c <calc_yaw+0x3c>
movss  (%rsp),%xmm0
call   1030 <abs@plt>
mov    $0x168,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mulss  0x4(%rsp),%xmm0
pop    %rax
ret
movss  (%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @calc_yaw(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%8 = load float, float* %4
%9 = load float, float* %5
%10 = fsub float %8, %9
store float %10, float* %7
%11 = load float, float* %7
%12 = call i32 @abs(float %11)
%13 = icmp sgt i32 %12, 180
br i1 %13, label %14, label %21
14: ; preds = %3
%15 = load float, float* %6
%16 = load float, float* %7
%17 = call i32 @abs(float %16)
%18 = sub nsw i32 360, %17
%19 = sitofp i32 %18 to float
%20 = fmul float %15, %19
store float %20, float* %7
br label %21
21: ; preds = %14, %3
%22 = load float, float* %7
ret float %22
}

LLVM IR (-O2):
define float @calc_yaw(float %0, float %1, float %2) {
%4 = fsub float %0, %1
%5 = tail call i32 @abs(float %4)
%6 = icmp sgt i32 %5, 180
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = tail call i32 @abs(float %4)
%9 = sub nsw i32 360, %8
%10 = sitofp i32 %9 to float
%11 = fmul float %10, %2
br label %12
12: ; preds = %7, %3
%13 = phi float [ %11, %7 ], [ %4, %3 ]
ret float %13
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint64_t;

/* Variables and functions */
int get_big_endian_32(int /*<<< orphan*/ const *);
uint64_t get_big_endian_64(const uint8_t *buf) {
  uint64_t val;
  val = ((uint64_t)get_big_endian_32(buf) << 32) | get_big_endian_32(buf + 4);
  return val;
}


x86 assembly (clang, -O0):
<get_big_endian_64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <get_big_endian_32@plt>
mov    $0x20,%ecx
shl    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
call   1030 <get_big_endian_32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
or     %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_big_endian_64>:
push   %rbx
mov    %rdi,%rbx
call   1030 <get_big_endian_32@plt>
add    $0x10,%rbx
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <get_big_endian_32@plt>

LLVM IR (-O0):
define i32 @get_big_endian_64(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = call i32 @get_big_endian_32(i32* %4)
%6 = shl i32 %5, 32
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 4
%9 = call i32 @get_big_endian_32(i32* %8)
%10 = or i32 %6, %9
store i32 %10, i32* %3
%11 = load i32, i32* %3
ret i32 %11
}

LLVM IR (-O2):
define i32 @get_big_endian_64(i32* %0) {
%2 = tail call i32 @get_big_endian_32(i32* %0)
%3 = getelementptr inbounds i32, i32* %0, i64 4
%4 = tail call i32 @get_big_endian_32(i32* %3)
ret i32 poison
}
/* Type definitions */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ lxc_raw_getpid();
pid_t lxc_raw_gettid(void) { return lxc_raw_getpid(); }


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

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

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

LLVM IR (-O2):
define i32 @lxc_raw_gettid() {
%1 = tail call i32 (...) @lxc_raw_getpid()
ret i32 %1
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void cleanup(void) { printf("atexit handler called\n"); }


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

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

LLVM IR (-O0):
@.str = [23 x i8] c"atexit handler called\0A\00"
define void @cleanup() {
%1 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [22 x i8] c"atexit handler called\00"
define void @cleanup() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
ret void
}
void imx_init_l2cache(void) {}


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

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

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

LLVM IR (-O2):
define void @imx_init_l2cache() {
ret void
}
/* Type definitions */
struct udev_ctrl {
  int dummy;
};
struct udev {
  int dummy;
};

/* Variables and functions */
struct udev_ctrl *udev_ctrl_new_from_fd(struct udev *, int);
struct udev_ctrl *udev_ctrl_new(struct udev *udev) {
  return udev_ctrl_new_from_fd(udev, -1);
}


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

x86 assembly (clang, -O2):
<udev_ctrl_new>:
mov    $0xffffffff,%esi
jmp    1030 <udev_ctrl_new_from_fd@plt>

LLVM IR (-O0):
%struct.udev_ctrl = type { i32 }
%struct.udev = type { i32 }
define %struct.udev_ctrl* @udev_ctrl_new(%struct.udev* %0) {
%2 = alloca %struct.udev*
store %struct.udev* %0, %struct.udev** %2
%3 = load %struct.udev*, %struct.udev** %2
%4 = call %struct.udev_ctrl* @udev_ctrl_new_from_fd(%struct.udev* %3, i32 -1)
ret %struct.udev_ctrl* %4
}

LLVM IR (-O2):
%struct.udev_ctrl = type { i32 }
%struct.udev = type { i32 }
define %struct.udev_ctrl* @udev_ctrl_new(%struct.udev* %0) {
%2 = tail call %struct.udev_ctrl* @udev_ctrl_new_from_fd(%struct.udev* %0, i32 -1)
ret %struct.udev_ctrl* %2
}
/* Variables and functions */
int close(int);
int UDP_Close(int fd) { return close(fd); }


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

x86 assembly (clang, -O2):
<UDP_Close>:
jmp    1030 <close@plt>

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

LLVM IR (-O2):
define i32 @UDP_Close(i32 %0) {
%2 = tail call i32 @close(i32 %0)
ret i32 %2
}
int d_ne_rm1(double a1, double *a2) { return (((a1) != (*a2))); }


x86 assembly (clang, -O0):
<d_ne_rm1>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
setne  %al
setp   %cl
or     %cl,%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<d_ne_rm1>:
cmpneqsd (%rdi),%xmm0
movq   %xmm0,%rax
and    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @d_ne_rm1(double %0, double* %1) {
%3 = alloca double
%4 = alloca double*
store double %0, double* %3
store double* %1, double** %4
%5 = load double, double* %3
%6 = load double*, double** %4
%7 = load double, double* %6
%8 = fcmp une double %5, %7
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
define i32 @d_ne_rm1(double %0, double* nocapture %1) {
%3 = load double, double* %1
%4 = fcmp une double %3, %0
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int remove(char const *);
void delete_memory() {
  const char *filepath = "/tmp/mmapped.bin";
  int ret;
  ret = remove(filepath);
  if (ret == 0) {
    printf("File deleted successfully");
  } else {
    printf("Error: unable to delete the file");
  }
}


x86 assembly (clang, -O0):
<delete_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <remove@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    115a <delete_memory+0x3a>
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
jmp    1166 <delete_memory+0x46>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_memory>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <remove@plt>
test   %eax,%eax
lea    0xedb(%rip),%rax
lea    0xeee(%rip),%rdi
cmove  %rax,%rdi
pop    %rax
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"/tmp/mmapped.bin\00"
@.str.1 = [26 x i8] c"File deleted successfully\00"
@.str.2 = [33 x i8] c"Error: unable to delete the file\00"
define void @delete_memory() {
%1 = alloca i8*
%2 = alloca i32
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = load i8*, i8** %1
%4 = call i32 @remove(i8* %3)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %7
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"/tmp/mmapped.bin\00"
@.str.1 = [26 x i8] c"File deleted successfully\00"
@.str.2 = [33 x i8] c"Error: unable to delete the file\00"
define void @delete_memory() {
%1 = tail call i32 @remove(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0)
%4 = tail call i32 @printf(i8* dereferenceable(1) %3)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ set_bit(int *, int);
int /*<<< orphan*/ unset_bit(int *, int);
void clear(int *bits, int *known) {
  int i;
  scanf("%d", &i);
  unset_bit(bits, i);
  set_bit(known, i);
}


x86 assembly (clang, -O0):
<clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <unset_bit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <set_bit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1050 <unset_bit@plt>
mov    0x4(%rsp),%esi
mov    %r14,%rdi
call   1030 <set_bit@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define void @clear(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = load i32*, i32** %3
%8 = load i32, i32* %5
%9 = call i32 @unset_bit(i32* %7, i32 %8)
%10 = load i32*, i32** %4
%11 = load i32, i32* %5
%12 = call i32 @set_bit(i32* %10, i32 %11)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @clear(i32* %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = call i32 @unset_bit(i32* %0, i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @set_bit(i32* %1, i32 %8)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void usage(void) {
  printf("syntax: spec2def [<options> ...] <spec file>\n"
         "Possible options:\n"
         "  -h --help               print this help screen\n"
         "  -l=<file>               generate an asm lib stub\n"
         "  -d=<file>               generate a def file\n"
         "  -s=<file>               generate a stub file\n"
         "  --ms                    MSVC compatibility\n"
         "  -n=<name>               name of the dll\n"
         "  --implib                generate a def file for an import library\n"
         "  --no-private-warnings   suppress warnings about symbols that "
         "should be -private\n"
         "  -a=<arch>               set architecture to <arch> (i386, x86_64, "
         "arm)\n"
         "  --with-tracing          generate wine-like \"+relay\" trace "
         "trampolines (needs -s)\n");
}


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

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

LLVM IR (-O0):
@.str = [650 x i8] c"syntax: spec2def [<options> ...] <spec file>\0APossible options:\0A -h --help print this help screen\0A -l=<file> generate an asm lib stub\0A -d=<file> generate a def file\0A -s=<file> generate a stub file\0A --ms MSVC compatibility\0A -n=<name> name of the dll\0A --implib generate a def file for an import library\0A --no-private-warnings suppress warnings about symbols that should be -private\0A -a=<arch> set architecture to <arch> (i386, x86_64, arm)\0A --with-tracing generate wine-like \22+relay\22 trace trampolines (needs -s)\0A\00"
define void @usage() {
%1 = call i32 @printf(i8* getelementptr inbounds ([650 x i8], [650 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [649 x i8] c"syntax: spec2def [<options> ...] <spec file>\0APossible options:\0A -h --help print this help screen\0A -l=<file> generate an asm lib stub\0A -d=<file> generate a def file\0A -s=<file> generate a stub file\0A --ms MSVC compatibility\0A -n=<name> name of the dll\0A --implib generate a def file for an import library\0A --no-private-warnings suppress warnings about symbols that should be -private\0A -a=<arch> set architecture to <arch> (i386, x86_64, arm)\0A --with-tracing generate wine-like \22+relay\22 trace trampolines (needs -s)\00"
define void @usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([649 x i8], [649 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ puts(char *);
int main(void) {
  char our_string[] = "Halli Hallo";
  puts(our_string);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movabs $0x614820696c6c6148,%rax
20 48 61
mov    %rax,0x8(%rsp)
movl   $0x6f6c6c,0x10(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.our_string = [12 x i8] c"Halli Hallo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i8]
store i32 0, i32* %1
%3 = bitcast [12 x i8]* %2 to i8*
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 @puts(i8* %4)
ret i32 0
}

LLVM IR (-O2):
@__const.main.our_string = [12 x i8] c"Halli Hallo\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = call i32 @puts(i8* %2)
ret i32 0
}
void testAsymmetricIntSymOperations(int a) {
  if (((~0) >> a) != (~0))
    ((void)*(char *)0);
  if ((0 >> a) != 0)
    ((void)*(char *)0);
  if ((0 << a) != 0)
    ((void)*(char *)0);
  if ((((unsigned)(~0)) >> ((unsigned)a)) != ((unsigned)(~0)))
    ((void)*(char *)0);
}


x86 assembly (clang, -O0):
<testAsymmetricIntSymOperations>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0xffffffff,%eax
sar    %cl,%eax
cmp    $0xffffffff,%eax
je     111a <testAsymmetricIntSymOperations+0x1a>
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
sar    %cl,%eax
cmp    $0x0,%eax
je     112a <testAsymmetricIntSymOperations+0x2a>
mov    -0x4(%rbp),%ecx
xor    %eax,%eax
shl    %cl,%eax
cmp    $0x0,%eax
je     113a <testAsymmetricIntSymOperations+0x3a>
mov    -0x4(%rbp),%ecx
mov    $0xffffffff,%eax
shr    %cl,%eax
cmp    $0xffffffff,%eax
je     114d <testAsymmetricIntSymOperations+0x4d>
pop    %rbp
ret

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

LLVM IR (-O0):
define void @testAsymmetricIntSymOperations(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = ashr i32 -1, %3
%5 = icmp ne i32 %4, -1
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = load i8, i8* null
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* %2
%10 = ashr i32 0, %9
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = load i8, i8* null
br label %14
14: ; preds = %12, %8
%15 = load i32, i32* %2
%16 = shl i32 0, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = load i8, i8* null
br label %20
20: ; preds = %18, %14
%21 = load i32, i32* %2
%22 = lshr i32 -1, %21
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = load i8, i8* null
br label %26
26: ; preds = %24, %20
ret void
}

LLVM IR (-O2):
define void @testAsymmetricIntSymOperations(i32 %0) {
ret void
}
adrreg0adrx1(r0, r1, x0, x1, p0, p1) double r0, r1;
double *p0, *p1;
{
  if ((p0[10000000]) <= (((double *)11111111)[x1]))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<adrreg0adrx1>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
mov    %esi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsd  0x4c4b400(%rax),%xmm1
04
movslq -0x20(%rbp),%rcx
mov    $0xa98ac7,%eax
movsd  (%rax,%rcx,8),%xmm0
ucomisd %xmm1,%xmm0
jb     114c <adrreg0adrx1+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    1153 <adrreg0adrx1+0x53>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<adrreg0adrx1>:
movslq %esi,%rax
movsd  0xa98ac7(,%rax,8),%xmm0
xor    %eax,%eax
ucomisd 0x4c4b400(%rdx),%xmm0
04
setae  %al
ret

LLVM IR (-O0):
define i32 @adrreg0adrx1(double %0, double %1, i32 %2, i32 %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double*
%13 = alloca double*
store double %0, double* %8
store double %1, double* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store double* %4, double** %12
store double* %5, double** %13
%14 = load double*, double** %12
%15 = getelementptr inbounds double, double* %14, i64 10000000
%16 = load double, double* %15
%17 = load i32, i32* %11
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds double, double* inttoptr (i64 11111111 to double*), i64 %18
%20 = load double, double* %19
%21 = fcmp ole double %16, %20
br i1 %21, label %22, label %23
22: ; preds = %6
store i32 1, i32* %7
br label %24
23: ; preds = %6
store i32 0, i32* %7
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %7
ret i32 %25
}

LLVM IR (-O2):
define i32 @adrreg0adrx1(double %0, double %1, i32 %2, i32 %3, double* nocapture %4, double* nocapture readnone %5) {
%7 = getelementptr inbounds double, double* %4, i64 10000000
%8 = load double, double* %7
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds double, double* inttoptr (i64 11111111 to double*), i64 %9
%11 = load double, double* %10
%12 = fcmp ole double %8, %11
%13 = zext i1 %12 to i32
ret i32 %13
}
void freeWorldMutex(struct World *world) {}


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

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

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

LLVM IR (-O2):
%struct.World = type opaque
define void @freeWorldMutex(%struct.World* nocapture %0) {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ dequeue();
int /*<<< orphan*/ enqueue(int);
int /*<<< orphan*/ init_queue();
int /*<<< orphan*/ print_queue();
int main() {
  init_queue();
  print_queue();
  enqueue(1);
  enqueue(2);
  print_queue();
  enqueue(3);
  enqueue(4);
  enqueue(5);
  enqueue(6);
  print_queue();
  dequeue();
  dequeue();
  print_queue();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <init_queue@plt>
mov    $0x0,%al
call   1050 <print_queue@plt>
mov    $0x1,%edi
call   1060 <enqueue@plt>
mov    $0x2,%edi
call   1060 <enqueue@plt>
mov    $0x0,%al
call   1050 <print_queue@plt>
mov    $0x3,%edi
call   1060 <enqueue@plt>
mov    $0x4,%edi
call   1060 <enqueue@plt>
mov    $0x5,%edi
call   1060 <enqueue@plt>
mov    $0x6,%edi
call   1060 <enqueue@plt>
mov    $0x0,%al
call   1050 <print_queue@plt>
mov    $0x0,%al
call   1040 <dequeue@plt>
mov    $0x0,%al
call   1040 <dequeue@plt>
mov    $0x0,%al
call   1050 <print_queue@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <init_queue@plt>
xor    %eax,%eax
call   1050 <print_queue@plt>
mov    $0x1,%edi
call   1060 <enqueue@plt>
mov    $0x2,%edi
call   1060 <enqueue@plt>
xor    %eax,%eax
call   1050 <print_queue@plt>
mov    $0x3,%edi
call   1060 <enqueue@plt>
mov    $0x4,%edi
call   1060 <enqueue@plt>
mov    $0x5,%edi
call   1060 <enqueue@plt>
mov    $0x6,%edi
call   1060 <enqueue@plt>
xor    %eax,%eax
call   1050 <print_queue@plt>
xor    %eax,%eax
call   1040 <dequeue@plt>
xor    %eax,%eax
call   1040 <dequeue@plt>
xor    %eax,%eax
call   1050 <print_queue@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = call i32 (...) @init_queue()
%2 = call i32 (...) @print_queue()
%3 = call i32 @enqueue(i32 1)
%4 = call i32 @enqueue(i32 2)
%5 = call i32 (...) @print_queue()
%6 = call i32 @enqueue(i32 3)
%7 = call i32 @enqueue(i32 4)
%8 = call i32 @enqueue(i32 5)
%9 = call i32 @enqueue(i32 6)
%10 = call i32 (...) @print_queue()
%11 = call i32 (...) @dequeue()
%12 = call i32 (...) @dequeue()
%13 = call i32 (...) @print_queue()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @init_queue()
%2 = tail call i32 (...) @print_queue()
%3 = tail call i32 @enqueue(i32 1)
%4 = tail call i32 @enqueue(i32 2)
%5 = tail call i32 (...) @print_queue()
%6 = tail call i32 @enqueue(i32 3)
%7 = tail call i32 @enqueue(i32 4)
%8 = tail call i32 @enqueue(i32 5)
%9 = tail call i32 @enqueue(i32 6)
%10 = tail call i32 (...) @print_queue()
%11 = tail call i32 (...) @dequeue()
%12 = tail call i32 (...) @dequeue()
%13 = tail call i32 (...) @print_queue()
ret i32 0
}
unsigned char CountBitsInByte(unsigned char byte) {
  unsigned char count = 0;
  while (byte > 0) {
    if (byte & 1) {
      count++;
    }
    byte >>= 1;
  }
  return count;
}


x86 assembly (clang, -O0):
<CountBitsInByte>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movb   $0x0,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x0,%eax
jle    1142 <CountBitsInByte+0x42>
movzbl -0x1(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1133 <CountBitsInByte+0x33>
mov    -0x2(%rbp),%al
add    $0x1,%al
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
sar    $0x1,%eax
mov    %al,-0x1(%rbp)
jmp    110e <CountBitsInByte+0xe>
movzbl -0x2(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<CountBitsInByte>:
xor    %eax,%eax
test   %edi,%edi
je     1121 <CountBitsInByte+0x21>
mov    %edi,%ecx
nopl   0x0(%rax,%rax,1)
mov    %edi,%edx
and    $0x1,%dl
add    %dl,%al
shr    %cl
cmp    $0x1,%dil
mov    %ecx,%edi
ja     1110 <CountBitsInByte+0x10>
ret

LLVM IR (-O0):
define zeroext i8 @CountBitsInByte(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
store i8 %0, i8* %2
store i8 0, i8* %3
br label %4
4: ; preds = %16, %1
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %4
%9 = load i8, i8* %2
%10 = zext i8 %9 to i32
%11 = and i32 %10, 1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i8, i8* %3
%15 = add i8 %14, 1
store i8 %15, i8* %3
br label %16
16: ; preds = %13, %8
%17 = load i8, i8* %2
%18 = zext i8 %17 to i32
%19 = ashr i32 %18, 1
%20 = trunc i32 %19 to i8
store i8 %20, i8* %2
br label %4
21: ; preds = %4
%22 = load i8, i8* %3
ret i8 %22
}

LLVM IR (-O2):
define zeroext i8 @CountBitsInByte(i8 zeroext %0) {
%2 = icmp eq i8 %0, 0
br i1 %2, label %10, label %3
3: ; preds = %1, %3
%4 = phi i8 [ %7, %3 ], [ 0, %1 ]
%5 = phi i8 [ %8, %3 ], [ %0, %1 ]
%6 = and i8 %5, 1
%7 = add i8 %4, %6
%8 = lshr i8 %5, 1
%9 = icmp ult i8 %5, 2
br i1 %9, label %10, label %3
10: ; preds = %3, %1
%11 = phi i8 [ 0, %1 ], [ %7, %3 ]
ret i8 %11
}
int is_octaldigit(char c) { return c <= '7' && c >= '0'; }


x86 assembly (clang, -O0):
<is_octaldigit>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x37,%ecx
mov    %al,-0x2(%rbp)
jg     1129 <is_octaldigit+0x29>
movsbl -0x1(%rbp),%eax
cmp    $0x30,%eax
setge  %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_octaldigit>:
and    $0xf8,%dil
xor    %eax,%eax
cmp    $0x30,%dil
sete   %al
ret

LLVM IR (-O0):
define i32 @is_octaldigit(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = sext i8 %3 to i32
%5 = icmp sle i32 %4, 55
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp sge i32 %8, 48
br label %10
10: ; preds = %6, %1
%11 = phi i1 [ false, %1 ], [ %9, %6 ]
%12 = zext i1 %11 to i32
ret i32 %12
}

LLVM IR (-O2):
define i32 @is_octaldigit(i8 signext %0) {
%2 = and i8 %0, -8
%3 = icmp eq i8 %2, 48
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ return_struct_vi4();
int /*<<< orphan*/ take_struct_vi4(int /*<<< orphan*/);
void test_struct_vi4() { take_struct_vi4(return_struct_vi4()); }


x86 assembly (clang, -O0):
<test_struct_vi4>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1040 <return_struct_vi4@plt>
mov    %eax,%edi
call   1030 <take_struct_vi4@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_struct_vi4>:
push   %rax
xor    %eax,%eax
call   1040 <return_struct_vi4@plt>
mov    %eax,%edi
pop    %rax
jmp    1030 <take_struct_vi4@plt>

LLVM IR (-O0):
define void @test_struct_vi4() {
%1 = call i32 (...) @return_struct_vi4()
%2 = call i32 @take_struct_vi4(i32 %1)
ret void
}

LLVM IR (-O2):
define void @test_struct_vi4() {
%1 = tail call i32 (...) @return_struct_vi4()
%2 = tail call i32 @take_struct_vi4(i32 %1)
ret void
}