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

/* Variables and functions */
int /*<<< orphan*/ _gdbio_read_r(int /*<<< orphan*/ *, int, void *, size_t);
int /*<<< orphan*/ errno;
ssize_t gdbio_read(int fd, void *buf, size_t bytes) {
  return _gdbio_read_r(&errno, fd, buf, bytes);
}


x86 assembly (clang, -O0):
<gdbio_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    0x2eab(%rip),%rdi
call   1030 <_gdbio_read_r@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdbio_read>:
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %edi,%esi
mov    0x2ec1(%rip),%rdi
jmp    1030 <_gdbio_read_r@plt>

LLVM IR (-O0):
@errno = global i32 0
define i32 @gdbio_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 @_gdbio_read_r(i32* @errno, i32 %7, i8* %8, i64 %9)
ret i32 %10
}

LLVM IR (-O2):
@errno = global i32 0
define i32 @gdbio_read(i32 %0, i8* %1, i64 %2) {
%4 = tail call i32 @_gdbio_read_r(i32* @errno, i32 %0, i8* %1, i64 %2)
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, unsigned short);
int /*<<< orphan*/ try_outb(unsigned short);
void expect_ok_outb(unsigned short port) {
  if (!try_outb(port)) {
    printf("[FAIL]\toutb to 0x%02hx failed\n", port);
    exit(1);
  }
  printf("[OK]\toutb to 0x%02hx worked\n", port);
}


x86 assembly (clang, -O0):
<expect_ok_outb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%edi
call   1030 <try_outb@plt>
cmp    $0x0,%eax
jne    116b <expect_ok_outb+0x3b>
lea    0xea8(%rip),%rdi
movzwl -0x2(%rbp),%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xead(%rip),%rdi
movzwl -0x2(%rbp),%esi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect_ok_outb>:
push   %rbx
mov    %edi,%ebx
call   1030 <try_outb@plt>
movzwl %bx,%esi
test   %eax,%eax
je     114c <expect_ok_outb+0x1c>
lea    0xed9(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xead(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"[FAIL]\09outb to 0x%02hx failed\0A\00"
@.str.1 = [29 x i8] c"[OK]\09outb to 0x%02hx worked\0A\00"
define void @expect_ok_outb(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = call i32 @try_outb(i16 zeroext %3)
%5 = icmp ne i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i16, i16* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i16 zeroext %7)
%9 = call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = load i16, i16* %2
%12 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %11)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"[FAIL]\09outb to 0x%02hx failed\0A\00"
@.str.1 = [29 x i8] c"[OK]\09outb to 0x%02hx worked\0A\00"
define void @expect_ok_outb(i16 zeroext %0) {
%2 = tail call i32 @try_outb(i16 zeroext %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i16 zeroext %0)
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void str_timestamp(char *buffer, int buffer_size) {
  time_t time_data;
  struct tm *time_info;
  time(&time_data);
  time_info = localtime(&time_data);
  strftime(buffer, buffer_size, "%Y-%m-%d_%H-%M-%S", time_info);
  buffer[buffer_size - 1] = 0;
}


x86 assembly (clang, -O0):
<str_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <time@plt>
lea    -0x10(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
lea    0xe99(%rip),%rdx
call   1050 <strftime@plt>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_timestamp>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xc(%rsp),%r15
mov    %r15,%rdi
call   1040 <time@plt>
mov    %r15,%rdi
call   1030 <localtime@plt>
lea    0xea6(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
movslq %ebx,%rax
movb   $0x0,-0x1(%rax,%r14,1)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d_%H-%M-%S\00"
define void @str_timestamp(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tm*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32 @time(i32* %5)
%8 = call %struct.tm* @localtime(i32* %5)
store %struct.tm* %8, %struct.tm** %6
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = load %struct.tm*, %struct.tm** %6
%12 = call i32 @strftime(i8* %9, i32 %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %11)
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sub nsw i32 %14, 1
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %13, i64 %16
store i8 0, i8* %17
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%d_%H-%M-%S\00"
define void @str_timestamp(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @time(i32* %3)
%6 = call %struct.tm* @localtime(i32* %3)
%7 = call i32 @strftime(i8* %0, i32 %1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%8 = add nsw i32 %1, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
store i8 0, i8* %10
ret void
}
void output_temp(E, file_number) struct All_variables *E;
int file_number;
{
  int m, nno, i, j, fd;
  static int *temp1;
  static int been_here = 0;
  static int size2, size1;
  char output_file[255];
  return;
}


x86 assembly (clang, -O0):
<output_temp>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
add    $0xa0,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
%struct.All_variables = type opaque
@output_temp.temp1 = internal global i32* null
@output_temp.been_here = internal global i32 0
@output_temp.size2 = internal global i32 0
@output_temp.size1 = internal global i32 0
define void @output_temp(%struct.All_variables* %0, i32 %1) {
%3 = alloca %struct.All_variables*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [255 x i8]
store %struct.All_variables* %0, %struct.All_variables** %3
store i32 %1, i32* %4
ret void
}

LLVM IR (-O2):
%struct.All_variables = type opaque
define void @output_temp(%struct.All_variables* nocapture %0, i32 %1) {
ret void
}
unsigned int slen(const unsigned char *x) {
  unsigned int i = 0;
  while (x[i] != 0x00) {
    i++;
  }
  return i;
}


x86 assembly (clang, -O0):
<slen>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1131 <slen+0x31>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <slen+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<slen>:
mov    $0xffffffff,%eax
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%eax
cmpb   $0x0,(%rdi,%rax,1)
jne    1110 <slen+0x10>
ret

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

LLVM IR (-O2):
define i32 @slen(i8* nocapture %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i32 [ 0, %1 ], [ %8, %2 ]
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
%8 = add i32 %3, 1
br i1 %7, label %9, label %2
9: ; preds = %2
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ __builtin_arm_dbg(int /*<<< orphan*/);
void dbg() { __builtin_arm_dbg(0); }


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

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

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

LLVM IR (-O2):
define void @dbg() {
%1 = tail call i32 @__builtin_arm_dbg(i32 0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void cursorunsave(void) {
  printf("\x1b"
         "8");
}


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

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

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

LLVM IR (-O2):
@.str = [3 x i8] c"\1B8\00"
define void @cursorunsave() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
ret void
}
void UartTx(char ch) {
  while (((*((volatile unsigned int *)((0xFFFD0000 + 0x14)))) & 0x00000002) ==
         0)
    ;
  (*((volatile unsigned int *)((0xFFFD0000 + 0x1C))) = (ch));
}


x86 assembly (clang, -O0):
<UartTx>:
push   %rbp
mov    %rsp,%rbp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0xfffd0014,%eax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    1122 <UartTx+0x22>
jmp    110a <UartTx+0xa>
movsbl -0x1(%rbp),%ecx
mov    $0xfffd001c,%eax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<UartTx>:
mov    $0xfffd0014,%eax
cs nopw 0x0(%rax,%rax,1)
nop
testl  $0x2,(%rax)
je     1110 <UartTx+0x10>
movsbl %dil,%ecx
mov    %ecx,0x8(%rax)
ret

LLVM IR (-O0):
define void @UartTx(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
br label %3
3: ; preds = %7, %1
%4 = load volatile i32, i32* inttoptr (i64 4294770708 to i32*)
%5 = and i32 %4, 2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %3
br label %3
8: ; preds = %3
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
store volatile i32 %10, i32* inttoptr (i64 4294770716 to i32*)
ret void
}

LLVM IR (-O2):
define void @UartTx(i8 signext %0) {
br label %2
2: ; preds = %2, %1
%3 = load volatile i32, i32* inttoptr (i64 4294770708 to i32*)
%4 = and i32 %3, 2
%5 = icmp eq i32 %4, 0
br i1 %5, label %2, label %6
6: ; preds = %2
%7 = sext i8 %0 to i32
store volatile i32 %7, i32* inttoptr (i64 4294770716 to i32*)
ret void
}
/* Variables and functions */
int detect(char *);
int main(int argc, char *argv[]) {
  if (argc < 2)
    return 0x1;
  return detect(argv[1]);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    113c <main+0x2c>
movl   $0x1,-0x4(%rbp)
jmp    114c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <detect@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x2,%edi
jge    111b <main+0xb>
mov    $0x1,%eax
ret
mov    0x8(%rsi),%rdi
jmp    1030 <detect@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @detect(i8* %12)
store i32 %13, i32* %3
br label %14
14: ; preds = %9, %8
%15 = load i32, i32* %3
ret i32 %15
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @detect(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 1, %2 ]
ret i32 %9
}
int contains_wildcard(char *str) {
  int found = 0;
  while (*str) {
    if (*str == '*' || *str == '?') {
      found = 1;
      break;
    }
    ++str;
  }
  return found;
}


x86 assembly (clang, -O0):
<contains_wildcard>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1159 <contains_wildcard+0x59>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
je     113c <contains_wildcard+0x3c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1148 <contains_wildcard+0x48>
movl   $0x1,-0xc(%rbp)
jmp    1159 <contains_wildcard+0x59>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110f <contains_wildcard+0xf>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<contains_wildcard>:
movzbl (%rdi),%eax
test   %al,%al
je     111b <contains_wildcard+0x1b>
cmp    $0x2a,%al
je     1115 <contains_wildcard+0x15>
cmp    $0x3f,%al
je     1115 <contains_wildcard+0x15>
add    $0x1,%rdi
jmp    1100 <contains_wildcard>
mov    $0x1,%eax
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @contains_wildcard(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %19, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 42
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 63
br i1 %17, label %18, label %19
18: ; preds = %13, %8
store i32 1, i32* %3
br label %22
19: ; preds = %13
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %2
br label %4
22: ; preds = %18, %4
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @contains_wildcard(i8* nocapture %0) {
br label %2
2: ; preds = %5, %1
%3 = phi i8* [ %0, %1 ], [ %6, %5 ]
%4 = load i8, i8* %3
switch i8 %4, label %5 [
i8 0, label %7
i8 42, label %8
i8 63, label %8
]
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
7: ; preds = %2
br label %8
8: ; preds = %2, %2, %7
%9 = phi i32 [ 0, %7 ], [ 1, %2 ], [ 1, %2 ]
ret i32 %9
}
int funkyResult() { return 7; }


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

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

LLVM IR (-O0):
define i32 @funkyResult() {
ret i32 7
}

LLVM IR (-O2):
define i32 @funkyResult() {
ret i32 7
}
/* Variables and functions */
scalar_t__ islower(int const);
scalar_t__ isupper(int const);
int isalpha(const int c) {
  return ((isupper(c) != 0) || (islower(c) != 0)) ? 1 : 0;
}


x86 assembly (clang, -O0):
<isalpha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <isupper@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x5(%rbp)
jne    1157 <isalpha+0x37>
mov    -0x4(%rbp),%edi
call   1030 <islower@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%dl
xor    %eax,%eax
mov    $0x1,%ecx
test   $0x1,%dl
cmovne %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isalpha>:
push   %rbx
mov    %edi,%ebx
call   1040 <isupper@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1137 <isalpha+0x17>
pop    %rbx
ret
mov    %ebx,%edi
call   1030 <islower@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isalpha(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i64 @isupper(i32 %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i64 @islower(i32 %7)
%9 = icmp ne i64 %8, 0
br label %10
10: ; preds = %6, %1
%11 = phi i1 [ true, %1 ], [ %9, %6 ]
%12 = zext i1 %11 to i64
%13 = select i1 %11, i32 1, i32 0
ret i32 %13
}

LLVM IR (-O2):
define i32 @isalpha(i32 %0) {
%2 = tail call i64 @isupper(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i64 @islower(i32 %0)
%6 = icmp ne i64 %5, 0
%7 = zext i1 %6 to i32
br label %8
8: ; preds = %4, %1
%9 = phi i32 [ 1, %1 ], [ %7, %4 ]
ret i32 %9
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
char *malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int strlen(char const *);
char *vice_stralloc(const char *str) {
  size_t size;
  char *ptr;
  if (str == NULL) {
    exit(-1);
  }
  size = strlen(str) + 1;
  ptr = malloc(size);
  memcpy(ptr, str, size);
  return ptr;
}


x86 assembly (clang, -O0):
<vice_stralloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1161 <vice_stralloc+0x21>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vice_stralloc>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     117a <vice_stralloc+0x3a>
mov    %rdi,%r15
call   1030 <strlen@plt>
add    $0x1,%eax
movslq %eax,%r14
mov    %r14,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <memcpy@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i8* @vice_stralloc(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @exit(i32 -1)
unreachable
9: ; preds = %1
%10 = load i8*, i8** %2
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 1
%13 = sext i32 %12 to i64
store i64 %13, i64* %3
%14 = load i64, i64* %3
%15 = call i8* @malloc(i64 %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = load i8*, i8** %2
%18 = load i64, i64* %3
%19 = call i32 @memcpy(i8* %16, i8* %17, i64 %18)
%20 = load i8*, i8** %4
ret i8* %20
}

LLVM IR (-O2):
define i8* @vice_stralloc(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @exit(i32 -1)
unreachable
5: ; preds = %1
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = tail call i8* @malloc(i64 %8)
%10 = tail call i32 @memcpy(i8* %9, i8* %0, i64 %8)
ret i8* %9
}
/* Type definitions */
struct pci_dev {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ pci_dev_put(struct pci_dev *);
void swap_pci_ref(struct pci_dev **from, struct pci_dev *to) {
  pci_dev_put(*from);
  *from = to;
}


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

x86 assembly (clang, -O2):
<swap_pci_ref>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rdi
call   1030 <pci_dev_put@plt>
mov    %r14,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.pci_dev = type { i32 }
define void @swap_pci_ref(%struct.pci_dev** %0, %struct.pci_dev* %1) {
%3 = alloca %struct.pci_dev**
%4 = alloca %struct.pci_dev*
store %struct.pci_dev** %0, %struct.pci_dev*** %3
store %struct.pci_dev* %1, %struct.pci_dev** %4
%5 = load %struct.pci_dev**, %struct.pci_dev*** %3
%6 = load %struct.pci_dev*, %struct.pci_dev** %5
%7 = call i32 @pci_dev_put(%struct.pci_dev* %6)
%8 = load %struct.pci_dev*, %struct.pci_dev** %4
%9 = load %struct.pci_dev**, %struct.pci_dev*** %3
store %struct.pci_dev* %8, %struct.pci_dev** %9
ret void
}

LLVM IR (-O2):
%struct.pci_dev = type { i32 }
define void @swap_pci_ref(%struct.pci_dev** nocapture %0, %struct.pci_dev* %1) {
%3 = load %struct.pci_dev*, %struct.pci_dev** %0
%4 = tail call i32 @pci_dev_put(%struct.pci_dev* %3)
store %struct.pci_dev* %1, %struct.pci_dev** %0
ret void
}
int test_imm_A8int8_reg(signed char val) {
  return ((val) & (-0xA8 << 0)) ? -20 : -40;
}


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

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

LLVM IR (-O0):
define i32 @test_imm_A8int8_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, -168
%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_A8int8_reg(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = and i32 %2, -168
%4 = icmp eq i32 %3, 0
%5 = select i1 %4, i32 -40, i32 -20
ret i32 %5
}
int root(int *p, int a) {
  while (p[a] >= 0)
    a = p[a];
  return a;
}


x86 assembly (clang, -O0):
<root>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jl     1130 <root+0x30>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0xc(%rbp)
jmp    110b <root+0xb>
mov    -0xc(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<root>:
mov    %esi,%eax
movslq %esi,%rcx
mov    (%rdi,%rcx,4),%esi
test   %esi,%esi
jns    1100 <root>
ret

LLVM IR (-O0):
define i32 @root(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %12, %2
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %6, i64 %8
%10 = load i32, i32* %9
%11 = icmp sge i32 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %5
%13 = load i32*, i32** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
store i32 %17, i32* %4
br label %5
18: ; preds = %5
%19 = load i32, i32* %4
ret i32 %19
}

LLVM IR (-O2):
define i32 @root(i32* nocapture %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i32 [ %1, %2 ], [ %7, %3 ]
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = icmp sgt i32 %7, -1
br i1 %8, label %3, label %9
9: ; preds = %3
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char const *);
int /*<<< orphan*/ stdin;
char tolower(char);
bool ask_yes_no(const char *msg) {
  char answer = 'n';
  static char buffer[3];
  printf(msg);
  fgets(buffer, 2, stdin);
  answer = tolower(buffer[0]);
  return (answer == 's' || answer == 'y');
}


x86 assembly (clang, -O0):
<ask_yes_no>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x6e,-0x9(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <printf@plt>
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    0x2ee3(%rip),%rdi
mov    $0x2,%esi
call   1040 <fgets@plt>
movsbl 0x2ed2(%rip),%edi
call   1050 <tolower@plt>
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%ecx
mov    $0x1,%al
cmp    $0x73,%ecx
mov    %al,-0xa(%rbp)
je     1191 <ask_yes_no+0x61>
movsbl -0x9(%rbp),%eax
cmp    $0x79,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask_yes_no>:
push   %rax
call   1030 <printf@plt>
mov    0x2eab(%rip),%rax
mov    (%rax),%edx
lea    0x2ef6(%rip),%rdi
mov    $0x2,%esi
call   1040 <fgets@plt>
movsbl 0x2ee5(%rip),%edi
call   1050 <tolower@plt>
cmp    $0x73,%al
sete   %cl
cmp    $0x79,%al
sete   %al
or     %cl,%al
movzbl %al,%eax
pop    %rcx
ret

LLVM IR (-O0):
@ask_yes_no.buffer = internal global [3 x i8] zeroinitializer
@stdin = global i32 0
define i32 @ask_yes_no(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
store i8 110, i8* %3
%4 = load i8*, i8** %2
%5 = call i32 @printf(i8* %4)
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ask_yes_no.buffer, i64 0, i64 0), i32 2, i32 %6)
%8 = load i8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ask_yes_no.buffer, i64 0, i64 0)
%9 = call signext i8 @tolower(i8 signext %8)
store i8 %9, i8* %3
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 115
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 121
br label %17
17: ; preds = %13, %1
%18 = phi i1 [ true, %1 ], [ %16, %13 ]
%19 = zext i1 %18 to i32
ret i32 %19
}

LLVM IR (-O2):
@ask_yes_no.buffer = internal global [3 x i8] zeroinitializer
@stdin = global i32 0
define i32 @ask_yes_no(i8* nocapture %0) {
%2 = tail call i32 @printf(i8* dereferenceable(1) %0)
%3 = load i32, i32* @stdin
%4 = tail call i32 @fgets(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ask_yes_no.buffer, i64 0, i64 0), i32 2, i32 %3)
%5 = load i8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @ask_yes_no.buffer, i64 0, i64 0)
%6 = tail call signext i8 @tolower(i8 signext %5)
%7 = icmp eq i8 %6, 115
%8 = icmp eq i8 %6, 121
%9 = or i1 %7, %8
%10 = zext i1 %9 to i32
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ exit(int);
int getpid();
int /*<<< orphan*/ printf(char *, int, char *);
char *strsignal(int);
void test_signal_handler(int sig) {
  printf("\x1b[33m"
         "%d: signal received: %s\n"
         "\x1b[0m",
         getpid(), strsignal(sig));
  exit(2);
}


x86 assembly (clang, -O0):
<test_signal_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <strsignal@plt>
mov    -0x8(%rbp),%esi
mov    %rax,%rdx
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<test_signal_handler>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <strsignal@plt>
lea    0xea4(%rip),%rdi
mov    %ebp,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [34 x i8] c"\1B[33m%d: signal received: %s\0A\1B[0m\00"
define void @test_signal_handler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 (...) @getpid()
%4 = load i32, i32* %2
%5 = call i8* @strsignal(i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %3, i8* %5)
%7 = call i32 @exit(i32 2)
unreachable
}

LLVM IR (-O2):
@.str = [34 x i8] c"\1B[33m%d: signal received: %s\0A\1B[0m\00"
define void @test_signal_handler(i32 %0) {
%2 = tail call i32 (...) @getpid()
%3 = tail call i8* @strsignal(i32 %0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i32 %2, i8* %3)
%5 = tail call i32 @exit(i32 2)
unreachable
}
extern int max(int n1, int n2) {
  if (n1 > n2) {
    return n1;
  } else {
    return n2;
  }
}


x86 assembly (clang, -O0):
<max>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1121 <max+0x21>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1127 <max+0x27>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<max>:
mov    %esi,%eax
cmp    %esi,%edi
cmovg  %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @max(i32 %0, i32 %1) {
%3 = icmp sgt i32 %0, %1
%4 = select i1 %3, i32 %0, i32 %1
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isxdigit(int);
void t_isxdigit_0x9e() {
  Assert_real((isxdigit(158) == 0),
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/"
              "dg/z88dk/test/suites/ctype/test_isxdigit.c",
              795, ("isxdigit should be 0 for 0x9e"));
}


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

x86 assembly (clang, -O2):
<t_isxdigit_0x9e>:
push   %rax
mov    $0x9e,%edi
call   1030 <isxdigit@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf67(%rip),%rcx
mov    $0x31b,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [169 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_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0x9e\00"
define void @t_isxdigit_0x9e() {
%1 = call i64 @isxdigit(i32 158)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 795, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [169 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_isxdigit.c\00"
@.str.1 = [30 x i8] c"isxdigit should be 0 for 0x9e\00"
define void @t_isxdigit_0x9e() {
%1 = tail call i64 @isxdigit(i32 158)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([169 x i8], [169 x i8]* @.str, i64 0, i64 0), i32 795, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
ret void
}
int main() {
  int a = 3, seven = 7, c = a * seven;
  int b = 15 * a, twenty_two = 22;
  return b / a + c / a - twenty_two;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x7,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0xf,-0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x16,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
sub    -0x18(%rbp),%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
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 3, i32* %2
store i32 7, i32* %3
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = mul nsw i32 %7, %8
store i32 %9, i32* %4
%10 = load i32, i32* %2
%11 = mul nsw i32 15, %10
store i32 %11, i32* %5
store i32 22, i32* %6
%12 = load i32, i32* %5
%13 = load i32, i32* %2
%14 = sdiv i32 %12, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %2
%17 = sdiv i32 %15, %16
%18 = add nsw i32 %14, %17
%19 = load i32, i32* %6
%20 = sub nsw i32 %18, %19
ret i32 %20
}

LLVM IR (-O2):
define i32 @main() {
ret i32 0
}
/* Variables and functions */
void *malloc(size_t);
void *Malloc(size_t size, const char *file, int line) { return (malloc(size)); }


x86 assembly (clang, -O0):
<Malloc>:
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 <malloc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Malloc>:
jmp    1030 <malloc@plt>

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

LLVM IR (-O2):
define noalias i8* @Malloc(i64 %0, i8* nocapture readnone %1, i32 %2) {
%4 = tail call i8* @malloc(i64 %0)
ret i8* %4
}
int ini_errno(int err) { return err & 0xff; }


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

x86 assembly (clang, -O2):
<ini_errno>:
movzbl %dil,%eax
ret

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

LLVM IR (-O2):
define i32 @ini_errno(i32 %0) {
%2 = and i32 %0, 255
ret i32 %2
}
/* Variables and functions */
int /*<<< orphan*/ abort();
void DPSCantHappen() { abort(); }


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

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

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

LLVM IR (-O2):
define void @DPSCantHappen() {
%1 = tail call i32 (...) @abort()
unreachable
}
/* Variables and functions */
bool test_cpu() { return true; }


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

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

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

LLVM IR (-O2):
define i32 @test_cpu() {
ret i32 1
}
/* Variables and functions */
int /*<<< orphan*/ free(char *);
void khs_free(void *ptr) { free((char *)ptr); }


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

x86 assembly (clang, -O2):
<khs_free>:
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @khs_free(i8* nocapture %0) {
%2 = tail call i32 @free(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ assert(void *);
void *calloc(size_t, size_t);
void *twopence_calloc(size_t nmemb, size_t size) {
  void *p;
  if (size == 0 || nmemb == 0)
    return NULL;
  p = calloc(nmemb, size);
  do {
    assert(p);
    return p;
  } while (0);
}


x86 assembly (clang, -O0):
<twopence_calloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1146 <twopence_calloc+0x26>
cmpq   $0x0,-0x10(%rbp)
jne    1153 <twopence_calloc+0x33>
movq   $0x0,-0x8(%rbp)
jmp    1175 <twopence_calloc+0x55>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<twopence_calloc>:
push   %rbx
xor    %ebx,%ebx
test   %rdi,%rdi
je     113d <twopence_calloc+0x1d>
test   %rsi,%rsi
je     113d <twopence_calloc+0x1d>
call   1030 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <assert@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @twopence_calloc(i64 %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i64 %0, i64* %4
store i64 %1, i64* %5
%7 = load i64, i64* %5
%8 = icmp eq i64 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i64, i64* %4
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9, %2
store i8* null, i8** %3
br label %21
13: ; preds = %9
%14 = load i64, i64* %4
%15 = load i64, i64* %5
%16 = call i8* @calloc(i64 %14, i64 %15)
store i8* %16, i8** %6
br label %17
17: ; preds = %13
%18 = load i8*, i8** %6
%19 = call i32 @assert(i8* %18)
%20 = load i8*, i8** %6
store i8* %20, i8** %3
br label %21
21: ; preds = %12, %17
%22 = load i8*, i8** %3
ret i8* %22
}

LLVM IR (-O2):
define i8* @twopence_calloc(i64 %0, i64 %1) {
%3 = icmp eq i64 %1, 0
%4 = icmp eq i64 %0, 0
%5 = or i1 %4, %3
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i8* @calloc(i64 %0, i64 %1)
%8 = tail call i32 @assert(i8* %7)
br label %9
9: ; preds = %2, %6
%10 = phi i8* [ %7, %6 ], [ null, %2 ]
ret i8* %10
}
/* Type definitions */
struct tcmi_rpc {
  int dummy;
};

/* Variables and functions */
long tcmi_rpc_do(struct tcmi_rpc *, unsigned int, long *);
long tcmi_rpc_call2(struct tcmi_rpc *self, unsigned int rpc_num, long param1,
                    long param2) {
  long parameters[6] = {0, 0, 0, 0, 0, 0};
  parameters[0] = param1;
  parameters[1] = param2;
  return tcmi_rpc_do(self, rpc_num, parameters);
}


x86 assembly (clang, -O0):
<tcmi_rpc_call2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1040 <tcmi_rpc_do@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcmi_rpc_call2>:
sub    $0x38,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
mov    %rdx,(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rsp,%rdx
call   1030 <tcmi_rpc_do@plt>
add    $0x38,%rsp
ret

LLVM IR (-O0):
%struct.tcmi_rpc = type { i32 }
define i64 @tcmi_rpc_call2(%struct.tcmi_rpc* %0, i32 %1, i64 %2, i64 %3) {
%5 = alloca %struct.tcmi_rpc*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca [6 x i64]
store %struct.tcmi_rpc* %0, %struct.tcmi_rpc** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = bitcast [6 x i64]* %9 to i8*
%11 = load i64, i64* %7
%12 = getelementptr inbounds [6 x i64], [6 x i64]* %9, i64 0, i64 0
store i64 %11, i64* %12
%13 = load i64, i64* %8
%14 = getelementptr inbounds [6 x i64], [6 x i64]* %9, i64 0, i64 1
store i64 %13, i64* %14
%15 = load %struct.tcmi_rpc*, %struct.tcmi_rpc** %5
%16 = load i32, i32* %6
%17 = getelementptr inbounds [6 x i64], [6 x i64]* %9, i64 0, i64 0
%18 = call i64 @tcmi_rpc_do(%struct.tcmi_rpc* %15, i32 %16, i64* %17)
ret i64 %18
}

LLVM IR (-O2):
%struct.tcmi_rpc = type { i32 }
define i64 @tcmi_rpc_call2(%struct.tcmi_rpc* %0, i32 %1, i64 %2, i64 %3) {
%5 = alloca [6 x i64]
%6 = bitcast [6 x i64]* %5 to i8*
%7 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 2
%8 = bitcast i64* %7 to i8*
%9 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 0
store i64 %2, i64* %9
%10 = getelementptr inbounds [6 x i64], [6 x i64]* %5, i64 0, i64 1
store i64 %3, i64* %10
%11 = call i64 @tcmi_rpc_do(%struct.tcmi_rpc* %0, i32 %1, i64* %9)
ret i64 %11
}
/* Type definitions */
typedef int /*<<< orphan*/ uint64_t;
struct eb_root {
  int dummy;
};
struct eb128_node {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ eb128_compose_264(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/ const);
struct eb128_node *eb128_lookup(struct eb_root *, int /*<<< orphan*/);
struct eb128_node *eb128_lookup_264(struct eb_root *root, const uint64_t lo,
                                    const uint64_t hi) {
  return eb128_lookup(root, eb128_compose_264(lo, hi));
}


x86 assembly (clang, -O0):
<eb128_lookup_264>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <eb128_compose_264@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <eb128_lookup@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eb128_lookup_264>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
mov    %edx,%esi
call   1030 <eb128_compose_264@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <eb128_lookup@plt>

LLVM IR (-O0):
%struct.eb128_node = type { i32 }
%struct.eb_root = type { i32 }
define %struct.eb128_node* @eb128_lookup_264(%struct.eb_root* %0, i32 %1, i32 %2) {
%4 = alloca %struct.eb_root*
%5 = alloca i32
%6 = alloca i32
store %struct.eb_root* %0, %struct.eb_root** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load %struct.eb_root*, %struct.eb_root** %4
%8 = load i32, i32* %5
%9 = load i32, i32* %6
%10 = call i32 @eb128_compose_264(i32 %8, i32 %9)
%11 = call %struct.eb128_node* @eb128_lookup(%struct.eb_root* %7, i32 %10)
ret %struct.eb128_node* %11
}

LLVM IR (-O2):
%struct.eb128_node = type { i32 }
%struct.eb_root = type { i32 }
define %struct.eb128_node* @eb128_lookup_264(%struct.eb_root* %0, i32 %1, i32 %2) {
%4 = tail call i32 @eb128_compose_264(i32 %1, i32 %2)
%5 = tail call %struct.eb128_node* @eb128_lookup(%struct.eb_root* %0, i32 %4)
ret %struct.eb128_node* %5
}
void generate_segv(int val) {
  printf("bla segv\n");
  int *p = 0;
  printf("EIP of segfault: 0x%x\n", &&segfault);
  __asm__ __volatile__(
      "movl $0x600D1, %eax;            movl $0x600D2, %ebx;            movl "
      "$0x600D3, %ecx;            movl $0x600D4, %edx;            movl "
      "$0x600D5, %edi;            movl $0x600D6, %esi;            movl "
      "$0x600D7, %ebp");
segfault:
  __asm__ __volatile__("movl (0x0), %ecx");
}


x86 assembly (clang, -O0):
<generate_segv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
lea    0xed2(%rip),%rdi
xor    %eax,%eax
lea    0x28(%rip),%rsi
call   1030 <printf@plt>
mov    $0x600d1,%eax
mov    $0x600d2,%ebx
mov    $0x600d3,%ecx
mov    $0x600d4,%edx
mov    $0x600d5,%edi
mov    $0x600d6,%esi
mov    $0x600d7,%ebp
mov    0x0,%ecx
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_segv>:
push   %rax
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
lea    0x2a(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x600d1,%eax
mov    $0x600d2,%ebx
mov    $0x600d3,%ecx
mov    $0x600d4,%edx
mov    $0x600d5,%edi
mov    $0x600d6,%esi
mov    $0x600d7,%ebp
mov    0x0,%ecx
pop    %rax
ret

LLVM IR (-O0):
@.str = [10 x i8] c"bla segv\0A\00"
@.str.1 = [23 x i8] c"EIP of segfault: 0x%x\0A\00"
define void @generate_segv(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
store i32 %0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* blockaddress(@generate_segv, %6))
br label %6
6: ; preds = %1, %7
ret void
7: ; No predecessors!
indirectbr i8* undef, [label %6]
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"EIP of segfault: 0x%x\0A\00"
@str = [9 x i8] c"bla segv\00"
define void @generate_segv(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* blockaddress(@generate_segv, %4))
tail call void asm sideeffect "movl $$0x600D1, %eax; movl $$0x600D2, %ebx; movl $$0x600D3, %ecx; movl $$0x600D4, %edx; movl $$0x600D5, %edi; movl $$0x600D6, %esi; movl $$0x600D7, %ebp", "~{dirflag},~{fpsr},~{flags}"()
br label %4
4: ; preds = %1
tail call void asm sideeffect "movl (0x0), %ecx", "~{dirflag},~{fpsr},~{flags}"()
ret void
}
int Convert(int i, int j) {
  if (i >= j)
    return i * (i - 1) / 2 + j - 1;
  if (i <= j)
    return j * (j - 1) / 2 + i - 1;
  return 6121;
}


x86 assembly (clang, -O0):
<Convert>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     1138 <Convert+0x38>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116d <Convert+0x6d>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1166 <Convert+0x66>
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
imul   %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116d <Convert+0x6d>
movl   $0x17e9,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Convert>:
cmp    %esi,%edi
mov    %edi,%eax
cmovl  %esi,%eax
cmovl  %edi,%esi
lea    -0x1(%rax),%ecx
imul   %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
add    %esi,%eax
add    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @Convert(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* %5
%8 = icmp sge i32 %6, %7
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = mul nsw i32 %10, %12
%14 = sdiv i32 %13, 2
%15 = load i32, i32* %5
%16 = add nsw i32 %14, %15
%17 = sub nsw i32 %16, 1
store i32 %17, i32* %3
br label %32
18: ; preds = %2
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %5
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 1
%26 = mul nsw i32 %23, %25
%27 = sdiv i32 %26, 2
%28 = load i32, i32* %4
%29 = add nsw i32 %27, %28
%30 = sub nsw i32 %29, 1
store i32 %30, i32* %3
br label %32
31: ; preds = %18
store i32 6121, i32* %3
br label %32
32: ; preds = %31, %22, %9
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @Convert(i32 %0, i32 %1) {
%3 = icmp slt i32 %0, %1
%4 = select i1 %3, i32 %1, i32 %0
%5 = select i1 %3, i32 %0, i32 %1
%6 = add nsw i32 %4, -1
%7 = mul nsw i32 %6, %4
%8 = sdiv i32 %7, 2
%9 = add nsw i32 %8, %5
%10 = add nsw i32 %9, -1
ret i32 %10
}
void update_entry(const char **e, const char old[], const char new[]) {
  if (*e == old) {
    *e = new;
  }
}


x86 assembly (clang, -O0):
<update_entry>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
jne    112c <update_entry+0x2c>
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_entry>:
cmp    %rsi,(%rdi)
je     1106 <update_entry+0x6>
ret
mov    %rdx,(%rdi)
ret

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

LLVM IR (-O2):
define void @update_entry(i8** nocapture %0, i8* readnone %1, i8* %2) {
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, %1
br i1 %5, label %6, label %7
6: ; preds = %3
store i8* %2, i8** %0
br label %7
7: ; preds = %6, %3
ret void
}