xunge/DecIR huggingface dataset:
/* Variables and functions */
char *imalloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int strlen(char const *);
char *istrdup(const char *s) {
  char *m;
  int l;
  l = strlen(s) + 1;
  m = imalloc(l);
  memcpy(m, s, l);
  return m;
}


x86 assembly (clang, -O0):
<istrdup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <imalloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<istrdup>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
lea    0x1(%rax),%ebp
mov    %ebp,%edi
call   1040 <imalloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @istrdup(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, 1
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = call i8* @imalloc(i32 %8)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = call i32 @memcpy(i8* %10, i8* %11, i32 %12)
%14 = load i8*, i8** %3
ret i8* %14
}

LLVM IR (-O2):
define i8* @istrdup(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @imalloc(i32 %3)
%5 = tail call i32 @memcpy(i8* %4, i8* %0, i32 %3)
ret i8* %4
}
void RTStrToUtf16Tag(void) {}


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

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

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

LLVM IR (-O2):
define void @RTStrToUtf16Tag() {
ret void
}
/* Variables and functions */
float *fvec_new(long);
int /*<<< orphan*/ memcpy(float *, float const *, long);
float *fvec_new_cpy(const float *v, long n) {
  float *ret = fvec_new(n);
  memcpy(ret, v, n * sizeof(*ret));
  return ret;
}


x86 assembly (clang, -O0):
<fvec_new_cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fvec_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
shl    $0x2,%rdx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fvec_new_cpy>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <fvec_new@plt>
mov    %rax,%r15
shl    $0x2,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <memcpy@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define float* @fvec_new_cpy(float* %0, i64 %1) {
%3 = alloca float*
%4 = alloca i64
%5 = alloca float*
store float* %0, float** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
%7 = call float* @fvec_new(i64 %6)
store float* %7, float** %5
%8 = load float*, float** %5
%9 = load float*, float** %3
%10 = load i64, i64* %4
%11 = mul i64 %10, 4
%12 = call i32 @memcpy(float* %8, float* %9, i64 %11)
%13 = load float*, float** %5
ret float* %13
}

LLVM IR (-O2):
define float* @fvec_new_cpy(float* %0, i64 %1) {
%3 = tail call float* @fvec_new(i64 %1)
%4 = shl i64 %1, 2
%5 = tail call i32 @memcpy(float* %3, float* %0, i64 %4)
ret float* %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int main(void) {
  printf("FOO not defined\n");
  return 0;
}


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

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

LLVM IR (-O0):
@.str = [17 x i8] c"FOO not defined\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [16 x i8] c"FOO not defined\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
ret i32 0
}
unsigned int next_multiple(unsigned int a, unsigned int b) {
  return (a + b - 1) / b * b;
}


x86 assembly (clang, -O0):
<next_multiple>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
sub    $0x1,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
imul   -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_multiple>:
lea    (%rdi,%rsi,1),%ecx
add    $0xffffffff,%ecx
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
sub    %edx,%ecx
mov    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @next_multiple(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 = add i32 %5, %6
%8 = sub i32 %7, 1
%9 = load i32, i32* %4
%10 = udiv i32 %8, %9
%11 = load i32, i32* %4
%12 = mul i32 %10, %11
ret i32 %12
}

LLVM IR (-O2):
define i32 @next_multiple(i32 %0, i32 %1) {
%3 = add i32 %0, -1
%4 = add i32 %3, %1
%5 = urem i32 %4, %1
%6 = sub i32 %4, %5
ret i32 %6
}
int main() {
  int i;
  int a;
  i = 0;
  while (i) {
    a = 0;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1128 <main+0x28>
movl   $0x0,-0xc(%rbp)
jmp    1112 <main+0x12>
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
int _isatty(fd)
int fd;
{ return 0; }


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

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

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

LLVM IR (-O2):
define i32 @_isatty(i32 %0) {
ret i32 0
}
main() {
  int x = 1, y = 2, tmp;
  tmp = x;
  x = y;
  y = tmp;
  int a[] = {3, 2, 1, 0};
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x1,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@__const.main.a = [4 x i32] [i32 3, i32 2, i32 1, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
store i32 1, i32* %1
store i32 2, i32* %2
%5 = load i32, i32* %1
store i32 %5, i32* %3
%6 = load i32, i32* %2
store i32 %6, i32* %1
%7 = load i32, i32* %3
store i32 %7, i32* %2
%8 = bitcast [4 x i32]* %4 to i8*
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
void f1(void) {
#pragma omp barrier a
}


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

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

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

LLVM IR (-O2):
define void @f1() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ free(int **);
int **malloc(int);
int /*<<< orphan*/ printf(char *);
int main() {
  int **p;
  int i;
  p = malloc(0x20);
  i = *p[1];
  free(p);
  printf("all done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x20,%edi
call   1050 <malloc@plt>
mov    %rax,%rdi
call   1030 <free@plt>
lea    0xeb6(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"all done\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32**
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32** @malloc(i32 32)
store i32** %4, i32*** %2
%5 = load i32**, i32*** %2
%6 = getelementptr inbounds i32*, i32** %5, i64 1
%7 = load i32*, i32** %6
%8 = load i32, i32* %7
store i32 %8, i32* %3
%9 = load i32**, i32*** %2
%10 = call i32 @free(i32** %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [9 x i8] c"all done\00"
define i32 @main() {
%1 = tail call i32** @malloc(i32 32)
%2 = tail call i32 @free(i32** %1)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
char *getenv(char *);
char *get_temp_dir() {
  char *folder = getenv("TMPDIR");
  return folder ? folder : "/tmp/";
}


x86 assembly (clang, -O0):
<get_temp_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1140 <get_temp_dir+0x30>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1150 <get_temp_dir+0x40>
lea    0xec0(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1150 <get_temp_dir+0x40>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_temp_dir>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xee0(%rip),%rcx
cmove  %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"TMPDIR\00"
@.str.1 = [6 x i8] c"/tmp/\00"
define i8* @get_temp_dir() {
%1 = alloca i8*
%2 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = load i8*, i8** %1
br label %8
7: ; preds = %0
br label %8
8: ; preds = %7, %5
%9 = phi i8* [ %6, %5 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %7 ]
ret i8* %9
}

LLVM IR (-O2):
@.str = [7 x i8] c"TMPDIR\00"
@.str.1 = [6 x i8] c"/tmp/\00"
define i8* @get_temp_dir() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
%3 = select i1 %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1
ret i8* %3
}
const char *__ubsan_default_options() {
  return ":halt_on_error=1"
         ":abort_on_error=1"
         ":print_stacktrace=1";
}


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

x86 assembly (clang, -O2):
<__ubsan_default_options>:
lea    0xef9(%rip),%rax
ret

LLVM IR (-O0):
@.str = [53 x i8] c":halt_on_error=1:abort_on_error=1:print_stacktrace=1\00"
define i8* @__ubsan_default_options() {
ret i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [53 x i8] c":halt_on_error=1:abort_on_error=1:print_stacktrace=1\00"
define i8* @__ubsan_default_options() {
ret i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0)
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int filesize(FILE *fd) {
  int tmp, tmp2 = ftell(fd);
  fseek(fd, 0, SEEK_END);
  tmp = ftell(fd);
  fseek(fd, tmp2, SEEK_SET);
  return tmp;
}


x86 assembly (clang, -O0):
<filesize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1030 <ftell@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filesize>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1030 <ftell@plt>
mov    %eax,%r14d
mov    0x2eb2(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <fseek@plt>
mov    %rbx,%rdi
call   1030 <ftell@plt>
mov    %eax,%ebp
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <fseek@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @filesize(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @ftell(i32* %5)
store i32 %6, i32* %4
%7 = load i32*, i32** %2
%8 = load i32, i32* @SEEK_END
%9 = call i32 @fseek(i32* %7, i32 0, i32 %8)
%10 = load i32*, i32** %2
%11 = call i32 @ftell(i32* %10)
store i32 %11, i32* %3
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = load i32, i32* @SEEK_SET
%15 = call i32 @fseek(i32* %12, i32 %13, i32 %14)
%16 = load i32, i32* %3
ret i32 %16
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
define i32 @filesize(i32* nocapture %0) {
%2 = tail call i32 @ftell(i32* %0)
%3 = load i32, i32* @SEEK_END
%4 = tail call i32 @fseek(i32* %0, i32 0, i32 %3)
%5 = tail call i32 @ftell(i32* %0)
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i32 %2, i32 %6)
ret i32 %5
}
int map_getcolhex(int hex) { return ((hex % 5) * 2) % 5; }


x86 assembly (clang, -O0):
<map_getcolhex>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
shl    $0x1,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_getcolhex>:
movslq %edi,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
add    %eax,%eax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
ret

LLVM IR (-O0):
define i32 @map_getcolhex(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = srem i32 %3, 5
%5 = mul nsw i32 %4, 2
%6 = srem i32 %5, 5
ret i32 %6
}

LLVM IR (-O2):
define i32 @map_getcolhex(i32 %0) {
%2 = srem i32 %0, 5
%3 = shl nsw i32 %2, 1
%4 = srem i32 %3, 5
ret i32 %4
}
int test_imm_C2int8_reg(signed char val) {
  return ((val) & (-0xC2 << 0)) ? -20 : -40;
}


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

x86 assembly (clang, -O2):
<test_imm_C2int8_reg>:
test   $0xffffff3e,%edi
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_C2int8_reg(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = and i32 %2, -194
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void exec_once_2_block(void) { printf("Hello World from a constructor 2\n"); }


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

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

LLVM IR (-O0):
@.str = [34 x i8] c"Hello World from a constructor 2\0A\00"
define void @exec_once_2_block() {
%1 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@str = [33 x i8] c"Hello World from a constructor 2\00"
define void @exec_once_2_block() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ print_pascal_triangle(int);
int main(int argc, char *argv[]) {
  print_pascal_triangle(15);
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xf,%edi
call   1030 <print_pascal_triangle@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @print_pascal_triangle(i32 15)
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @print_pascal_triangle(i32 15)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ return_struct_vl4();
int /*<<< orphan*/ take_struct_vl4(int /*<<< orphan*/);
void test_struct_vl4() { take_struct_vl4(return_struct_vl4()); }


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

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

LLVM IR (-O0):
define void @test_struct_vl4() {
%1 = call i32 (...) @return_struct_vl4()
%2 = call i32 @take_struct_vl4(i32 %1)
ret void
}

LLVM IR (-O2):
define void @test_struct_vl4() {
%1 = tail call i32 (...) @return_struct_vl4()
%2 = tail call i32 @take_struct_vl4(i32 %1)
ret void
}
/* Type definitions */
typedef scalar_t__ int32_t;

/* Variables and functions */
int gca_search_int32(const void *aa, void *bb) {
  const int32_t a = *(const int32_t *)aa;
  const int32_t b = *(int32_t *)bb;
  return (((a) > (b)) - ((b) > (a)));
}


x86 assembly (clang, -O0):
<gca_search_int32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x20(%rbp),%rcx
cmp    -0x18(%rbp),%rcx
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
sub    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<gca_search_int32>:
mov    (%rdi),%rcx
mov    (%rsi),%rdx
xor    %eax,%eax
xor    %esi,%esi
cmp    %rdx,%rcx
setg   %al
setl   %sil
sub    %esi,%eax
ret

LLVM IR (-O0):
define i32 @gca_search_int32(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to i64*
%9 = load i64, i64* %8
store i64 %9, i64* %5
%10 = load i8*, i8** %4
%11 = bitcast i8* %10 to i64*
%12 = load i64, i64* %11
store i64 %12, i64* %6
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = icmp sgt i64 %13, %14
%16 = zext i1 %15 to i32
%17 = load i64, i64* %6
%18 = load i64, i64* %5
%19 = icmp sgt i64 %17, %18
%20 = zext i1 %19 to i32
%21 = sub nsw i32 %16, %20
ret i32 %21
}

LLVM IR (-O2):
define i32 @gca_search_int32(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i64*
%4 = load i64, i64* %3
%5 = bitcast i8* %1 to i64*
%6 = load i64, i64* %5
%7 = icmp sgt i64 %4, %6
%8 = zext i1 %7 to i32
%9 = icmp sgt i64 %6, %4
%10 = sext i1 %9 to i32
%11 = add nsw i32 %10, %8
ret i32 %11
}
/* Variables and functions */
int /*<<< orphan*/ pnc_read_string_from_console_optional(char const *, char *,
                                                         int, int);
void pnc_read_string_from_console(char const *message, char *val, int size) {
  pnc_read_string_from_console_optional(message, val, size, false);
}


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

x86 assembly (clang, -O2):
<pnc_read_string_from_console>:
xor    %ecx,%ecx
jmp    1030 <pnc_read_string_from_console_optional@plt>

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

LLVM IR (-O2):
define void @pnc_read_string_from_console(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @pnc_read_string_from_console_optional(i8* %0, i8* %1, i32 %2, i32 0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ ABMON_4;
char *nl_langinfo(int /*<<< orphan*/);
char *langinfo_abmon_4() { return nl_langinfo(ABMON_4); }


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

x86 assembly (clang, -O2):
<langinfo_abmon_4>:
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
jmp    1030 <nl_langinfo@plt>

LLVM IR (-O0):
@ABMON_4 = global i32 0
define i8* @langinfo_abmon_4() {
%1 = load i32, i32* @ABMON_4
%2 = call i8* @nl_langinfo(i32 %1)
ret i8* %2
}

LLVM IR (-O2):
@ABMON_4 = global i32 0
define i8* @langinfo_abmon_4() {
%1 = load i32, i32* @ABMON_4
%2 = tail call i8* @nl_langinfo(i32 %1)
ret i8* %2
}
void wirebus_timer_handler() {}


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

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

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

LLVM IR (-O2):
define void @wirebus_timer_handler() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void die(const char *msg) {
  fprintf(stderr, "can't preload: %s\n", msg);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<die>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xec0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<die>:
push   %rax
mov    %rdi,%rdx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"can't preload: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @die(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i32, i32* @EXIT_FAILURE
%7 = call i32 @exit(i32 %6)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"can't preload: %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @die(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = load i32, i32* @EXIT_FAILURE
%5 = tail call i32 @exit(i32 %4)
unreachable
}
void RTVfsFileRetain(void) {}


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

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

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

LLVM IR (-O2):
define void @RTVfsFileRetain() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  printf("%s\n", "smsrail version 0.01.00 (00100)");
  return (0);
}


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

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

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [32 x i8] c"smsrail version 0.01.00 (00100)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [32 x i8] c"smsrail version 0.01.00 (00100)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}
void XScreenResourceString() {}


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

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

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

LLVM IR (-O2):
define void @XScreenResourceString() {
ret void
}
_Complex double f2(void) {
  double x;
  return x;
}


x86 assembly (clang, -O0):
<f2>:
push   %rbp
mov    %rsp,%rbp
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
pop    %rbp
ret

x86 assembly (clang, -O2):
<f2>:
xorps  %xmm1,%xmm1
ret

LLVM IR (-O0):
define { double, double } @f2() {
%1 = alloca { double, double }
%2 = alloca double
%3 = load double, double* %2
%4 = getelementptr inbounds { double, double }, { double, double }* %1, i32 0, i32 0
%5 = getelementptr inbounds { double, double }, { double, double }* %1, i32 0, i32 1
store double %3, double* %4
store double 0.000000e+00, double* %5
%6 = load { double, double }, { double, double }* %1
ret { double, double } %6
}

LLVM IR (-O2):
define { double, double } @f2() {
ret { double, double } { double undef, double 0.000000e+00 }
}
/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ ft_putcharerrno(char);
int /*<<< orphan*/ ft_putstrerrno(char *);
void ft_error(char *msg) {
  ft_putstrerrno(msg);
  ft_putcharerrno('\n');
  exit(0);
}


x86 assembly (clang, -O0):
<ft_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <ft_putstrerrno@plt>
mov    $0xa,%edi
call   1040 <ft_putcharerrno@plt>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<ft_error>:
push   %rax
call   1030 <ft_putstrerrno@plt>
mov    $0xa,%edi
call   1040 <ft_putcharerrno@plt>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define void @ft_error(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @ft_putstrerrno(i8* %3)
%5 = call i32 @ft_putcharerrno(i8 signext 10)
%6 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
define void @ft_error(i8* %0) {
%2 = tail call i32 @ft_putstrerrno(i8* %0)
%3 = tail call i32 @ft_putcharerrno(i8 signext 10)
%4 = tail call i32 @exit(i32 0)
unreachable
}
void gdk_pixbuf_render_threshold_alpha() {}


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

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

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

LLVM IR (-O2):
define void @gdk_pixbuf_render_threshold_alpha() {
ret void
}
void foo379(int p) {}


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

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

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

LLVM IR (-O2):
define void @foo379(i32 %0) {
ret void
}
int test_imm_F3int32_mem(int *val) {
  return ((*val) & (0xF3 << 0)) ? -20 : -40;
}


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

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

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

LLVM IR (-O2):
define i32 @test_imm_F3int32_mem(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = and i32 %2, 243
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
double fmod(double x, double y) { asm volatile("int $13"); }


x86 assembly (clang, -O0):
<fmod>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
int    $0xd
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmod>:
int    $0xd
ret

LLVM IR (-O0):
define double @fmod(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %3
ret double %6
}

LLVM IR (-O2):
define double @fmod(double %0, double %1) {
tail call void asm sideeffect "int $$13", "~{dirflag},~{fpsr},~{flags}"()
ret double undef
}
/* Variables and functions */
long long output_param(char *, int, int, char *, int /*<<< orphan*/ *,
                       int /*<<< orphan*/);
long long dump_SMALL_IO_Completion(char *buffer, int length, int offset) {
  offset += 16;
  long long complete_size =
      output_param(buffer, offset, 8, "Complete_size", NULL, 0);
  return complete_size;
}


x86 assembly (clang, -O0):
<dump_SMALL_IO_Completion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    $0x8,%edx
lea    0xec2(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
call   1030 <output_param@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_SMALL_IO_Completion>:
lea    0x10(%rdx),%esi
lea    0xee6(%rip),%rcx
mov    $0x8,%edx
xor    %r8d,%r8d
xor    %r9d,%r9d
jmp    1030 <output_param@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Complete_size\00"
define i64 @dump_SMALL_IO_Completion(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = add nsw i32 %8, 16
store i32 %9, i32* %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %6
%12 = call i64 @output_param(i8* %10, i32 %11, i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* null, i32 0)
store i64 %12, i64* %7
%13 = load i64, i64* %7
ret i64 %13
}

LLVM IR (-O2):
@.str = [14 x i8] c"Complete_size\00"
define i64 @dump_SMALL_IO_Completion(i8* %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, 16
%5 = tail call i64 @output_param(i8* %0, i32 %4, i32 8, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32* null, i32 0)
ret i64 %5
}
void exch5(int *a, int *b) { *b = *a + *b - (*a = *b); }


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

x86 assembly (clang, -O2):
<exch5>:
mov    (%rdi),%eax
mov    (%rsi),%ecx
mov    %ecx,(%rdi)
mov    %eax,(%rsi)
ret

LLVM IR (-O0):
define void @exch5(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* %5
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = add nsw i32 %6, %8
%10 = load i32*, i32** %4
%11 = load i32, i32* %10
%12 = load i32*, i32** %3
store i32 %11, i32* %12
%13 = sub nsw i32 %9, %11
%14 = load i32*, i32** %4
store i32 %13, i32* %14
ret void
}

LLVM IR (-O2):
define void @exch5(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = load i32, i32* %1
store i32 %4, i32* %0
store i32 %3, i32* %1
ret void
}
char isValidColor(char color) { return color >= 0 && color <= 15; }


x86 assembly (clang, -O0):
<isValidColor>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2(%rbp)
jl     1129 <isValidColor+0x29>
movsbl -0x1(%rbp),%eax
cmp    $0xf,%eax
setle  %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movsbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isValidColor>:
cmp    $0x10,%dil
setb   %al
ret

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

LLVM IR (-O2):
define signext i8 @isValidColor(i8 signext %0) {
%2 = icmp ult i8 %0, 16
%3 = zext i1 %2 to i8
ret i8 %3
}
/* Type definitions */
struct mp_log {
  int dummy;
};

/* Variables and functions */
int mp_msg_level(struct mp_log *);
bool mp_msg_test(struct mp_log *log, int lev) {
  return lev <= mp_msg_level(log);
}


x86 assembly (clang, -O0):
<mp_msg_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <mp_msg_level@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp_msg_test>:
push   %rbx
mov    %esi,%ebx
call   1030 <mp_msg_level@plt>
xor    %ecx,%ecx
cmp    %ebx,%eax
setge  %cl
mov    %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.mp_log = type { i32 }
define i32 @mp_msg_test(%struct.mp_log* %0, i32 %1) {
%3 = alloca %struct.mp_log*
%4 = alloca i32
store %struct.mp_log* %0, %struct.mp_log** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = load %struct.mp_log*, %struct.mp_log** %3
%7 = call i32 @mp_msg_level(%struct.mp_log* %6)
%8 = icmp sle i32 %5, %7
%9 = zext i1 %8 to i32
ret i32 %9
}

LLVM IR (-O2):
%struct.mp_log = type { i32 }
define i32 @mp_msg_test(%struct.mp_log* %0, i32 %1) {
%3 = tail call i32 @mp_msg_level(%struct.mp_log* %0)
%4 = icmp sge i32 %3, %1
%5 = zext i1 %4 to i32
ret i32 %5
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned short fa_read_ushort(FILE *fp) {
  unsigned short cx;
  unsigned char temp[2];
  int ret;
  ret = fread(temp, sizeof(*temp), 2, fp);
  cx = temp[0];
  cx |= (unsigned short)temp[1] << 8;
  return cx;
}


x86 assembly (clang, -O0):
<fa_read_ushort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
mov    %eax,-0x10(%rbp)
movzbl -0xc(%rbp),%eax
mov    %ax,-0xa(%rbp)
movzbl -0xb(%rbp),%eax
movzwl %ax,%ecx
shl    $0x8,%ecx
movzwl -0xa(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fa_read_ushort>:
push   %rax
mov    %rdi,%rcx
lea    0x6(%rsp),%rdi
mov    $0x1,%esi
mov    $0x2,%edx
call   1030 <fread@plt>
movzwl 0x6(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
define zeroext i16 @fa_read_ushort(i32* %0) {
%2 = alloca i32*
%3 = alloca i16
%4 = alloca [2 x i8]
%5 = alloca i32
store i32* %0, i32** %2
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%7 = load i32*, i32** %2
%8 = call i32 @fread(i8* %6, i32 1, i32 2, i32* %7)
store i32 %8, i32* %5
%9 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 0
%10 = load i8, i8* %9
%11 = zext i8 %10 to i16
store i16 %11, i16* %3
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %4, i64 0, i64 1
%13 = load i8, i8* %12
%14 = zext i8 %13 to i16
%15 = zext i16 %14 to i32
%16 = shl i32 %15, 8
%17 = load i16, i16* %3
%18 = zext i16 %17 to i32
%19 = or i32 %18, %16
%20 = trunc i32 %19 to i16
store i16 %20, i16* %3
%21 = load i16, i16* %3
ret i16 %21
}

LLVM IR (-O2):
define zeroext i16 @fa_read_ushort(i32* nocapture %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = call i32 @fread(i8* %3, i32 1, i32 2, i32* %0)
%5 = load i8, i8* %3
%6 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i16
%9 = shl nuw i16 %8, 8
%10 = zext i8 %5 to i16
%11 = or i16 %9, %10
ret i16 %11
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ pthread_mutex_lock(int /*<<< orphan*/ *);
int pthread_mutex_lock_d(pthread_mutex_t *m, const char *FILENAME,
                         const int LINENO) {
  pthread_mutex_lock(m);
  return (0);
}


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

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

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

LLVM IR (-O2):
define i32 @pthread_mutex_lock_d(i32* %0, i8* nocapture readnone %1, i32 %2) {
%4 = tail call i32 @pthread_mutex_lock(i32* %0)
ret i32 0
}
/* Type definitions */
struct semaphore {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ sema_init(struct semaphore *, int);
void init_MUTEX(struct semaphore *sem) { sema_init(sem, 1); }


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

x86 assembly (clang, -O2):
<init_MUTEX>:
mov    $0x1,%esi
jmp    1030 <sema_init@plt>

LLVM IR (-O0):
%struct.semaphore = type { i32 }
define void @init_MUTEX(%struct.semaphore* %0) {
%2 = alloca %struct.semaphore*
store %struct.semaphore* %0, %struct.semaphore** %2
%3 = load %struct.semaphore*, %struct.semaphore** %2
%4 = call i32 @sema_init(%struct.semaphore* %3, i32 1)
ret void
}

LLVM IR (-O2):
%struct.semaphore = type { i32 }
define void @init_MUTEX(%struct.semaphore* %0) {
%2 = tail call i32 @sema_init(%struct.semaphore* %0, i32 1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void stdlibHello() { printf("hello, stdlib\n"); }


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

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

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

LLVM IR (-O2):
@str = [14 x i8] c"hello, stdlib\00"
define void @stdlibHello() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
ret void
}
/* Type definitions */
struct activity {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ stub_print_net_sock_stats(struct activity *, int, int,
                                             unsigned long long, int);
void print_avg_net_sock_stats(struct activity *a, int prev, int curr,
                              unsigned long long itv) {
  stub_print_net_sock_stats(a, prev, curr, itv, 1);
}


x86 assembly (clang, -O0):
<print_avg_net_sock_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%r8d
call   1030 <stub_print_net_sock_stats@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_avg_net_sock_stats>:
mov    $0x1,%r8d
jmp    1030 <stub_print_net_sock_stats@plt>

LLVM IR (-O0):
%struct.activity = type { i32 }
define void @print_avg_net_sock_stats(%struct.activity* %0, i32 %1, i32 %2, i64 %3) {
%5 = alloca %struct.activity*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store %struct.activity* %0, %struct.activity** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i64 %3, i64* %8
%9 = load %struct.activity*, %struct.activity** %5
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = load i64, i64* %8
%13 = call i32 @stub_print_net_sock_stats(%struct.activity* %9, i32 %10, i32 %11, i64 %12, i32 1)
ret void
}

LLVM IR (-O2):
%struct.activity = type { i32 }
define void @print_avg_net_sock_stats(%struct.activity* %0, i32 %1, i32 %2, i64 %3) {
%5 = tail call i32 @stub_print_net_sock_stats(%struct.activity* %0, i32 %1, i32 %2, i64 %3, i32 1)
ret void
}
long data_long(data)
char *data;
{
  return (atol(&data[6]) + 1900) * 10000L + atol(&data[3]) * 100L +
         (atol(&data[0]));
}


x86 assembly (clang, -O0):
<data_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x6,%rdi
mov    $0x0,%al
call   1030 <atol@plt>
add    $0x76c,%eax
cltq
imul   $0x2710,%rax,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    $0x0,%al
call   1030 <atol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
imul   $0x64,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <atol@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<data_long>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
add    $0x6,%rdi
xor    %eax,%eax
call   1030 <atol@plt>
add    $0x76c,%eax
cltq
imul   $0x2710,%rax,%r14
lea    0x3(%r15),%rdi
xor    %eax,%eax
call   1030 <atol@plt>
cltq
imul   $0x64,%rax,%rbx
add    %r14,%rbx
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <atol@plt>
cltq
add    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @data_long(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 6
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %4)
%6 = add nsw i32 %5, 1900
%7 = sext i32 %6 to i64
%8 = mul nsw i64 %7, 10000
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 3
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %10)
%12 = sext i32 %11 to i64
%13 = mul nsw i64 %12, 100
%14 = add nsw i64 %8, %13
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %16)
%18 = sext i32 %17 to i64
%19 = add nsw i64 %14, %18
ret i64 %19
}

LLVM IR (-O2):
define i64 @data_long(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 6
%3 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %2)
%4 = add nsw i32 %3, 1900
%5 = sext i32 %4 to i64
%6 = mul nsw i64 %5, 10000
%7 = getelementptr inbounds i8, i8* %0, i64 3
%8 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %7)
%9 = sext i32 %8 to i64
%10 = mul nsw i64 %9, 100
%11 = add nsw i64 %6, %10
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @atol to i32 (i8*, ...)*)(i8* %0)
%13 = sext i32 %12 to i64
%14 = add nsw i64 %11, %13
ret i64 %14
}
void insb(int port, void *addr, unsigned long count) {
  asm volatile("rep; ins"
               "b"
               : "+D"(addr), "+c"(count)
               : "d"(port));
}


x86 assembly (clang, -O0):
<insb>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x4(%rbp),%edx
rep insb (%dx),%es:(%rdi)
mov    %rdi,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
pop    %rbp
ret

x86 assembly (clang, -O2):
<insb>:
mov    %rdx,%rcx
mov    %edi,%edx
mov    %rsi,%rdi
rep insb (%dx),%es:(%rdi)
ret

LLVM IR (-O0):
define void @insb(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 i8*, i8** %5
%8 = load i64, i64* %6
%9 = load i32, i32* %4
%10 = call { i8*, i64 } asm sideeffect "rep; insb", "={di},={cx},{dx},0,1,~{dirflag},~{fpsr},~{flags}"(i32 %9, i8* %7, i64 %8)
%11 = extractvalue { i8*, i64 } %10, 0
%12 = extractvalue { i8*, i64 } %10, 1
store i8* %11, i8** %5
store i64 %12, i64* %6
ret void
}

LLVM IR (-O2):
define void @insb(i32 %0, i8* %1, i64 %2) {
%4 = tail call { i8*, i64 } asm sideeffect "rep; insb", "={di},={cx},{dx},0,1,~{dirflag},~{fpsr},~{flags}"(i32 %0, i8* %1, i64 %2)
ret void
}
/* Variables and functions */
int read(int, void *, size_t);
int posix_read(int fd, void *buf, size_t n) { return read(fd, buf, n); }


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

x86 assembly (clang, -O2):
<posix_read>:
jmp    1030 <read@plt>

LLVM IR (-O0):
define i32 @posix_read(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* %4
%8 = load i8*, i8** %5
%9 = load i64, i64* %6
%10 = call i32 @read(i32 %7, i8* %8, i64 %9)
ret i32 %10
}

LLVM IR (-O2):
define i32 @posix_read(i32 %0, i8* nocapture %1, i64 %2) {
%4 = tail call i32 @read(i32 %0, i8* %1, i64 %2)
ret i32 %4
}