xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
void usage(const char *path) {
  printf("Usage: %s [tty path]\n"
         "Runs the FBUS protocol on a given terminal.\n",
         path);
}


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

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

LLVM IR (-O0):
@.str = [66 x i8] c"Usage: %s [tty path]\0ARuns the FBUS protocol on a given terminal.\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"Usage: %s [tty path]\0ARuns the FBUS protocol on a given terminal.\0A\00"
define void @usage(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ my_putchar(char);
int my_isneg(int n) {
  if (n >= 0)
    my_putchar('P');
  else
    my_putchar('N');
  return (0);
}


x86 assembly (clang, -O0):
<my_isneg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1134 <my_isneg+0x24>
mov    $0x50,%edi
call   1030 <my_putchar@plt>
jmp    113e <my_isneg+0x2e>
mov    $0x4e,%edi
call   1030 <my_putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_isneg>:
push   %rax
not    %edi
shr    $0x1f,%edi
add    %edi,%edi
add    $0x4e,%edi
call   1030 <my_putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @my_isneg(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = call i32 @my_putchar(i8 signext 80)
br label %9
7: ; preds = %1
%8 = call i32 @my_putchar(i8 signext 78)
br label %9
9: ; preds = %7, %5
ret i32 0
}

LLVM IR (-O2):
define i32 @my_isneg(i32 %0) {
%2 = icmp sgt i32 %0, -1
%3 = select i1 %2, i8 80, i8 78
%4 = tail call i32 @my_putchar(i8 signext %3)
ret i32 0
}
void RTPathGetCurrent(void) {}


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

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

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

LLVM IR (-O2):
define void @RTPathGetCurrent() {
ret void
}
int num_digits(int n) {
  if (n < 10)
    return 1;
  else
    return 1 + num_digits(n / 10);
}


x86 assembly (clang, -O0):
<num_digits>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    1131 <num_digits+0x21>
movl   $0x1,-0x4(%rbp)
jmp    1149 <num_digits+0x39>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <num_digits@plt>
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<num_digits>:
mov    $0x1,%eax
cmp    $0xa,%edi
jl     1134 <num_digits+0x34>
mov    $0x1,%eax
mov    $0xcccccccd,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %edi,%edx
imul   %rcx,%rdx
shr    $0x23,%rdx
add    $0x1,%eax
cmp    $0x63,%edi
mov    %edx,%edi
ja     1120 <num_digits+0x20>
ret

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

LLVM IR (-O2):
define i32 @num_digits(i32 %0) {
%2 = icmp slt i32 %0, 10
br i1 %2, label %11, label %3
3: ; preds = %1, %3
%4 = phi i32 [ %6, %3 ], [ %0, %1 ]
%5 = phi i32 [ %7, %3 ], [ 0, %1 ]
%6 = udiv i32 %4, 10
%7 = add nuw nsw i32 %5, 1
%8 = icmp ult i32 %4, 100
br i1 %8, label %9, label %3
9: ; preds = %3
%10 = add nuw i32 %5, 2
br label %11
11: ; preds = %9, %1
%12 = phi i32 [ 1, %1 ], [ %10, %9 ]
ret i32 %12
}
/* Type definitions */
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
int /*<<< orphan*/ logprintf(int /*<<< orphan*/, char *);
int sqlite_add_permission(int /*<<< orphan*/ *, char *, char *);
int mode_grant(sqlite3 *db, int argc, char **argv) {
  if (argc < 3) {
    logprintf(0, "Not enough arguments for grant\n\n");
    return 20;
  }
  return sqlite_add_permission(db, argv[1], argv[2]);
}


x86 assembly (clang, -O0):
<mode_grant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1157 <mode_grant+0x37>
xor    %edi,%edi
lea    0xeba(%rip),%rsi
call   1040 <logprintf@plt>
movl   $0x14,-0x4(%rbp)
jmp    1173 <mode_grant+0x53>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rdx
call   1030 <sqlite_add_permission@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mode_grant>:
push   %rax
cmp    $0x2,%esi
jg     113b <mode_grant+0x1b>
lea    0xed3(%rip),%rsi
xor    %edi,%edi
call   1040 <logprintf@plt>
mov    $0x14,%eax
pop    %rcx
ret
mov    0x8(%rdx),%rsi
mov    0x10(%rdx),%rdx
pop    %rax
jmp    1030 <sqlite_add_permission@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Not enough arguments for grant\0A\0A\00"
define i32 @mode_grant(i32* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i8**
store i32* %0, i32** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 3
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @logprintf(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 20, i32* %4
br label %21
12: ; preds = %3
%13 = load i32*, i32** %5
%14 = load i8**, i8*** %7
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8**, i8*** %7
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @sqlite_add_permission(i32* %13, i8* %16, i8* %19)
store i32 %20, i32* %4
br label %21
21: ; preds = %12, %10
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@.str = [33 x i8] c"Not enough arguments for grant\0A\0A\00"
define i32 @mode_grant(i32* %0, i32 %1, i8** nocapture %2) {
%4 = icmp slt i32 %1, 3
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = tail call i32 @logprintf(i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %13
7: ; preds = %3
%8 = getelementptr inbounds i8*, i8** %2, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %2, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @sqlite_add_permission(i32* %0, i8* %9, i8* %11)
br label %13
13: ; preds = %7, %5
%14 = phi i32 [ 20, %5 ], [ %12, %7 ]
ret i32 %14
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *);
void fun() { printf("hello\n"); }


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

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

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

LLVM IR (-O2):
@str = [6 x i8] c"hello\00"
define void @fun() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
ret void
}
void fire(void) {}


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

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

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

LLVM IR (-O2):
define void @fire() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int f(int a, int b) {
  printf("a %d b %d\n", a, b);
  return 7 * a - b;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
imul   $0x7,-0x4(%rbp),%eax
sub    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xee2(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
lea    0x0(,%rbx,8),%eax
sub    %ebx,%eax
sub    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"a %d b %d\0A\00"
define i32 @f(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %3
%9 = mul nsw i32 7, %8
%10 = load i32, i32* %4
%11 = sub nsw i32 %9, %10
ret i32 %11
}

LLVM IR (-O2):
@.str = [11 x i8] c"a %d b %d\0A\00"
define i32 @f(i32 %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1)
%4 = mul nsw i32 %0, 7
%5 = sub nsw i32 %4, %1
ret i32 %5
}
/* Variables and functions */
int omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  omp_set_num_threads(4);
#pragma omp parallel
  {
    printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(),
           omp_get_num_threads());
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    -0x4(%rbp),%esi
mov    %eax,%edx
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x4,%edi
call   1060 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xe9e(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Hello from thread %d, nthreads %d\0A\00"
define i32 @main() {
%1 = call i32 @omp_set_num_threads(i32 4)
%2 = call i32 (...) @omp_get_thread_num()
%3 = call i32 (...) @omp_get_num_threads()
%4 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Hello from thread %d, nthreads %d\0A\00"
define i32 @main() {
%1 = tail call i32 @omp_set_num_threads(i32 4)
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (...) @omp_get_num_threads()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
ret i32 0
}
void g(int *ptr) { return; }


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

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

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

LLVM IR (-O2):
define void @g(i32* nocapture %0) {
ret void
}
/* Type definitions */
struct stat {
  int dummy;
};

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
scalar_t__ stat(char *, struct stat *);
int check_file(char *fname) {
  struct stat buf;
  if (stat(fname, &buf) != 0) {
    if (errno == ENOENT)
      return -3;
    else
      return -1;
  } else {
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <stat@plt>
cmp    $0x0,%rax
je     1165 <check_file+0x55>
mov    0x2ea6(%rip),%rax
mov    (%rax),%rax
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
jne    1159 <check_file+0x49>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1171 <check_file+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    1171 <check_file+0x61>
jmp    116a <check_file+0x5a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_file>:
push   %rax
mov    %rsp,%rsi
call   1030 <stat@plt>
mov    0x2ec0(%rip),%rcx
mov    (%rcx),%rcx
mov    0x2ea6(%rip),%rdx
xor    %esi,%esi
cmp    (%rdx),%rcx
setne  %sil
add    %esi,%esi
or     $0xfffffffd,%esi
xor    %ecx,%ecx
test   %rax,%rax
cmovne %esi,%ecx
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@errno = global i64 0
@ENOENT = global i64 0
define i32 @check_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca %struct.stat
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @stat(i8* %5, %struct.stat* %4)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i64, i64* @errno
%10 = load i64, i64* @ENOENT
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 -3, i32* %2
br label %16
13: ; preds = %8
store i32 -1, i32* %2
br label %16
14: ; preds = %1
br label %15
15: ; preds = %14
store i32 0, i32* %2
br label %16
16: ; preds = %15, %13, %12
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@errno = global i64 0
@ENOENT = global i64 0
define i32 @check_file(i8* %0) {
%2 = alloca %struct.stat
%3 = bitcast %struct.stat* %2 to i8*
%4 = call i64 @stat(i8* %0, %struct.stat* %2)
%5 = icmp eq i64 %4, 0
%6 = load i64, i64* @errno
%7 = load i64, i64* @ENOENT
%8 = icmp eq i64 %6, %7
%9 = select i1 %8, i32 -3, i32 -1
%10 = select i1 %5, i32 0, i32 %9
ret i32 %10
}
/* Variables and functions */
char *bufext(char **, char *, size_t);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
char *bufncat(char **base, char *tail, const char *s, size_t n) {
  if ((tail = bufext(base, tail, n))) {
    memcpy(tail, s, n);
    tail += n;
  }
  return tail;
}


x86 assembly (clang, -O0):
<bufncat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <bufext@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1174 <bufncat+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bufncat>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rcx,%rdx
call   1030 <bufext@plt>
test   %rax,%rax
je     114e <bufncat+0x2e>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <memcpy@plt>
add    %r14,%rbx
jmp    1150 <bufncat+0x30>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @bufncat(i8** %0, i8* %1, i8* %2, i64 %3) {
%5 = tail call i8* @bufext(i8** %0, i8* %1, i64 %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @memcpy(i8* %5, i8* %2, i64 %3)
%9 = getelementptr inbounds i8, i8* %5, i64 %3
br label %10
10: ; preds = %7, %4
%11 = phi i8* [ %9, %7 ], [ null, %4 ]
ret i8* %11
}
/* Variables and functions */
int /*<<< orphan*/ dio_set(unsigned char, unsigned char);
void DIOSetStep(unsigned char pin, unsigned char value) { dio_set(pin, value); }


x86 assembly (clang, -O0):
<DIOSetStep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
mov    -0x1(%rbp),%al
movzbl %al,%edi
movzbl -0x2(%rbp),%esi
call   1030 <dio_set@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DIOSetStep>:
jmp    1030 <dio_set@plt>

LLVM IR (-O0):
define void @DIOSetStep(i8 zeroext %0, i8 zeroext %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 @dio_set(i8 zeroext %5, i8 zeroext %6)
ret void
}

LLVM IR (-O2):
define void @DIOSetStep(i8 zeroext %0, i8 zeroext %1) {
%3 = tail call i32 @dio_set(i8 zeroext %0, i8 zeroext %1)
ret void
}
int get_i(int index, int N) { return index / N; }


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

x86 assembly (clang, -O2):
<get_i>:
mov    %edi,%eax
cltd
idiv   %esi
ret

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

LLVM IR (-O2):
define i32 @get_i(i32 %0, i32 %1) {
%3 = sdiv i32 %0, %1
ret i32 %3
}
/* Type definitions */
struct sched_param {
  int dummy;
};
typedef int /*<<< orphan*/ posix_spawnattr_t;

/* Variables and functions */
int ENOSYS;
int posix_spawnattr_getschedparam(const posix_spawnattr_t *restrict attr,
                                  struct sched_param *restrict schedparam) {
  return ENOSYS;
}


x86 assembly (clang, -O0):
<posix_spawnattr_getschedparam>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ed5(%rip),%rax
mov    (%rax),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<posix_spawnattr_getschedparam>:
mov    0x2ee1(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.sched_param = type { i32 }
@ENOSYS = global i32 0
define i32 @posix_spawnattr_getschedparam(i32* noalias %0, %struct.sched_param* noalias %1) {
%3 = alloca i32*
%4 = alloca %struct.sched_param*
store i32* %0, i32** %3
store %struct.sched_param* %1, %struct.sched_param** %4
%5 = load i32, i32* @ENOSYS
ret i32 %5
}

LLVM IR (-O2):
%struct.sched_param = type { i32 }
@ENOSYS = global i32 0
define i32 @posix_spawnattr_getschedparam(i32* noalias nocapture readnone %0, %struct.sched_param* noalias nocapture readnone %1) {
%3 = load i32, i32* @ENOSYS
ret i32 %3
}
/* Variables and functions */
char *addBinary(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *a = "1111111111";
  char *b = "1";
  printf("%s\n", addBinary(a, b));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec8(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <addBinary@plt>
mov    %rax,%rsi
lea    0xeaf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
lea    0xeda(%rip),%rsi
call   1040 <addBinary@plt>
lea    0xed0(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [11 x i8] c"1111111111\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = tail call i8* @addBinary(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %1)
ret i32 0
}
int D(int x, int y) {
  unsigned ux = (unsigned)x;
  unsigned uy = (unsigned)y;
  return (ux - uy) == -(unsigned)(y - x);
}


x86 assembly (clang, -O0):
<D>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    -0x8(%rbp),%edx
sub    -0x4(%rbp),%edx
xor    %ecx,%ecx
sub    %edx,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @D(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
store i32 %7, i32* %5
%8 = load i32, i32* %4
store i32 %8, i32* %6
%9 = load i32, i32* %5
%10 = load i32, i32* %6
%11 = sub i32 %9, %10
%12 = load i32, i32* %4
%13 = load i32, i32* %3
%14 = sub nsw i32 %12, %13
%15 = sub i32 0, %14
%16 = icmp eq i32 %11, %15
%17 = zext i1 %16 to i32
ret i32 %17
}

LLVM IR (-O2):
define i32 @D(i32 %0, i32 %1) {
ret i32 1
}
/* Variables and functions */
int foo(int);
int main(int argc, char **argv) { return foo(-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)
mov    $0xffffffff,%edi
call   1030 <foo@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0xffffffff,%edi
jmp    1030 <foo@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 = call i32 @foo(i32 -1)
ret i32 %6
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @foo(i32 -1)
ret i32 %3
}
int(isalnum)(int c) { return isalnum(c); }


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

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

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

LLVM IR (-O2):
define i32 @isalnum(i32 %0) {
ret i32 undef
}
void cvtimage(buffer) register int buffer[];
{
  cvtshorts((unsigned short *)buffer, 12);
  cvtlongs(buffer + 3, 12);
  cvtlongs(buffer + 26, 4);
}


x86 assembly (clang, -O0):
<cvtimage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1040 <cvtshorts@plt>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1030 <cvtlongs@plt>
mov    -0x8(%rbp),%rdi
add    $0x68,%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <cvtlongs@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cvtimage>:
push   %rbx
mov    %rdi,%rbx
mov    $0xc,%esi
xor    %eax,%eax
call   1040 <cvtshorts@plt>
lea    0xc(%rbx),%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1030 <cvtlongs@plt>
add    $0x68,%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <cvtlongs@plt>

LLVM IR (-O0):
define void @cvtimage(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = bitcast i32* %3 to i16*
%5 = call i32 (i16*, i32, ...) bitcast (i32 (...)* @cvtshorts to i32 (i16*, i32, ...)*)(i16* %4, i32 12)
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 3
%8 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @cvtlongs to i32 (i32*, i32, ...)*)(i32* %7, i32 12)
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 26
%11 = call i32 (i32*, i32, ...) bitcast (i32 (...)* @cvtlongs to i32 (i32*, i32, ...)*)(i32* %10, i32 4)
ret void
}

LLVM IR (-O2):
define void @cvtimage(i32* %0) {
%2 = bitcast i32* %0 to i16*
%3 = tail call i32 (i16*, i32, ...) bitcast (i32 (...)* @cvtshorts to i32 (i16*, i32, ...)*)(i16* %2, i32 12)
%4 = getelementptr inbounds i32, i32* %0, i64 3
%5 = tail call i32 (i32*, i32, ...) bitcast (i32 (...)* @cvtlongs to i32 (i32*, i32, ...)*)(i32* %4, i32 12)
%6 = getelementptr inbounds i32, i32* %0, i64 26
%7 = tail call i32 (i32*, i32, ...) bitcast (i32 (...)* @cvtlongs to i32 (i32*, i32, ...)*)(i32* %6, i32 4)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ abort();
void assert_false(int val) {
  if (val) {
    abort();
  }
}


x86 assembly (clang, -O0):
<assert_false>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     112c <assert_false+0x1c>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assert_false>:
test   %edi,%edi
jne    1115 <assert_false+0x5>
ret
push   %rax
xor    %eax,%eax
call   1030 <abort@plt>

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

LLVM IR (-O2):
define void @assert_false(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 (...) @abort()
unreachable
5: ; preds = %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ WRITETEST(char *);
void SetDispBlink() { WRITETEST("\033[5m"); }


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

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

LLVM IR (-O0):
@.str = [5 x i8] c"\1B[5m\00"
define void @SetDispBlink() {
%1 = call i32 @WRITETEST(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"\1B[5m\00"
define void @SetDispBlink() {
%1 = tail call i32 @WRITETEST(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, int);
void crash_fgetc() {
  FILE *f;
  int i;
  f = fopen("this_file_doesnt_exist", "r");
  i = fgetc(f);
  printf("i =%i\n", i);
  fclose(f);
}


x86 assembly (clang, -O0):
<crash_fgetc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crash_fgetc>:
push   %rbx
lea    0xeb8(%rip),%rdi
lea    0xec8(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fgetc@plt>
lea    0xeb3(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"this_file_doesnt_exist\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"i =%i\0A\00"
define void @crash_fgetc() {
%1 = alloca i32*
%2 = alloca i32
%3 = call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
%4 = load i32*, i32** %1
%5 = call i32 @fgetc(i32* %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = load i32*, i32** %1
%9 = call i32 @fclose(i32* %8)
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"this_file_doesnt_exist\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"i =%i\0A\00"
define void @crash_fgetc() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i32 @fgetc(i32* %1)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%4 = tail call i32 @fclose(i32* %1)
ret void
}
int count_char(char *str, char sep) {
  int i;
  for (i = 0; str[i]; (str[i] == sep) ? i++ : *str++)
    ;
  return i;
}


x86 assembly (clang, -O0):
<count_char>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1169 <count_char+0x69>
jmp    112c <count_char+0x2c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    1152 <count_char+0x52>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <count_char+0x64>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%eax
jmp    1115 <count_char+0x15>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<count_char>:
mov    (%rdi),%cl
test   %cl,%cl
je     1132 <count_char+0x32>
xor    %r8d,%r8d
nopl   0x0(%rax)
xor    %eax,%eax
xor    %edx,%edx
cmp    %sil,%cl
sete   %al
setne  %dl
add    %rdx,%rdi
mov    %r8d,%ecx
add    %rcx,%rax
movzbl (%rdi,%rax,1),%ecx
mov    %eax,%r8d
test   %cl,%cl
jne    1110 <count_char+0x10>
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @count_char(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i8*, i8** %3
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %6
br label %14
14: ; preds = %13
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %27
24: ; preds = %14
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %32
27: ; preds = %14
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %3
%30 = load i8, i8* %28
%31 = sext i8 %30 to i32
br label %32
32: ; preds = %27, %24
%33 = phi i32 [ %25, %24 ], [ %31, %27 ]
br label %6
34: ; preds = %6
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @count_char(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %19, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %17, %5 ], [ %3, %2 ]
%7 = phi i32 [ %14, %5 ], [ 0, %2 ]
%8 = phi i8* [ %12, %5 ], [ %0, %2 ]
%9 = icmp eq i8 %6, %1
%10 = xor i1 %9, true
%11 = zext i1 %10 to i64
%12 = getelementptr i8, i8* %8, i64 %11
%13 = zext i1 %9 to i32
%14 = add nuw nsw i32 %7, %13
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %5, %2
%20 = phi i32 [ 0, %2 ], [ %14, %5 ]
ret i32 %20
}
/* Variables and functions */
int /*<<< orphan*/ imx_puts(char *);
void cputs(char *string) { imx_puts(string); }


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

x86 assembly (clang, -O2):
<cputs>:
jmp    1030 <imx_puts@plt>

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

LLVM IR (-O2):
define void @cputs(i8* %0) {
%2 = tail call i32 @imx_puts(i8* %0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ unlink(char *);
void unlock(int fd) {
  close(fd);
  unlink("lock");
}


x86 assembly (clang, -O0):
<unlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
lea    0xec6(%rip),%rdi
call   1030 <unlink@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlock>:
push   %rax
call   1040 <close@plt>
lea    0xed3(%rip),%rdi
pop    %rax
jmp    1030 <unlink@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"lock\00"
define void @unlock(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @close(i32 %3)
%5 = call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"lock\00"
define void @unlock(i32 %0) {
%2 = tail call i32 @close(i32 %0)
%3 = tail call i32 @unlink(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Type definitions */
typedef int uint8_t;
typedef int uint32_t;
typedef int src;

/* Variables and functions */
void cpy_net32(uint32_t src, uint32_t *dst) {
  uint8_t *d = (uint8_t *)dst;
  d[3] = (src)&0xFF;
  d[2] = (src >> 8) & 0xFF;
  d[1] = (src >> 16) & 0xFF;
  d[0] = (src >> 24) & 0xFF;
}


x86 assembly (clang, -O0):
<cpy_net32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x4(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpy_net32>:
mov    %edi,%eax
movzbl %al,%ecx
mov    %ecx,0xc(%rsi)
movzbl %ah,%ecx
mov    %ecx,0x8(%rsi)
mov    %edi,%ecx
shr    $0x10,%ecx
movzbl %cl,%ecx
mov    %ecx,0x4(%rsi)
shr    $0x18,%eax
mov    %eax,(%rsi)
ret

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

LLVM IR (-O2):
define void @cpy_net32(i32 %0, i32* nocapture writeonly %1) {
%3 = and i32 %0, 255
%4 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %3, i32* %4
%5 = lshr i32 %0, 8
%6 = and i32 %5, 255
%7 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %6, i32* %7
%8 = lshr i32 %0, 16
%9 = and i32 %8, 255
%10 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %9, i32* %10
%11 = lshr i32 %0, 24
store i32 %11, i32* %1
ret void
}
/* Variables and functions */
void *realloc(void *, size_t);
void *myrealloc(void *ptr, size_t len, void *pw) {
  ((pw) = (pw));
  return realloc(ptr, len);
}


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

x86 assembly (clang, -O2):
<myrealloc>:
jmp    1030 <realloc@plt>

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

LLVM IR (-O2):
define noalias i8* @myrealloc(i8* nocapture %0, i64 %1, i8* nocapture readnone %2) {
%4 = tail call i8* @realloc(i8* %0, i64 %1)
ret i8* %4
}
/* Variables and functions */
long read_byte_ADS123X();
long read_value_ADS123X() {
  long read = 0;
  for (int i = 0; i <= 3; i++)
    read = (read << 8) | read_byte_ADS123X();
  return read;
}


x86 assembly (clang, -O0):
<read_value_ADS123X>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movq   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jg     1160 <read_value_ADS123X+0x50>
mov    -0x8(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <read_byte_ADS123X@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
or     %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1127 <read_value_ADS123X+0x17>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_value_ADS123X>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <read_byte_ADS123X@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <read_byte_ADS123X@plt>
mov    %rax,%r15
shl    $0x10,%r14
shl    $0x8,%r15
or     %r14,%r15
xor    %eax,%eax
call   1030 <read_byte_ADS123X@plt>
mov    %rax,%rbx
or     %r15,%rbx
shl    $0x8,%rbx
xor    %eax,%eax
call   1030 <read_byte_ADS123X@plt>
or     %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @read_value_ADS123X() {
%1 = alloca i64
%2 = alloca i32
store i64 0, i64* %1
store i32 0, i32* %2
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %2
%5 = icmp sle i32 %4, 3
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i64, i64* %1
%8 = shl i64 %7, 8
%9 = call i64 (...) @read_byte_ADS123X()
%10 = or i64 %8, %9
store i64 %10, i64* %1
br label %11
11: ; preds = %6
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %3
14: ; preds = %3
%15 = load i64, i64* %1
ret i64 %15
}

LLVM IR (-O2):
define i64 @read_value_ADS123X() {
%1 = tail call i64 (...) @read_byte_ADS123X()
%2 = tail call i64 (...) @read_byte_ADS123X()
%3 = shl i64 %1, 16
%4 = shl i64 %2, 8
%5 = or i64 %3, %4
%6 = tail call i64 (...) @read_byte_ADS123X()
%7 = or i64 %6, %5
%8 = shl i64 %7, 8
%9 = tail call i64 (...) @read_byte_ADS123X()
%10 = or i64 %9, %8
ret i64 %10
}
/* Variables and functions */
int f280(int *);
int f281(int *p) { return f280(p); }


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

x86 assembly (clang, -O2):
<f281>:
jmp    1030 <f280@plt>

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

LLVM IR (-O2):
define i32 @f281(i32* %0) {
%2 = tail call i32 @f280(i32* %0)
ret i32 %2
}
/* Variables and functions */
unsigned int jsV_numbertoint32(double);
unsigned int jsV_numbertouint32(double n) { return jsV_numbertoint32(n); }


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

x86 assembly (clang, -O2):
<jsV_numbertouint32>:
jmp    1030 <jsV_numbertoint32@plt>

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

LLVM IR (-O2):
define i32 @jsV_numbertouint32(double %0) {
%2 = tail call i32 @jsV_numbertoint32(double %0)
ret i32 %2
}
void Msp430TimerCapComP__4__Timer__overflow(void) {}


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

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

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

LLVM IR (-O2):
define void @Msp430TimerCapComP__4__Timer__overflow() {
ret void
}
void PRCMLPDSWakeupSourceDisable(unsigned long ulLpdsWakeupSrc) {
  (*((volatile unsigned long *)(0x4402D000 + 0x00000004))) &= ~ulLpdsWakeupSrc;
}


x86 assembly (clang, -O0):
<PRCMLPDSWakeupSourceDisable>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
xor    $0xffffffffffffffff,%rax
mov    $0x4402d004,%ecx
mov    (%rcx),%rcx
and    %rax,%rcx
mov    $0x4402d004,%eax
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<PRCMLPDSWakeupSourceDisable>:
not    %rdi
and    %rdi,0x4402d004
44
ret

LLVM IR (-O0):
define void @PRCMLPDSWakeupSourceDisable(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = xor i64 %3, -1
%5 = load volatile i64, i64* inttoptr (i64 1141035012 to i64*)
%6 = and i64 %5, %4
store volatile i64 %6, i64* inttoptr (i64 1141035012 to i64*)
ret void
}

LLVM IR (-O2):
define void @PRCMLPDSWakeupSourceDisable(i64 %0) {
%2 = xor i64 %0, -1
%3 = load volatile i64, i64* inttoptr (i64 1141035012 to i64*)
%4 = and i64 %3, %2
store volatile i64 %4, i64* inttoptr (i64 1141035012 to i64*)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ _strfail(char const *, char const *, int);
scalar_t__ strcmp(char const *, char const *);
int _assert_streq(const char *actual, const char *expected) {
  if (strcmp(actual, expected) != 0) {
    _strfail(actual, expected, -1);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<_assert_streq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1165 <_assert_streq+0x45>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xffffffff,%edx
call   1040 <_strfail@plt>
movl   $0x0,-0x4(%rbp)
jmp    116c <_assert_streq+0x4c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_assert_streq>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strcmp@plt>
test   %rax,%rax
je     1148 <_assert_streq+0x28>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xffffffff,%edx
call   1040 <_strfail@plt>
xor    %eax,%eax
jmp    114d <_assert_streq+0x2d>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @_assert_streq(i8* %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @_strfail(i8* %0, i8* %1, i32 -1)
br label %7
7: ; preds = %2, %5
%8 = phi i32 [ 0, %5 ], [ 1, %2 ]
ret i32 %8
}
void CrushCRs(char *text) {
  char *p = text;
  char *q = text;
  char ch;
  do {
    ch = *p++;
    if (ch == '\r')
      continue;
    *q++ = ch;
  } while (ch != '\0');
}


x86 assembly (clang, -O0):
<CrushCRs>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0xd,%eax
jne    113e <CrushCRs+0x3e>
jmp    1152 <CrushCRs+0x52>
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
movsbl -0x19(%rbp),%eax
cmp    $0x0,%eax
jne    1118 <CrushCRs+0x18>
pop    %rbp
ret

x86 assembly (clang, -O2):
<CrushCRs>:
mov    %rdi,%rax
jmp    1118 <CrushCRs+0x18>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rax
test   %cl,%cl
je     1128 <CrushCRs+0x28>
movzbl (%rax),%ecx
cmp    $0xd,%cl
je     1110 <CrushCRs+0x10>
mov    %cl,(%rdi)
add    $0x1,%rdi
jmp    1110 <CrushCRs+0x10>
ret

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

LLVM IR (-O2):
define void @CrushCRs(i8* nocapture %0) {
br label %2
2: ; preds = %10, %1
%3 = phi i8* [ %0, %1 ], [ %11, %10 ]
%4 = phi i8* [ %0, %1 ], [ %5, %10 ]
%5 = getelementptr inbounds i8, i8* %4, i64 1
%6 = load i8, i8* %4
%7 = icmp eq i8 %6, 13
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = getelementptr inbounds i8, i8* %3, i64 1
store i8 %6, i8* %3
br label %10
10: ; preds = %2, %8
%11 = phi i8* [ %3, %2 ], [ %9, %8 ]
%12 = icmp eq i8 %6, 0
br i1 %12, label %13, label %2
13: ; preds = %10
ret void
}
double squareByValue(double num) { return num * num; }


x86 assembly (clang, -O0):
<squareByValue>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<squareByValue>:
mulsd  %xmm0,%xmm0
ret

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

LLVM IR (-O2):
define double @squareByValue(double %0) {
%2 = fmul double %0, %0
ret double %2
}
/* Variables and functions */
int isPrefix(char *, char *);
int isSerialPortDev(char *s) { return isPrefix("ttyusb", s); }


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

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

LLVM IR (-O0):
@.str = [7 x i8] c"ttyusb\00"
define i32 @isSerialPortDev(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @isPrefix(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 %4
}

LLVM IR (-O2):
@.str = [7 x i8] c"ttyusb\00"
define i32 @isSerialPortDev(i8* %0) {
%2 = tail call i32 @isPrefix(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %0)
ret i32 %2
}