xunge/DecIR huggingface dataset:
int test_imm_0Duint64_lowword_mem(unsigned long long *val) {
  return ((*val) & (0x0D << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_0Duint64_lowword_mem(i64* %0) {
%2 = alloca i64*
store i64* %0, i64** %2
%3 = load i64*, i64** %2
%4 = load i64, i64* %3
%5 = and i64 %4, 13
%6 = icmp ne i64 %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_0Duint64_lowword_mem(i64* nocapture %0) {
%2 = load i64, i64* %0
%3 = and i64 %2, 13
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_mutexattr_t;
typedef int /*<<< orphan*/ pthread_mutex_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
scalar_t__ pthread_mutex_init(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
void std_pthread_mutex_init(pthread_mutex_t *mutex,
                            const pthread_mutexattr_t *mutexattr) {
  if (pthread_mutex_init(mutex, mutexattr) != 0) {
    perror("pthread_mutex_init");
    exit(1);
  }
}


x86 assembly (clang, -O0):
<std_pthread_mutex_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <pthread_mutex_init@plt>
cmp    $0x0,%rax
je     116d <std_pthread_mutex_init+0x3d>
lea    0xea2(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<std_pthread_mutex_init>:
push   %rax
call   1050 <pthread_mutex_init@plt>
test   %rax,%rax
jne    113d <std_pthread_mutex_init+0xd>
pop    %rax
ret
lea    0xebc(%rip),%rdi
call   1030 <perror@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

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

LLVM IR (-O2):
@.str = [19 x i8] c"pthread_mutex_init\00"
define void @std_pthread_mutex_init(i32* %0, i32* %1) {
%3 = tail call i64 @pthread_mutex_init(i32* %0, i32* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void displayArray(size_t *array, size_t size) {
  size_t i;
  for (i = 0; i < size; i++)
    printf("%d ", array[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<displayArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1161 <displayArray+0x51>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <displayArray+0x18>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayArray>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1157 <displayArray+0x37>
mov    %rsi,%r12
mov    %rdi,%r14
lea    0xec6(%rip),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1140 <displayArray+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @displayArray(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
store i64* %0, i64** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %16, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = load i64*, i64** %3
%12 = load i64, i64* %5
%13 = getelementptr inbounds i64, i64* %11, i64 %12
%14 = load i64, i64* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %14)
br label %16
16: ; preds = %10
%17 = load i64, i64* %5
%18 = add i64 %17, 1
store i64 %18, i64* %5
br label %6
19: ; preds = %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @displayArray(i64* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %11, label %4
4: ; preds = %2, %4
%5 = phi i64 [ %9, %4 ], [ 0, %2 ]
%6 = getelementptr inbounds i64, i64* %0, i64 %5
%7 = load i64, i64* %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %7)
%9 = add nuw i64 %5, 1
%10 = icmp eq i64 %9, %1
br i1 %10, label %11, label %4
11: ; preds = %4, %2
%12 = tail call i32 @putchar(i32 10)
ret void
}
/* Type definitions */
struct shmid_ds {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int shmctl(int shmid, int cmd, struct shmid_ds *buf) {
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<shmctl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    0x2ebf(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.shmid_ds = type { i32 }
@ENOSYS = global i32 0
define i32 @shmctl(i32 %0, i32 %1, %struct.shmid_ds* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.shmid_ds*
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.shmid_ds* %2, %struct.shmid_ds** %6
%7 = load i32, i32* @ENOSYS
%8 = call i32 @__set_errno(i32 %7)
ret i32 -1
}

LLVM IR (-O2):
%struct.shmid_ds = type { i32 }
@ENOSYS = global i32 0
define i32 @shmctl(i32 %0, i32 %1, %struct.shmid_ds* nocapture readnone %2) {
%4 = load i32, i32* @ENOSYS
%5 = tail call i32 @__set_errno(i32 %4)
ret i32 -1
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
void printError(char *emsg) {
  printf("BigExtract: %s\nBigExtract: calling it a day...", emsg);
  exit(1);
}


x86 assembly (clang, -O0):
<printError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<printError>:
push   %rax
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [47 x i8] c"BigExtract: %s\0ABigExtract: calling it a day...\00"
define void @printError(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [47 x i8] c"BigExtract: %s\0ABigExtract: calling it a day...\00"
define void @printError(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = tail call i32 @exit(i32 1)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int Mult(int num3) {
  int result2 = 0;
  result2 = num3 % 2;
  if (result2 == 0) {
    printf("\nFinal result your number is even\n");
  } else
    printf("\nFinal result your number is odd\n");
  return result2;
}


x86 assembly (clang, -O0):
<Mult>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    114b <Mult+0x3b>
lea    0xebf(%rip),%rdi
call   1030 <printf@plt>
jmp    1157 <Mult+0x47>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mult>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%eax
shr    $0x1f,%eax
add    %edi,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebx
lea    0xefb(%rip),%rax
lea    0xed3(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AFinal result your number is even\0A\00"
@.str.1 = [34 x i8] c"\0AFinal result your number is odd\0A\00"
define i32 @Mult(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = srem i32 %4, 2
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = load i32, i32* %3
ret i32 %13
}

LLVM IR (-O2):
@str = [33 x i8] c"\0AFinal result your number is odd\00"
@str.2 = [34 x i8] c"\0AFinal result your number is even\00"
define i32 @Mult(i32 %0) {
%2 = srem i32 %0, 2
%3 = icmp eq i32 %2, 0
%4 = select i1 %3, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str.2, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0)
%5 = tail call i32 @puts(i8* dereferenceable(1) %4)
ret i32 %2
}
/* Variables and functions */
size_t clp2(const size_t x) {
  size_t i = 0;
  while ((1U << i) < x) {
    i++;
  }
  return (1U << i);
}


x86 assembly (clang, -O0):
<clp2>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%eax
cmp    -0x8(%rbp),%rax
jae    113a <clp2+0x3a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1110 <clp2+0x10>
mov    -0x10(%rbp),%rax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<clp2>:
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%eax
shl    %cl,%eax
add    $0x1,%ecx
cmp    %rdi,%rax
jb     1110 <clp2+0x10>
mov    %eax,%eax
ret

LLVM IR (-O0):
define i64 @clp2(i64 %0) {
%2 = alloca i64
%3 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
br label %4
4: ; preds = %11, %1
%5 = load i64, i64* %3
%6 = trunc i64 %5 to i32
%7 = shl i32 1, %6
%8 = zext i32 %7 to i64
%9 = load i64, i64* %2
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %4
%12 = load i64, i64* %3
%13 = add i64 %12, 1
store i64 %13, i64* %3
br label %4
14: ; preds = %4
%15 = load i64, i64* %3
%16 = trunc i64 %15 to i32
%17 = shl i32 1, %16
%18 = zext i32 %17 to i64
ret i64 %18
}

LLVM IR (-O2):
define i64 @clp2(i64 %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ 0, %1 ], [ %8, %2 ]
%4 = trunc i64 %3 to i32
%5 = shl nuw i32 1, %4
%6 = zext i32 %5 to i64
%7 = icmp ult i64 %6, %0
%8 = add i64 %3, 1
br i1 %7, label %2, label %9
9: ; preds = %2
%10 = zext i32 %5 to i64
ret i64 %10
}
int roundup(int n) {
  int l = 8 - 1;
  return (n + l) & ~l;
}


x86 assembly (clang, -O0):
<roundup>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movl   $0x7,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<roundup>:
lea    0x7(%rdi),%eax
and    $0xfffffff8,%eax
ret

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

LLVM IR (-O2):
define i32 @roundup(i32 %0) {
%2 = add nsw i32 %0, 7
%3 = and i32 %2, -8
ret i32 %3
}
/* Variables and functions */
double lrand48();
__attribute__((__visibility__("default"))) double hts_lrand48(void) {
  return lrand48();
}


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

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

LLVM IR (-O0):
define double @hts_lrand48() {
%1 = call double (...) @lrand48()
ret double %1
}

LLVM IR (-O2):
define double @hts_lrand48() {
%1 = tail call double (...) @lrand48()
ret double %1
}
/* Type definitions */
typedef scalar_t__ base;

/* Variables and functions */
int /*<<< orphan*/ barrier();
void flush(void) {
  unsigned long base = (0x10000000 + 0x00009000);
  while ((*(volatile unsigned char *)((base) + 0x18)) & (1 << 3))
    barrier();
}


x86 assembly (clang, -O0):
<flush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x10009000,-0x8(%rbp)
10
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%al
movzbl %al,%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     1142 <flush+0x32>
mov    $0x0,%al
call   1030 <barrier@plt>
jmp    1120 <flush+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flush>:
push   %rax
testb  $0x8,0x10009018
08
je     1131 <flush+0x21>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <barrier@plt>
testb  $0x8,0x10009018
08
jne    1120 <flush+0x10>
pop    %rax
ret

LLVM IR (-O0):
define void @flush() {
%1 = alloca i64
store i64 268472320, i64* %1
br label %2
2: ; preds = %10, %0
%3 = load i64, i64* %1
%4 = add i64 %3, 24
%5 = inttoptr i64 %4 to i8*
%6 = load volatile i8, i8* %5
%7 = zext i8 %6 to i32
%8 = and i32 %7, 8
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (...) @barrier()
br label %2
12: ; preds = %2
ret void
}

LLVM IR (-O2):
define void @flush() {
%1 = load volatile i8, i8* inttoptr (i64 268472344 to i8*)
%2 = and i8 %1, 8
%3 = icmp eq i8 %2, 0
br i1 %3, label %9, label %4
4: ; preds = %0, %4
%5 = tail call i32 (...) @barrier()
%6 = load volatile i8, i8* inttoptr (i64 268472344 to i8*)
%7 = and i8 %6, 8
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %4
9: ; preds = %4, %0
ret void
}
void lcd_draw_pixel(int row, int col, int color) {
  int *pixel = (int *)(0x3f000000);
  *(pixel + row * (799 + 1) + col) = color;
  return;
}


x86 assembly (clang, -O0):
<lcd_draw_pixel>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x3f000000,%eax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
imul   $0x320,-0x4(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x8(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcd_draw_pixel>:
imul   $0x320,%edi,%eax
cltq
movslq %esi,%rcx
shl    $0x2,%rcx
mov    %edx,0x3f000000(%rcx,%rax,4)
ret

LLVM IR (-O0):
define void @lcd_draw_pixel(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32* inttoptr (i64 1056964608 to i32*), i32** %7
%8 = load i32, i32* %6
%9 = load i32*, i32** %7
%10 = load i32, i32* %4
%11 = mul nsw i32 %10, 800
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %9, i64 %12
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
store i32 %8, i32* %16
ret void
}

LLVM IR (-O2):
define void @lcd_draw_pixel(i32 %0, i32 %1, i32 %2) {
%4 = mul nsw i32 %0, 800
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* inttoptr (i64 1056964608 to i32*), i64 %5
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i32, i32* %6, i64 %7
store i32 %2, i32* %8
ret void
}
void foo452(int p) {}


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

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

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

LLVM IR (-O2):
define void @foo452(i32 %0) {
ret void
}
/* Variables and functions */
int ffs(int const);
int ffsl(long int i) {
  int bitpos;
  bitpos = ffs(i);
  if (bitpos)
    return bitpos;
  const int high_bits = i >> (8 * sizeof(int));
  bitpos = ffs(high_bits);
  if (bitpos)
    return bitpos + (8 * sizeof(int));
  return 0;
}


x86 assembly (clang, -O0):
<ffsl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,%edi
call   1030 <ffs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     113f <ffsl+0x2f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1176 <ffsl+0x66>
mov    -0x10(%rbp),%rax
sar    $0x20,%rax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <ffs@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     116f <ffsl+0x5f>
movslq -0x14(%rbp),%rax
add    $0x20,%rax
mov    %eax,-0x4(%rbp)
jmp    1176 <ffsl+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ffsl>:
test   %edi,%edi
je     110b <ffsl+0xb>
bsf    %edi,%eax
add    $0x1,%eax
ret
shr    $0x20,%rdi
bsf    %edi,%ecx
add    $0x21,%ecx
xor    %eax,%eax
test   %rdi,%rdi
cmovne %ecx,%eax
ret

LLVM IR (-O0):
define i32 @ffsl(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i64 %0, i64* %3
%6 = load i64, i64* %3
%7 = trunc i64 %6 to i32
%8 = call i32 @ffs(i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = load i32, i32* %4
store i32 %12, i32* %2
br label %27
13: ; preds = %1
%14 = load i64, i64* %3
%15 = ashr i64 %14, 32
%16 = trunc i64 %15 to i32
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = call i32 @ffs(i32 %17)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %13
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = add i64 %23, 32
%25 = trunc i64 %24 to i32
store i32 %25, i32* %2
br label %27
26: ; preds = %13
store i32 0, i32* %2
br label %27
27: ; preds = %26, %21, %11
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @ffsl(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @llvm.cttz.i32(i32 %2, i1 true)
%6 = add nuw nsw i32 %5, 1
br label %14
7: ; preds = %1
%8 = lshr i64 %0, 32
%9 = trunc i64 %8 to i32
%10 = icmp eq i32 %9, 0
%11 = tail call i32 @llvm.cttz.i32(i32 %9, i1 true)
%12 = add nuw nsw i32 %11, 33
%13 = select i1 %10, i32 0, i32 %12
br label %14
14: ; preds = %7, %4
%15 = phi i32 [ %6, %4 ], [ %13, %7 ]
ret i32 %15
}
/* Variables and functions */
int /*<<< orphan*/ ENOSYS;
int /*<<< orphan*/ __set_errno(int /*<<< orphan*/);
int socket(int __domain, int __type, int __protocol) {
  __set_errno(ENOSYS);
  return -1;
}


x86 assembly (clang, -O0):
<socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    0x2ec0(%rip),%rax
mov    (%rax),%edi
call   1030 <__set_errno@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@ENOSYS = global i32 0
define i32 @socket(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* @ENOSYS
%8 = call i32 @__set_errno(i32 %7)
ret i32 -1
}

LLVM IR (-O2):
@ENOSYS = global i32 0
define i32 @socket(i32 %0, i32 %1, i32 %2) {
%4 = load i32, i32* @ENOSYS
%5 = tail call i32 @__set_errno(i32 %4)
ret i32 -1
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
__attribute__((__noreturn__)) int error(char *msg, FILE *fp) {
  fprintf(stderr, "ERROR: %s\n", msg);
  fclose(fp);
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeac(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<error>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rdx
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xeb9(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @error(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %3
%7 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32*, i32** %4
%9 = call i32 @fclose(i32* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"ERROR: %s\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @error(i8* %0, i32* nocapture %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i32 @fclose(i32* %1)
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
}
/* Variables and functions */
int /*<<< orphan*/ fgets(char *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ trim_end_lf(char *);
void print_input_form(const char *form_str, char input_str[], size_t len) {
  printf("%s", form_str);
  fgets(input_str, len, stdin);
  trim_end_lf(input_str);
}


x86 assembly (clang, -O0):
<print_input_form>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
call   1030 <trim_end_lf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_input_form>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <fgets@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <trim_end_lf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
define void @print_input_form(i8* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i8*, i8** %4
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %9, i64 %10, i32 %11)
%13 = load i8*, i8** %5
%14 = call i32 @trim_end_lf(i8* %13)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@stdin = global i32 0
define void @print_input_form(i8* %0, i8* %1, i64 %2) {
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = load i32, i32* @stdin
%6 = tail call i32 @fgets(i8* %1, i64 %2, i32 %5)
%7 = tail call i32 @trim_end_lf(i8* %1)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ isspace(int);
void t_isspace_0x0a() {
  Assert_real((isspace(10)),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isspace.c",
              55, ("isspace should be 1 for 0x0a"));
}


x86 assembly (clang, -O0):
<t_isspace_0x0a>:
push   %rbp
mov    %rsp,%rbp
mov    $0xa,%edi
call   1030 <isspace@plt>
mov    %eax,%edi
lea    0xec9(%rip),%rsi
mov    $0x37,%edx
lea    0xf65(%rip),%rcx
call   1040 <Assert_real@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<t_isspace_0x0a>:
push   %rax
mov    $0xa,%edi
call   1030 <isspace@plt>
lea    0xece(%rip),%rsi
lea    0xf6f(%rip),%rcx
mov    %eax,%edi
mov    $0x37,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isspace.c\00"
@.str.1 = [29 x i8] c"isspace should be 1 for 0x0a\00"
define void @t_isspace_0x0a() {
%1 = call i32 @isspace(i32 10)
%2 = call i32 @Assert_real(i32 %1, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isspace.c\00"
@.str.1 = [29 x i8] c"isspace should be 1 for 0x0a\00"
define void @t_isspace_0x0a() {
%1 = tail call i32 @isspace(i32 10)
%2 = tail call i32 @Assert_real(i32 %1, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 55, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int bt_handleNumeric(struct irc_message_t *msg) { return 0; }


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

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

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

LLVM IR (-O2):
%struct.irc_message_t = type opaque
define i32 @bt_handleNumeric(%struct.irc_message_t* nocapture readnone %0) {
ret i32 0
}
int checkCellar(int floor) {
  if (floor != -1)
    return 0;
  else
    return 1;
}


x86 assembly (clang, -O0):
<checkCellar>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     111d <checkCellar+0x1d>
movl   $0x0,-0x4(%rbp)
jmp    1124 <checkCellar+0x24>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkCellar>:
xor    %eax,%eax
cmp    $0xffffffff,%edi
sete   %al
ret

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

LLVM IR (-O2):
define i32 @checkCellar(i32 %0) {
%2 = icmp eq i32 %0, -1
%3 = zext i1 %2 to i32
ret i32 %3
}
void *MemDup(void *p0, void *p1) {
  int size = (char *)p1 - (char *)p0;
  char *cp = malloc(size);
  if (!cp)
    error("Out of memory");
  memcpy(cp, p0, size);
  return cp;
}


x86 assembly (clang, -O0):
<MemDup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1174 <MemDup+0x44>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <error@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rdx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MemDup>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
sub    %r14d,%esi
movslq %esi,%r15
mov    %r15,%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    115c <MemDup+0x2c>
lea    0xeab(%rip),%rdi
xor    %eax,%eax
call   1050 <error@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memcpy@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"Out of memory\00"
define i8* @MemDup(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = load i8*, i8** %3
%9 = ptrtoint i8* %7 to i64
%10 = ptrtoint i8* %8 to i64
%11 = sub i64 %9, %10
%12 = trunc i64 %11 to i32
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = call i8* @malloc(i64 %14)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %20, label %18
18: ; preds = %2
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %2
%21 = load i8*, i8** %6
%22 = load i8*, i8** %3
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = load i8*, i8** %6
ret i8* %25
}

LLVM IR (-O2):
@.str = [14 x i8] c"Out of memory\00"
define i8* @MemDup(i8* %0, i8* %1) {
%3 = ptrtoint i8* %1 to i64
%4 = ptrtoint i8* %0 to i64
%5 = sub i64 %3, %4
%6 = shl i64 %5, 32
%7 = ashr exact i64 %6, 32
%8 = tail call i8* @malloc(i64 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %8, i8* align 1 %0, i64 %7, i1 false)
ret i8* %8
}
unsigned char FillBit(unsigned char Bucket, int bitToFill, int offset) {
  int absoffset = (offset - 8);
  if (absoffset < 0)
    absoffset *= -1;
  Bucket |= (bitToFill << absoffset);
  return Bucket;
}


x86 assembly (clang, -O0):
<FillBit>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x8,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    112a <FillBit+0x2a>
imul   $0xffffffff,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%ecx
movzbl -0x1(%rbp),%eax
or     %ecx,%eax
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillBit>:
mov    %esi,%eax
mov    $0x8,%cl
sub    %dl,%cl
lea    -0x8(%rdx),%esi
cmp    $0x8,%edx
movzbl %cl,%edx
movzbl %sil,%ecx
cmovl  %edx,%ecx
shl    %cl,%eax
or     %edi,%eax
ret

LLVM IR (-O0):
define zeroext i8 @FillBit(i8 zeroext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sub nsw i32 %8, 8
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i32, i32* %7
%14 = mul nsw i32 %13, -1
store i32 %14, i32* %7
br label %15
15: ; preds = %12, %3
%16 = load i32, i32* %5
%17 = load i32, i32* %7
%18 = shl i32 %16, %17
%19 = load i8, i8* %4
%20 = zext i8 %19 to i32
%21 = or i32 %20, %18
%22 = trunc i32 %21 to i8
store i8 %22, i8* %4
%23 = load i8, i8* %4
ret i8 %23
}

LLVM IR (-O2):
define zeroext i8 @FillBit(i8 zeroext %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, -8
%5 = icmp slt i32 %2, 8
%6 = sub i32 8, %2
%7 = select i1 %5, i32 %6, i32 %4
%8 = shl i32 %1, %7
%9 = trunc i32 %8 to i8
%10 = or i8 %9, %0
ret i8 %10
}
/* Type definitions */
typedef int /*<<< orphan*/ wint_t;

/* Variables and functions */
int isprint(int /*<<< orphan*/);
int iswprint(wint_t wc) { return isprint(wc); }


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

x86 assembly (clang, -O2):
<iswprint>:
jmp    1030 <isprint@plt>

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

LLVM IR (-O2):
define i32 @iswprint(i32 %0) {
%2 = tail call i32 @isprint(i32 %0)
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
void OUTPUT(int idx) { printf("Found at index %d.\n", idx); }


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

x86 assembly (clang, -O2):
<OUTPUT>:
mov    %edi,%esi
lea    0xee7(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Found at index %d.\0A\00"
define void @OUTPUT(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %3)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Found at index %d.\0A\00"
define void @OUTPUT(i32 %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stdout;
void print_short(void) { fprintf(stdout, "short function\n"); }


x86 assembly (clang, -O0):
<print_short>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_short>:
mov    0x2ec9(%rip),%rax
mov    (%rax),%edi
lea    0xee0(%rip),%rsi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [16 x i8] c"short function\0A\00"
define void @print_short() {
%1 = load i32, i32* @stdout
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [16 x i8] c"short function\0A\00"
define void @print_short() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int errno;
int *__errno_location(void) { return &errno; }


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

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

LLVM IR (-O0):
@errno = global i32 0
define i32* @__errno_location() {
ret i32* @errno
}

LLVM IR (-O2):
@errno = global i32 0
define i32* @__errno_location() {
ret i32* @errno
}
int one() { return 1; }


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

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

LLVM IR (-O0):
define i32 @one() {
ret i32 1
}

LLVM IR (-O2):
define i32 @one() {
ret i32 1
}
/* Variables and functions */
int rand();
int ri(int range) {
  int k;
  k = rand();
  return k % range;
}


x86 assembly (clang, -O0):
<ri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x4(%rbp)
mov    %edx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ri>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <rand@plt>
cltd
idiv   %ebx
mov    %edx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ri(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @rand()
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = load i32, i32* %2
%7 = srem i32 %5, %6
ret i32 %7
}

LLVM IR (-O2):
define i32 @ri(i32 %0) {
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, %0
ret i32 %3
}
char *return_empty(char *name) { return ""; }


x86 assembly (clang, -O0):
<return_empty>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
lea    0xef1(%rip),%rax
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @return_empty(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @return_empty(i8* nocapture readnone %0) {
ret i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
}
void cli(void) { asm volatile("cli" : : : "cc"); }


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

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

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

LLVM IR (-O2):
define void @cli() {
tail call void asm sideeffect "cli", "~{cc},~{dirflag},~{fpsr},~{flags}"()
ret void
}
/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char const *);
char *setwbdir(char *buf, const char *boardname) {
  sprintf(buf,
          "boards/%s/"
          ".DIR",
          boardname);
  return buf;
}


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

x86 assembly (clang, -O2):
<setwbdir>:
push   %rbx
mov    %rsi,%rdx
mov    %rdi,%rbx
lea    0xee2(%rip),%rsi
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [15 x i8] c"boards/%s/.DIR\00"
define i8* @setwbdir(i8* returned writeonly %0, i8* %1) {
%3 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %1)
ret i8* %0
}
/* Variables and functions */
int /*<<< orphan*/ brc(int, char);
void decreqtparm(int pn) { brc(pn, 'x'); }


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

x86 assembly (clang, -O2):
<decreqtparm>:
mov    $0x78,%esi
jmp    1030 <brc@plt>

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

LLVM IR (-O2):
define void @decreqtparm(i32 %0) {
%2 = tail call i32 @brc(i32 %0, i8 signext 120)
ret void
}
/* Variables and functions */
int f386(int *);
int f387(int *p) { return f386(p); }


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

x86 assembly (clang, -O2):
<f387>:
jmp    1030 <f386@plt>

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

LLVM IR (-O2):
define i32 @f387(i32* %0) {
%2 = tail call i32 @f386(i32* %0)
ret i32 %2
}
int test(int z) {
  if (z == 0) {
    return 1 - z;
  }
  return 1 + z;
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1121 <test+0x21>
mov    $0x1,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    112a <test+0x2a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @test(i32 %0) {
%2 = add nsw i32 %0, 1
ret i32 %2
}
int CFunc() { return 1; }


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

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

LLVM IR (-O0):
define i32 @CFunc() {
ret i32 1
}

LLVM IR (-O2):
define i32 @CFunc() {
ret i32 1
}
/* Variables and functions */
double log(double);
double AT_step_to_N2(double step) { return (log(2.0) / log(step)); }


x86 assembly (clang, -O0):
<AT_step_to_N2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
call   1030 <log@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x10(%rbp),%xmm0
divsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AT_step_to_N2>:
push   %rax
call   1030 <log@plt>
movsd  0xee2(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @AT_step_to_N2(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = call double @log(double 2.000000e+00)
%4 = load double, double* %2
%5 = call double @log(double %4)
%6 = fdiv double %3, %5
ret double %6
}

LLVM IR (-O2):
define double @AT_step_to_N2(double %0) {
%2 = tail call double @log(double %0)
%3 = fdiv double 0x3FE62E42FEFA39EF, %2
ret double %3
}
int ptr_less(const void *o1, const void *o2) { return o1 < o2; }


x86 assembly (clang, -O0):
<ptr_less>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ptr_less>:
xor    %eax,%eax
cmp    %rsi,%rdi
setb   %al
ret

LLVM IR (-O0):
define i32 @ptr_less(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = icmp ult i8* %5, %6
%8 = zext i1 %7 to i32
ret i32 %8
}

LLVM IR (-O2):
define i32 @ptr_less(i8* readnone %0, i8* readnone %1) {
%3 = icmp ult i8* %0, %1
%4 = zext i1 %3 to i32
ret i32 %4
}
char foo(const char *ptr, int off) {
  off += 1;
  return ptr[off];
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define signext i8 @foo(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = add nsw i32 %5, 1
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
ret i8 %11
}

LLVM IR (-O2):
define signext i8 @foo(i8* nocapture %0, i32 %1) {
%3 = add nsw i32 %1, 1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
ret i8 %6
}
/* Variables and functions */
int /*<<< orphan*/ system(char *);
void *animenu_thread(void *ud) {
  char *cmd = (char *)ud;
  system(cmd);
  return (NULL);
}


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

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

LLVM IR (-O0):
define i8* @animenu_thread(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @system(i8* %5)
ret i8* null
}

LLVM IR (-O2):
define noalias i8* @animenu_thread(i8* nocapture %0) {
%2 = tail call i32 @system(i8* %0)
ret i8* null
}
char bitfield_reverse(char x) {
  x = (x & 0xF0) >> 4 | (x & 0x0F) << 4;
  x = (x & 0xCC) >> 2 | (x & 0x33) << 2;
  x = (x & 0xAA) >> 1 | (x & 0x55) << 1;
  return x;
}


x86 assembly (clang, -O0):
<bitfield_reverse>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
and    $0xf0,%eax
sar    $0x4,%eax
movsbl -0x1(%rbp),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
and    $0xcc,%eax
sar    $0x2,%eax
movsbl -0x1(%rbp),%ecx
and    $0x33,%ecx
shl    $0x2,%ecx
or     %ecx,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
and    $0xaa,%eax
sar    $0x1,%eax
movsbl -0x1(%rbp),%ecx
and    $0x55,%ecx
shl    $0x1,%ecx
or     %ecx,%eax
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitfield_reverse>:
rol    $0x4,%dil
mov    %edi,%eax
and    $0x33,%al
shl    $0x2,%al
shr    $0x2,%dil
and    $0x33,%dil
or     %dil,%al
mov    %eax,%ecx
and    $0x55,%cl
add    %cl,%cl
shr    %al
and    $0x55,%al
or     %cl,%al
ret

LLVM IR (-O0):
define signext i8 @bitfield_reverse(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, 240
%6 = ashr i32 %5, 4
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = and i32 %8, 15
%10 = shl i32 %9, 4
%11 = or i32 %6, %10
%12 = trunc i32 %11 to i8
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
%15 = and i32 %14, 204
%16 = ashr i32 %15, 2
%17 = load i8, i8* %2
%18 = sext i8 %17 to i32
%19 = and i32 %18, 51
%20 = shl i32 %19, 2
%21 = or i32 %16, %20
%22 = trunc i32 %21 to i8
store i8 %22, i8* %2
%23 = load i8, i8* %2
%24 = sext i8 %23 to i32
%25 = and i32 %24, 170
%26 = ashr i32 %25, 1
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = and i32 %28, 85
%30 = shl i32 %29, 1
%31 = or i32 %26, %30
%32 = trunc i32 %31 to i8
store i8 %32, i8* %2
%33 = load i8, i8* %2
ret i8 %33
}

LLVM IR (-O2):
define signext i8 @bitfield_reverse(i8 signext %0) {
%2 = tail call i8 @llvm.bitreverse.i8(i8 %0)
ret i8 %2
}
int select_packet(void *workspace, unsigned char *packet, int id1, int id2,
                  int id3, int id4) {
  return 0;
}


x86 assembly (clang, -O0):
<select_packet>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
xor    %eax,%eax
pop    %rbp
ret

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

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

LLVM IR (-O2):
define i32 @select_packet(i8* nocapture readnone %0, i8* nocapture readnone %1, i32 %2, i32 %3, i32 %4, i32 %5) {
ret i32 0
}
int parallel_eternal(void) {
#pragma acc parallel
  {
    while (1)
      ;
  }
  return 0;
}


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

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

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

LLVM IR (-O2):
define i32 @parallel_eternal() {
br label %1
1: ; preds = %0, %1
br label %1
}