xunge/DecIR huggingface dataset:
/* Variables and functions */
int /*<<< orphan*/ TIOCCBRK;
int /*<<< orphan*/ TIOCSBRK;
int /*<<< orphan*/ modem_ioctl(int /*<<< orphan*/, int /*<<< orphan*/);
void tty_td(int on) { modem_ioctl(on ? TIOCSBRK : TIOCCBRK, 0); }


x86 assembly (clang, -O0):
<tty_td>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1136 <tty_td+0x26>
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    1142 <tty_td+0x32>
mov    0x2ebb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
xor    %esi,%esi
call   1030 <modem_ioctl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tty_td>:
test   %edi,%edi
jne    111d <tty_td+0xd>
mov    0x2edd(%rip),%rax
jmp    1124 <tty_td+0x14>
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
jmp    1030 <modem_ioctl@plt>

LLVM IR (-O0):
@TIOCSBRK = global i32 0
@TIOCCBRK = global i32 0
define void @tty_td(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 = load i32, i32* @TIOCSBRK
br label %9
7: ; preds = %1
%8 = load i32, i32* @TIOCCBRK
br label %9
9: ; preds = %7, %5
%10 = phi i32 [ %6, %5 ], [ %8, %7 ]
%11 = call i32 @modem_ioctl(i32 %10, i32 0)
ret void
}

LLVM IR (-O2):
@TIOCSBRK = global i32 0
@TIOCCBRK = global i32 0
define void @tty_td(i32 %0) {
%2 = icmp eq i32 %0, 0
%3 = load i32, i32* @TIOCSBRK
%4 = load i32, i32* @TIOCCBRK
%5 = select i1 %2, i32 %4, i32 %3
%6 = tail call i32 @modem_ioctl(i32 %5, i32 0)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ max_heapify(int *, int, int);
void build_max_heap(int arr[], int arrLength) {
  int i;
  for (i = arrLength / 2; i > 0; i--)
    max_heapify(arr, i, arrLength);
}


x86 assembly (clang, -O0):
<build_max_heap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1154 <build_max_heap+0x44>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1030 <max_heapify@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <build_max_heap+0x1d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_max_heap>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%esi
jl     1146 <build_max_heap+0x36>
mov    %esi,%ebp
mov    %rdi,%r14
mov    %esi,%ebx
shr    %ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1030 <max_heapify@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     1130 <build_max_heap+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @build_max_heap(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
%7 = sdiv i32 %6, 2
store i32 %7, i32* %5
br label %8
8: ; preds = %16, %2
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = call i32 @max_heapify(i32* %12, i32 %13, i32 %14)
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
br label %8
19: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @build_max_heap(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 1
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = lshr i32 %1, 1
br label %6
6: ; preds = %4, %6
%7 = phi i32 [ %9, %6 ], [ %5, %4 ]
%8 = tail call i32 @max_heapify(i32* %0, i32 %7, i32 %1)
%9 = add nsw i32 %7, -1
%10 = icmp ugt i32 %7, 1
br i1 %10, label %6, label %11
11: ; preds = %6, %2
ret void
}
/* Type definitions */
struct Value {
  int dummy;
};
struct ParseState {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ LibPrintf(struct ParseState *, struct Value *,
                             struct Value **, int);
int /*<<< orphan*/ PlatformErrorPrefix(struct ParseState *);
void Cerrormsg(struct ParseState *Parser, struct Value *ReturnValue,
               struct Value **Param, int NumArgs) {
  PlatformErrorPrefix(Parser);
  LibPrintf(Parser, ReturnValue, Param, NumArgs);
}


x86 assembly (clang, -O0):
<Cerrormsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <PlatformErrorPrefix@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1030 <LibPrintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Cerrormsg>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1040 <PlatformErrorPrefix@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <LibPrintf@plt>

LLVM IR (-O0):
%struct.ParseState = type { i32 }
%struct.Value = type { i32 }
define void @Cerrormsg(%struct.ParseState* %0, %struct.Value* %1, %struct.Value** %2, i32 %3) {
%5 = alloca %struct.ParseState*
%6 = alloca %struct.Value*
%7 = alloca %struct.Value**
%8 = alloca i32
store %struct.ParseState* %0, %struct.ParseState** %5
store %struct.Value* %1, %struct.Value** %6
store %struct.Value** %2, %struct.Value*** %7
store i32 %3, i32* %8
%9 = load %struct.ParseState*, %struct.ParseState** %5
%10 = call i32 @PlatformErrorPrefix(%struct.ParseState* %9)
%11 = load %struct.ParseState*, %struct.ParseState** %5
%12 = load %struct.Value*, %struct.Value** %6
%13 = load %struct.Value**, %struct.Value*** %7
%14 = load i32, i32* %8
%15 = call i32 @LibPrintf(%struct.ParseState* %11, %struct.Value* %12, %struct.Value** %13, i32 %14)
ret void
}

LLVM IR (-O2):
%struct.ParseState = type { i32 }
%struct.Value = type { i32 }
define void @Cerrormsg(%struct.ParseState* %0, %struct.Value* %1, %struct.Value** %2, i32 %3) {
%5 = tail call i32 @PlatformErrorPrefix(%struct.ParseState* %0)
%6 = tail call i32 @LibPrintf(%struct.ParseState* %0, %struct.Value* %1, %struct.Value** %2, i32 %3)
ret void
}
/* Variables and functions */
scalar_t__ isalnum(unsigned char);
int isvalidkeychar(char c) {
  return isalnum((unsigned char)c) || c == ' ' || c == '-' || c == '_';
}


x86 assembly (clang, -O0):
<isvalidkeychar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%edi
call   1030 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x2(%rbp)
jne    116a <isvalidkeychar+0x5a>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x2(%rbp)
je     116a <isvalidkeychar+0x5a>
movsbl -0x1(%rbp),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x2(%rbp)
je     116a <isvalidkeychar+0x5a>
movsbl -0x1(%rbp),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x2(%rbp)
mov    -0x2(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isvalidkeychar>:
push   %rbx
mov    %edi,%ebx
movzbl %bl,%edi
call   1030 <isalnum@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     112a <isvalidkeychar+0x1a>
pop    %rbx
ret
cmp    $0x20,%bl
je     1128 <isvalidkeychar+0x18>
cmp    $0x2d,%bl
je     1128 <isvalidkeychar+0x18>
xor    %eax,%eax
cmp    $0x5f,%bl
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @isvalidkeychar(i8 signext %0) {
%2 = alloca i8
store i8 %0, i8* %2
%3 = load i8, i8* %2
%4 = call i64 @isalnum(i8 zeroext %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = load i8, i8* %2
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 32
br i1 %9, label %18, label %10
10: ; preds = %6
%11 = load i8, i8* %2
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 45
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 95
br label %18
18: ; preds = %14, %10, %6, %1
%19 = phi i1 [ true, %10 ], [ true, %6 ], [ true, %1 ], [ %17, %14 ]
%20 = zext i1 %19 to i32
ret i32 %20
}

LLVM IR (-O2):
define i32 @isvalidkeychar(i8 signext %0) {
%2 = tail call i64 @isalnum(i8 zeroext %0)
%3 = freeze i64 %2
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
switch i8 %0, label %6 [
i8 45, label %9
i8 32, label %9
]
6: ; preds = %5
%7 = icmp eq i8 %0, 95
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %5, %1, %6
%10 = phi i32 [ 1, %5 ], [ %8, %6 ], [ 1, %1 ], [ 1, %5 ]
ret i32 %10
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *, int, int);
void create_json_header(void) {
  printf("%s%c%c\n", "Content-type:application/json;charset=utf-8", 13, 10);
}


x86 assembly (clang, -O0):
<create_json_header>:
push   %rbp
mov    %rsp,%rbp
lea    0xee5(%rip),%rdi
lea    0xee6(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_json_header>:
lea    0xee9(%rip),%rdi
lea    0xeea(%rip),%rsi
mov    $0xd,%edx
mov    $0xa,%ecx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%s%c%c\0A\00"
@.str.1 = [44 x i8] c"Content-type:application/json;charset=utf-8\00"
define void @create_json_header() {
%1 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 13, i32 10)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%s%c%c\0A\00"
@.str.1 = [44 x i8] c"Content-type:application/json;charset=utf-8\00"
define void @create_json_header() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 13, i32 10)
ret void
}
/* Type definitions */
struct user_regs_struct {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ PTRACE_DETACH;
int /*<<< orphan*/ PTRACE_SETREGS;
int /*<<< orphan*/ ptrace(int /*<<< orphan*/, int, int /*<<< orphan*/ *,
                          struct user_regs_struct *);
int detachFromProc(int pid, struct user_regs_struct *regs) {
  ptrace(PTRACE_SETREGS, pid, NULL, regs);
  ptrace(PTRACE_DETACH, pid, NULL, NULL);
  return 0;
}


x86 assembly (clang, -O0):
<detachFromProc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec2(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edx
call   1030 <ptrace@plt>
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   1030 <ptrace@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detachFromProc>:
push   %rbx
mov    %rsi,%rcx
mov    %edi,%ebx
mov    0x2ecb(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <ptrace@plt>
mov    0x2eb1(%rip),%rax
mov    (%rax),%edi
mov    %ebx,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1030 <ptrace@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.user_regs_struct = type { i32 }
@PTRACE_SETREGS = global i32 0
@PTRACE_DETACH = global i32 0
define i32 @detachFromProc(i32 %0, %struct.user_regs_struct* %1) {
%3 = alloca i32
%4 = alloca %struct.user_regs_struct*
store i32 %0, i32* %3
store %struct.user_regs_struct* %1, %struct.user_regs_struct** %4
%5 = load i32, i32* @PTRACE_SETREGS
%6 = load i32, i32* %3
%7 = load %struct.user_regs_struct*, %struct.user_regs_struct** %4
%8 = call i32 @ptrace(i32 %5, i32 %6, i32* null, %struct.user_regs_struct* %7)
%9 = load i32, i32* @PTRACE_DETACH
%10 = load i32, i32* %3
%11 = call i32 @ptrace(i32 %9, i32 %10, i32* null, %struct.user_regs_struct* null)
ret i32 0
}

LLVM IR (-O2):
%struct.user_regs_struct = type { i32 }
@PTRACE_SETREGS = global i32 0
@PTRACE_DETACH = global i32 0
define i32 @detachFromProc(i32 %0, %struct.user_regs_struct* %1) {
%3 = load i32, i32* @PTRACE_SETREGS
%4 = tail call i32 @ptrace(i32 %3, i32 %0, i32* null, %struct.user_regs_struct* %1)
%5 = load i32, i32* @PTRACE_DETACH
%6 = tail call i32 @ptrace(i32 %5, i32 %0, i32* null, %struct.user_regs_struct* null)
ret i32 0
}
/* Variables and functions */
int tag_of(uintptr_t tag) { return tag & 3; }


x86 assembly (clang, -O0):
<tag_of>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
and    $0x3,%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_of>:
mov    %rdi,%rax
and    $0x3,%eax
ret

LLVM IR (-O0):
define i32 @tag_of(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = and i64 %3, 3
%5 = trunc i64 %4 to i32
ret i32 %5
}

LLVM IR (-O2):
define i32 @tag_of(i64 %0) {
%2 = trunc i64 %0 to i32
%3 = and i32 %2, 3
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ foo(char *);
void f7(void) {
  char buf[4096 * 10 + 512];
  foo(buf);
}


x86 assembly (clang, -O0):
<f7>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa200,%rsp
lea    -0xa200(%rbp),%rdi
call   1030 <foo@plt>
add    $0xa200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f7>:
sub    $0xa208,%rsp
mov    %rsp,%rdi
call   1030 <foo@plt>
add    $0xa208,%rsp
ret

LLVM IR (-O0):
define void @f7() {
%1 = alloca [41472 x i8]
%2 = getelementptr inbounds [41472 x i8], [41472 x i8]* %1, i64 0, i64 0
%3 = call i32 @foo(i8* %2)
ret void
}

LLVM IR (-O2):
define void @f7() {
%1 = alloca [41472 x i8]
%2 = getelementptr inbounds [41472 x i8], [41472 x i8]* %1, i64 0, i64 0
%3 = call i32 @foo(i8* %2)
ret void
}
/* Variables and functions */
int getpagesize();
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int i = getpagesize();
  printf("i=%d\n", i);
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <getpagesize@plt>
lea    0xed1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"i=%d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @getpagesize()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %1)
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
void *malloc(size_t);
int /*<<< orphan*/ my_putstr(char *);
void *xmalloc(size_t size) {
  void *p;
  p = malloc(size);
  if (p == NULL) {
    my_putstr("malloc failed\n");
    exit(EXIT_FAILURE);
  }
  return (p);
}


x86 assembly (clang, -O0):
<xmalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    116e <xmalloc+0x3e>
lea    0xea5(%rip),%rdi
call   1030 <my_putstr@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xmalloc>:
push   %rax
call   1040 <malloc@plt>
test   %rax,%rax
je     113d <xmalloc+0xd>
pop    %rcx
ret
lea    0xebc(%rip),%rdi
call   1030 <my_putstr@plt>
mov    0x2e90(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"malloc failed\0A\00"
@EXIT_FAILURE = global i32 0
define i8* @xmalloc(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = call i8* @malloc(i64 %4)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i32 @my_putstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
%13 = load i8*, i8** %3
ret i8* %13
}

LLVM IR (-O2):
@.str = [15 x i8] c"malloc failed\0A\00"
@EXIT_FAILURE = global i32 0
define noalias i8* @xmalloc(i64 %0) {
%2 = tail call i8* @malloc(i64 %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @my_putstr(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %1
ret i8* %2
}
int ini__is_comment(const char *str) { return *str == ';'; }


x86 assembly (clang, -O0):
<ini__is_comment>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ini__is_comment>:
xor    %eax,%eax
cmpb   $0x3b,(%rdi)
sete   %al
ret

LLVM IR (-O0):
define i32 @ini__is_comment(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
%6 = icmp eq i32 %5, 59
%7 = zext i1 %6 to i32
ret i32 %7
}

LLVM IR (-O2):
define i32 @ini__is_comment(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 59
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  setlocale(LC_ALL, "Portuguese");
  printf("Olá mundo com acentuações!\n");
  return 0;
}


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

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2eb8(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1040 <setlocale@plt>
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@.str.1 = [31 x i8] c"Ol\C3\A1 mundo com acentua\C3\A7\C3\B5es!\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @LC_ALL
%3 = call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [11 x i8] c"Portuguese\00"
@str = [30 x i8] c"Ol\C3\A1 mundo com acentua\C3\A7\C3\B5es!\00"
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32 @setlocale(i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}
/* Variables and functions */
int /*<<< orphan*/ gen(char *);
void cgswap(void) { gen("xchgq\t%rax,%rcx"); }


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

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

LLVM IR (-O0):
@.str = [16 x i8] c"xchgq\09%rax,%rcx\00"
define void @cgswap() {
%1 = call i32 @gen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"xchgq\09%rax,%rcx\00"
define void @cgswap() {
%1 = tail call i32 @gen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ Assert_real(int, char *, int, char *);
scalar_t__ isalpha(int);
void t_isalpha_0x22() {
  Assert_real((isalpha(34) == 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_isalpha.c",
              175, ("isalpha should be 0 for 0x22"));
}


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

x86 assembly (clang, -O2):
<t_isalpha_0x22>:
push   %rax
mov    $0x22,%edi
call   1030 <isalpha@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
lea    0xec5(%rip),%rsi
lea    0xf66(%rip),%rcx
mov    $0xaf,%edx
pop    %rax
jmp    1040 <Assert_real@plt>

LLVM IR (-O0):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isalpha.c\00"
@.str.1 = [29 x i8] c"isalpha should be 0 for 0x22\00"
define void @t_isalpha_0x22() {
%1 = call i64 @isalpha(i32 34)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 175, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bitfixer/bitfixer/refs/heads/master/dg/z88dk/test/suites/ctype/test_isalpha.c\00"
@.str.1 = [29 x i8] c"isalpha should be 0 for 0x22\00"
define void @t_isalpha_0x22() {
%1 = tail call i64 @isalpha(i32 34)
%2 = icmp eq i64 %1, 0
%3 = zext i1 %2 to i32
%4 = tail call i32 @Assert_real(i32 %3, i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str, i64 0, i64 0), i32 175, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
ret void
}
/* Variables and functions */
int /*<<< orphan*/ getchar();
void show_payload(int lt) {
  int i;
  for (i = 0; i < lt; i++)
    getchar();
}


x86 assembly (clang, -O0):
<show_payload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1143 <show_payload+0x33>
mov    $0x0,%al
call   1030 <getchar@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <show_payload+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_payload>:
push   %rbx
test   %edi,%edi
jle    112c <show_payload+0x1c>
mov    %edi,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getchar@plt>
add    $0xffffffff,%ebx
jne    1120 <show_payload+0x10>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @show_payload(i32 %0) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %8
3: ; preds = %1, %3
%4 = phi i32 [ %6, %3 ], [ 0, %1 ]
%5 = tail call i32 (...) @getchar()
%6 = add nuw nsw i32 %4, 1
%7 = icmp eq i32 %6, %0
br i1 %7, label %8, label %3
8: ; preds = %3, %1
ret void
}
/* Forward declarations */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  scalar_t__ pAppData;
  int /*<<< orphan*/ (*xDlClose)(TYPE_1__ *, void *);
};
typedef TYPE_1__ sqlite3_vfs;

/* Variables and functions */
int /*<<< orphan*/ stub1(TYPE_1__ *, void *);
void memDlClose(sqlite3_vfs *pVfs, void *pHandle) {
  ((sqlite3_vfs *)((pVfs)->pAppData))
      ->xDlClose(((sqlite3_vfs *)((pVfs)->pAppData)), pHandle);
}


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

x86 assembly (clang, -O2):
<memDlClose>:
mov    (%rdi),%rdi
mov    0x8(%rdi),%rax
jmp    *%rax

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i32 (%struct.TYPE_4__*, i8*)* }
define void @memDlClose(%struct.TYPE_4__* %0, i8* %1) {
%3 = alloca %struct.TYPE_4__*
%4 = alloca i8*
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %3
store i8* %1, i8** %4
%5 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i32 0, i32 0
%7 = load i64, i64* %6
%8 = inttoptr i64 %7 to %struct.TYPE_4__*
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 1
%10 = load i32 (%struct.TYPE_4__*, i8*)*, i32 (%struct.TYPE_4__*, i8*)** %9
%11 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = inttoptr i64 %13 to %struct.TYPE_4__*
%15 = load i8*, i8** %4
%16 = call i32 %10(%struct.TYPE_4__* %14, i8* %15)
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i32 (%struct.TYPE_4__*, i8*)* }
define void @memDlClose(%struct.TYPE_4__* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
%4 = load i64, i64* %3
%5 = inttoptr i64 %4 to %struct.TYPE_4__*
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %5, i64 0, i32 1
%7 = load i32 (%struct.TYPE_4__*, i8*)*, i32 (%struct.TYPE_4__*, i8*)** %6
%8 = tail call i32 %7(%struct.TYPE_4__* %5, i8* %1)
ret void
}
/* Type definitions */
struct _citrus_stdenc {
  int dummy;
};

/* Variables and functions */
int _citrus_NONE_stdenc_put_state_reset(struct _citrus_stdenc *__restrict ce,
                                        char *__restrict s, size_t n,
                                        void *__restrict pspriv,
                                        size_t *__restrict nresult) {
  *nresult = 0;
  return (0);
}


x86 assembly (clang, -O0):
<_citrus_NONE_stdenc_put_state_reset>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_citrus_NONE_stdenc_put_state_reset>:
movq   $0x0,(%r8)
xor    %eax,%eax
ret

LLVM IR (-O0):
%struct._citrus_stdenc = type { i32 }
define i32 @_citrus_NONE_stdenc_put_state_reset(%struct._citrus_stdenc* noalias %0, i8* noalias %1, i64 %2, i8* noalias %3, i64* noalias %4) {
%6 = alloca %struct._citrus_stdenc*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64*
store %struct._citrus_stdenc* %0, %struct._citrus_stdenc** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64* %4, i64** %10
%11 = load i64*, i64** %10
store i64 0, i64* %11
ret i32 0
}

LLVM IR (-O2):
%struct._citrus_stdenc = type { i32 }
define i32 @_citrus_NONE_stdenc_put_state_reset(%struct._citrus_stdenc* noalias nocapture readnone %0, i8* noalias nocapture readnone %1, i64 %2, i8* noalias nocapture readnone %3, i64* noalias nocapture writeonly %4) {
store i64 0, i64* %4
ret i32 0
}
char *strchr(const char *string, int c) {
  while (*string) {
    if (*string == c) {
      return (char *)string;
    }
    string++;
  }
  if (!c) {
    return (char *)string;
  }
  return (char *)0;
}


x86 assembly (clang, -O0):
<strchr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1146 <strchr+0x46>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    -0x14(%rbp),%eax
jne    1135 <strchr+0x35>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1165 <strchr+0x65>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    110b <strchr+0xb>
cmpl   $0x0,-0x14(%rbp)
jne    115d <strchr+0x5d>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1165 <strchr+0x65>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strchr>:
mov    %rdi,%rax
mov    (%rdi),%cl
test   %cl,%cl
je     1123 <strchr+0x23>
nopl   0x0(%rax)
movsbl %cl,%ecx
cmp    %esi,%ecx
je     112b <strchr+0x2b>
movzbl 0x1(%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1110 <strchr+0x10>
xor    %ecx,%ecx
test   %esi,%esi
cmovne %rcx,%rax
ret

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

LLVM IR (-O2):
define i8* @strchr(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %2, %10
%6 = phi i8 [ %12, %10 ], [ %3, %2 ]
%7 = phi i8* [ %11, %10 ], [ %0, %2 ]
%8 = sext i8 %6 to i32
%9 = icmp eq i32 %8, %1
br i1 %9, label %18, label %10
10: ; preds = %5
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %10, %2
%15 = phi i8* [ %0, %2 ], [ %11, %10 ]
%16 = icmp eq i32 %1, 0
%17 = select i1 %16, i8* %15, i8* null
br label %18
18: ; preds = %5, %14
%19 = phi i8* [ %17, %14 ], [ %7, %5 ]
ret i8* %19
}
int pow2(int exp) {
  if (exp == 0)
    return 1;
  return pow2(exp - 1) * 2;
}


x86 assembly (clang, -O0):
<pow2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1131 <pow2+0x21>
movl   $0x1,-0x4(%rbp)
jmp    1142 <pow2+0x32>
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
call   1030 <pow2@plt>
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pow2>:
test   %edi,%edi
je     1124 <pow2+0x14>
push   %rax
add    $0xffffffff,%edi
call   1030 <pow2@plt>
add    %eax,%eax
add    $0x8,%rsp
ret
mov    $0x1,%eax
ret

LLVM IR (-O0):
define i32 @pow2(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %12
7: ; preds = %1
%8 = load i32, i32* %3
%9 = sub nsw i32 %8, 1
%10 = call i32 @pow2(i32 %9)
%11 = mul nsw i32 %10, 2
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 @pow2(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1, %5
%4 = phi i32 [ %8, %5 ], [ 1, %1 ]
ret i32 %4
5: ; preds = %1
%6 = add nsw i32 %0, -1
%7 = tail call i32 @pow2(i32 %6)
%8 = shl nsw i32 %7, 1
br label %3
}
int hex_to_digit(int hex) {
  if (hex >= '0' && hex <= '9')
    return hex - '0';
  else if (hex >= 'a' && hex <= 'f')
    return hex - 'a' + 10;
  else if (hex >= 'A' && hex <= 'F')
    return hex - 'A' + 10;
  else
    return 0;
}


x86 assembly (clang, -O0):
<hex_to_digit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
cmpl   $0x30,-0x8(%rbp)
jl     1129 <hex_to_digit+0x29>
cmpl   $0x39,-0x8(%rbp)
jg     1129 <hex_to_digit+0x29>
mov    -0x8(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    117a <hex_to_digit+0x7a>
cmpl   $0x61,-0x8(%rbp)
jl     114e <hex_to_digit+0x4e>
cmpl   $0x66,-0x8(%rbp)
jg     114e <hex_to_digit+0x4e>
mov    -0x8(%rbp),%eax
sub    $0x61,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    117a <hex_to_digit+0x7a>
cmpl   $0x41,-0x8(%rbp)
jl     1173 <hex_to_digit+0x73>
cmpl   $0x46,-0x8(%rbp)
jg     1173 <hex_to_digit+0x73>
mov    -0x8(%rbp),%eax
sub    $0x41,%eax
add    $0xa,%eax
mov    %eax,-0x4(%rbp)
jmp    117a <hex_to_digit+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<hex_to_digit>:
lea    -0x30(%rdi),%eax
cmp    $0xa,%eax
jb     1124 <hex_to_digit+0x24>
lea    -0x61(%rdi),%eax
cmp    $0x5,%eax
ja     1116 <hex_to_digit+0x16>
add    $0xffffffa9,%edi
mov    %edi,%eax
ret
lea    -0x41(%rdi),%ecx
add    $0xffffffc9,%edi
xor    %eax,%eax
cmp    $0x6,%ecx
cmovb  %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @hex_to_digit(i32 %0) {
%2 = add i32 %0, -48
%3 = icmp ult i32 %2, 10
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = add i32 %0, -97
%6 = icmp ult i32 %5, 6
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = add nsw i32 %0, -87
br label %14
9: ; preds = %4
%10 = add i32 %0, -65
%11 = icmp ult i32 %10, 6
%12 = add nsw i32 %0, -55
%13 = select i1 %11, i32 %12, i32 0
br label %14
14: ; preds = %1, %9, %7
%15 = phi i32 [ %8, %7 ], [ %13, %9 ], [ %2, %1 ]
ret i32 %15
}
/* Variables and functions */
int /*<<< orphan*/ saida(int);
void varreVetor(int vetor[5]) {
  for (int cont = 0; cont < 5; cont++)
    saida(vetor[cont]);
}


x86 assembly (clang, -O0):
<varreVetor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    114b <varreVetor+0x3b>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <saida@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <varreVetor+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<varreVetor>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
call   1030 <saida@plt>
mov    0x4(%rbx),%edi
call   1030 <saida@plt>
mov    0x8(%rbx),%edi
call   1030 <saida@plt>
mov    0xc(%rbx),%edi
call   1030 <saida@plt>
mov    0x10(%rbx),%edi
pop    %rbx
jmp    1030 <saida@plt>

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

LLVM IR (-O2):
define void @varreVetor(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = tail call i32 @saida(i32 %2)
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = load i32, i32* %4
%6 = tail call i32 @saida(i32 %5)
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = load i32, i32* %7
%9 = tail call i32 @saida(i32 %8)
%10 = getelementptr inbounds i32, i32* %0, i64 3
%11 = load i32, i32* %10
%12 = tail call i32 @saida(i32 %11)
%13 = getelementptr inbounds i32, i32* %0, i64 4
%14 = load i32, i32* %13
%15 = tail call i32 @saida(i32 %14)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ getuid();
scalar_t__ setreuid(int /*<<< orphan*/, int /*<<< orphan*/);
bool downgrade() { return setreuid(0, getuid()) == 0; }


x86 assembly (clang, -O0):
<downgrade>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1030 <getuid@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1040 <setreuid@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<downgrade>:
push   %rax
xor    %eax,%eax
call   1030 <getuid@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1040 <setreuid@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @downgrade() {
%1 = call i32 (...) @getuid()
%2 = call i64 @setreuid(i32 0, i32 %1)
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
ret i32 %4
}

LLVM IR (-O2):
define i32 @downgrade() {
%1 = tail call i32 (...) @getuid()
%2 = tail call i64 @setreuid(i32 0, i32 %1)
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
ret i32 %4
}
/* Variables and functions */
int yas_kxsd9_read_reg_byte(int);
int /*<<< orphan*/ yas_kxsd9_write_reg_byte(int, int);
int yas_kxsd9_power_up(void) {
  yas_kxsd9_write_reg_byte(
      0x0d, ((yas_kxsd9_read_reg_byte(0x0d) & ~0x40) | ((1) << 6)));
  return (0);
}


x86 assembly (clang, -O0):
<yas_kxsd9_power_up>:
push   %rbp
mov    %rsp,%rbp
mov    $0xd,%edi
call   1040 <yas_kxsd9_read_reg_byte@plt>
mov    %eax,%esi
and    $0xffffffbf,%esi
or     $0x40,%esi
mov    $0xd,%edi
call   1030 <yas_kxsd9_write_reg_byte@plt>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<yas_kxsd9_power_up>:
push   %rax
mov    $0xd,%edi
call   1040 <yas_kxsd9_read_reg_byte@plt>
or     $0x40,%eax
mov    $0xd,%edi
mov    %eax,%esi
call   1030 <yas_kxsd9_write_reg_byte@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @yas_kxsd9_power_up() {
%1 = call i32 @yas_kxsd9_read_reg_byte(i32 13)
%2 = and i32 %1, -65
%3 = or i32 %2, 64
%4 = call i32 @yas_kxsd9_write_reg_byte(i32 13, i32 %3)
ret i32 0
}

LLVM IR (-O2):
define i32 @yas_kxsd9_power_up() {
%1 = tail call i32 @yas_kxsd9_read_reg_byte(i32 13)
%2 = or i32 %1, 64
%3 = tail call i32 @yas_kxsd9_write_reg_byte(i32 13, i32 %2)
ret i32 0
}
int security_setdomainname(char *domainname) { return 0; }


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

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

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

LLVM IR (-O2):
define i32 @security_setdomainname(i8* nocapture readnone %0) {
ret i32 0
}
/* Type definitions */
struct Global {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ Putchar(struct Global *, int /*<<< orphan*/);
void Putstring(struct Global *global, char *string) {
  if (!string)
    return;
  while (*string)
    Putchar(global, *string++);
}


x86 assembly (clang, -O0):
<Putstring>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1130 <Putstring+0x20>
jmp    1162 <Putstring+0x52>
jmp    1135 <Putstring+0x25>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1162 <Putstring+0x52>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%esi
call   1030 <Putchar@plt>
jmp    1135 <Putstring+0x25>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Putstring>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1146 <Putstring+0x36>
mov    %rsi,%rbx
mov    (%rsi),%al
test   %al,%al
je     1146 <Putstring+0x36>
mov    %rdi,%r14
add    $0x1,%rbx
nopl   0x0(%rax)
movsbl %al,%esi
mov    %r14,%rdi
call   1030 <Putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <Putstring+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Global = type { i32 }
define void @Putstring(%struct.Global* %0, i8* %1) {
%3 = alloca %struct.Global*
%4 = alloca i8*
store %struct.Global* %0, %struct.Global** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %2
br label %20
8: ; preds = %2
br label %9
9: ; preds = %13, %8
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load %struct.Global*, %struct.Global** %3
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = call i32 @Putchar(%struct.Global* %14, i32 %18)
br label %9
20: ; preds = %7, %9
ret void
}

LLVM IR (-O2):
%struct.Global = type { i32 }
define void @Putstring(%struct.Global* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %4, %7
%8 = phi i8 [ %13, %7 ], [ %5, %4 ]
%9 = phi i8* [ %10, %7 ], [ %1, %4 ]
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = sext i8 %8 to i32
%12 = tail call i32 @Putchar(%struct.Global* %0, i32 %11)
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %4, %2
ret void
}
void __attribute__((no)) HEX00_cgiInit(void) {}


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

x86 assembly (clang, -O2):
ret

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

LLVM IR (-O2):
define void @HEX00_cgiInit() {
ret void
}
int find_first_bit(int nbits, int *addr) {
  int i;
  for (i = 0; i < nbits; i++)
    if (!!(*(addr + (i >> 5)) & (1 << (i & 0x1f))) == 1)
      return i;
  return -11;
}


x86 assembly (clang, -O0):
<find_first_bit>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1175 <find_first_bit+0x75>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sar    $0x5,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x14(%rbp),%ecx
and    $0x1f,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
jne    1162 <find_first_bit+0x62>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117c <find_first_bit+0x7c>
jmp    1167 <find_first_bit+0x67>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1112 <find_first_bit+0x12>
movl   $0xfffffff5,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_first_bit>:
mov    $0xfffffff5,%eax
test   %edi,%edi
jle    1124 <find_first_bit+0x24>
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
mov    %ecx,%edx
shr    $0x5,%edx
mov    (%rsi,%rdx,4),%edx
bt     %ecx,%edx
jb     1125 <find_first_bit+0x25>
add    $0x1,%ecx
cmp    %ecx,%edi
jne    1110 <find_first_bit+0x10>
ret
mov    %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @find_first_bit(i32 %0, i32* nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %17
4: ; preds = %2, %14
%5 = phi i32 [ %15, %14 ], [ 0, %2 ]
%6 = lshr i32 %5, 5
%7 = zext i32 %6 to i64
%8 = getelementptr inbounds i32, i32* %1, i64 %7
%9 = load i32, i32* %8
%10 = and i32 %5, 31
%11 = shl nuw i32 1, %10
%12 = and i32 %9, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = add nuw nsw i32 %5, 1
%16 = icmp eq i32 %15, %0
br i1 %16, label %17, label %4
17: ; preds = %4, %14, %2
%18 = phi i32 [ -11, %2 ], [ -11, %14 ], [ %5, %4 ]
ret i32 %18
}
void readin(buf, count) char *buf;
unsigned count;
{
  int ch;
  while (count--) {
    if ((ch = readchar()) < 0)
      prematureeof();
    *buf++ = ch;
  }
}


x86 assembly (clang, -O0):
<readin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1178 <readin+0x58>
mov    $0x0,%al
call   1040 <readchar@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jge    115d <readin+0x3d>
mov    $0x0,%al
call   1030 <prematureeof@plt>
mov    -0x10(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    112f <readin+0xf>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readin>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
je     1163 <readin+0x43>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
jmp    114d <readin+0x2d>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %bpl,(%r14,%rbx,1)
add    $0x1,%rbx
cmp    %ebx,%r15d
je     1163 <readin+0x43>
xor    %eax,%eax
call   1040 <readchar@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1140 <readin+0x20>
xor    %eax,%eax
call   1030 <prematureeof@plt>
jmp    1140 <readin+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @readin(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %15, %2
%7 = load i32, i32* %4
%8 = add i32 %7, -1
store i32 %8, i32* %4
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = call i32 (...) @readchar()
store i32 %11, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 (...) @prematureeof()
br label %15
15: ; preds = %13, %10
%16 = load i32, i32* %5
%17 = trunc i32 %16 to i8
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
store i8 %17, i8* %18
br label %6
20: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @readin(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %16, label %4
4: ; preds = %2, %12
%5 = phi i32 [ %7, %12 ], [ %1, %2 ]
%6 = phi i8* [ %14, %12 ], [ %0, %2 ]
%7 = add i32 %5, -1
%8 = tail call i32 (...) @readchar()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = tail call i32 (...) @prematureeof()
br label %12
12: ; preds = %10, %4
%13 = trunc i32 %8 to i8
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %13, i8* %6
%15 = icmp eq i32 %7, 0
br i1 %15, label %16, label %4
16: ; preds = %12, %2
ret void
}
/* Variables and functions */
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void print_break() { fputc('\n', stdout); }


x86 assembly (clang, -O0):
<print_break>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1030 <fputc@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_break>:
mov    0x2ec9(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@stdout = global i32 0
define void @print_break() {
%1 = load i32, i32* @stdout
%2 = call i32 @fputc(i8 signext 10, i32 %1)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @print_break() {
%1 = load i32, i32* @stdout
%2 = tail call i32 @fputc(i8 signext 10, i32 %1)
ret void
}