xunge/DecIR huggingface dataset:
int strcmp(char *str1, char *str2) {
  while (*str1 == *str2) {
    if (*str1 == '\0') {
      return 0;
    }
    str1++;
    str2++;
  }
  return (*(unsigned char *)str1) - (*(unsigned char *)str2);
}


x86 assembly (clang, -O0):
<strcmp>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    115b <strcmp+0x5b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    113e <strcmp+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    116e <strcmp+0x6e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    110c <strcmp+0xc>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<strcmp>:
mov    (%rdi),%al
mov    (%rsi),%cl
cmp    %cl,%al
jne    1124 <strcmp+0x24>
mov    $0x1,%edx
nopl   (%rax)
test   %al,%al
je     112d <strcmp+0x2d>
movzbl (%rdi,%rdx,1),%eax
movzbl (%rsi,%rdx,1),%ecx
add    $0x1,%rdx
cmp    %cl,%al
je     1110 <strcmp+0x10>
movzbl %al,%eax
movzbl %cl,%ecx
sub    %ecx,%eax
ret
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @strcmp(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = load i8, i8* %1
%5 = icmp eq i8 %3, %4
br i1 %5, label %6, label %17
6: ; preds = %2, %11
%7 = phi i8 [ %14, %11 ], [ %3, %2 ]
%8 = phi i8* [ %13, %11 ], [ %1, %2 ]
%9 = phi i8* [ %12, %11 ], [ %0, %2 ]
%10 = icmp eq i8 %7, 0
br i1 %10, label %23, label %11
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = load i8, i8* %12
%15 = load i8, i8* %13
%16 = icmp eq i8 %14, %15
br i1 %16, label %6, label %17
17: ; preds = %11, %2
%18 = phi i8 [ %3, %2 ], [ %14, %11 ]
%19 = phi i8 [ %4, %2 ], [ %15, %11 ]
%20 = zext i8 %18 to i32
%21 = zext i8 %19 to i32
%22 = sub nsw i32 %20, %21
br label %23
23: ; preds = %6, %17
%24 = phi i32 [ %22, %17 ], [ 0, %6 ]
ret i32 %24
}
/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
void putGawbleBE(uint8_t *buffer, uint32_t value) {
  *buffer++ = value >> 24;
  *buffer++ = (value >> 16) & 0xff;
  *buffer++ = (value >> 8) & 0xff;
  *buffer++ = value & 0xff;
}


x86 assembly (clang, -O0):
<putGawbleBE>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,-0x8(%rbp)
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<putGawbleBE>:
mov    %esi,%eax
mov    %esi,%ecx
movzbl %ah,%edx
movzbl %al,%esi
sar    $0x18,%eax
mov    %eax,(%rdi)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x4(%rdi)
mov    %edx,0x8(%rdi)
mov    %esi,0xc(%rdi)
ret

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

LLVM IR (-O2):
define void @putGawbleBE(i32* nocapture writeonly %0, i32 %1) {
%3 = ashr i32 %1, 24
%4 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %3, i32* %0
%5 = lshr i32 %1, 16
%6 = and i32 %5, 255
%7 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %6, i32* %4
%8 = lshr i32 %1, 8
%9 = and i32 %8, 255
%10 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %9, i32* %7
%11 = and i32 %1, 255
store i32 %11, i32* %10
ret void
}
int test_imm_38int16_reg(short val) {
  return ((val) & (0x38 << 0)) ? -20 : -40;
}


x86 assembly (clang, -O0):
<test_imm_38int16_reg>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%edx
and    $0x38,%edx
mov    $0xffffffd8,%eax
mov    $0xffffffec,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_imm_38int16_reg>:
test   $0x38,%dil
mov    $0xffffffd8,%ecx
mov    $0xffffffec,%eax
cmove  %ecx,%eax
ret

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

LLVM IR (-O2):
define i32 @test_imm_38int16_reg(i16 signext %0) {
%2 = and i16 %0, 56
%3 = icmp eq i16 %2, 0
%4 = select i1 %3, i32 -40, i32 -20
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ fcntl_postprocess_(char const *, int, int, int, void *);
void fcntl64_postprocess_(const char *realfnname, int ret, int fd, int cmd,
                          void *arg) {
  fcntl_postprocess_(realfnname, ret, fd, cmd, arg);
}


x86 assembly (clang, -O0):
<fcntl64_postprocess_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1030 <fcntl_postprocess_@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fcntl64_postprocess_>:
jmp    1030 <fcntl_postprocess_@plt>

LLVM IR (-O0):
define void @fcntl64_postprocess_(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%11 = load i8*, i8** %6
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = load i8*, i8** %10
%16 = call i32 @fcntl_postprocess_(i8* %11, i32 %12, i32 %13, i32 %14, i8* %15)
ret void
}

LLVM IR (-O2):
define void @fcntl64_postprocess_(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4) {
%6 = tail call i32 @fcntl_postprocess_(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4)
ret void
}
int _fstat_r(struct _reent *reent, int fd, struct stat *stat) { return -1; }


x86 assembly (clang, -O0):
<_fstat_r>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0xffffffff,%eax
pop    %rbp
ret

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

LLVM IR (-O0):
%struct._reent = type opaque
%struct.stat = type opaque
define i32 @_fstat_r(%struct._reent* %0, i32 %1, %struct.stat* %2) {
%4 = alloca %struct._reent*
%5 = alloca i32
%6 = alloca %struct.stat*
store %struct._reent* %0, %struct._reent** %4
store i32 %1, i32* %5
store %struct.stat* %2, %struct.stat** %6
ret i32 -1
}

LLVM IR (-O2):
%struct._reent = type opaque
%struct.stat = type opaque
define i32 @_fstat_r(%struct._reent* nocapture readnone %0, i32 %1, %struct.stat* nocapture readnone %2) {
ret i32 -1
}
int abs(int x) { return x < 0 ? -x : x; }


x86 assembly (clang, -O0):
<abs>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    111e <abs+0x1e>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1124 <abs+0x24>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<abs>:
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
ret

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

LLVM IR (-O2):
define i32 @abs(i32 %0) {
%2 = tail call i32 @llvm.abs.i32(i32 %0, i1 true)
ret i32 %2
}
/* Type definitions */
struct dbuf_s {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ dbuf_c_str(struct dbuf_s *);
char *dbuf_detach(struct dbuf_s *);
char *dbuf_detach_c_str(struct dbuf_s *dbuf) {
  dbuf_c_str(dbuf);
  return dbuf_detach(dbuf);
}


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

x86 assembly (clang, -O2):
<dbuf_detach_c_str>:
push   %rbx
mov    %rdi,%rbx
call   1030 <dbuf_c_str@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <dbuf_detach@plt>

LLVM IR (-O0):
%struct.dbuf_s = type { i32 }
define i8* @dbuf_detach_c_str(%struct.dbuf_s* %0) {
%2 = alloca %struct.dbuf_s*
store %struct.dbuf_s* %0, %struct.dbuf_s** %2
%3 = load %struct.dbuf_s*, %struct.dbuf_s** %2
%4 = call i32 @dbuf_c_str(%struct.dbuf_s* %3)
%5 = load %struct.dbuf_s*, %struct.dbuf_s** %2
%6 = call i8* @dbuf_detach(%struct.dbuf_s* %5)
ret i8* %6
}

LLVM IR (-O2):
%struct.dbuf_s = type { i32 }
define i8* @dbuf_detach_c_str(%struct.dbuf_s* %0) {
%2 = tail call i32 @dbuf_c_str(%struct.dbuf_s* %0)
%3 = tail call i8* @dbuf_detach(%struct.dbuf_s* %0)
ret i8* %3
}
/* Variables and functions */
int _ada_use_c2phc4c(int, int *, int *, double *, int /*<<< orphan*/);
int syspool_dobldobl_initialize(int n) {
  int *b, fail;
  double *c;
  fail = _ada_use_c2phc4c(318, &n, b, c, 0);
  return fail;
}


x86 assembly (clang, -O0):
<syspool_dobldobl_initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x13e,%edi
lea    -0x4(%rbp),%rsi
xor    %r8d,%r8d
call   1030 <_ada_use_c2phc4c@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syspool_dobldobl_initialize>:
push   %rax
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rsi
mov    $0x13e,%edi
xor    %r8d,%r8d
call   1030 <_ada_use_c2phc4c@plt>
pop    %rcx
ret

LLVM IR (-O0):
define i32 @syspool_dobldobl_initialize(i32 %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca double*
store i32 %0, i32* %2
%6 = load i32*, i32** %3
%7 = load double*, double** %5
%8 = call i32 @_ada_use_c2phc4c(i32 318, i32* %2, i32* %6, double* %7, i32 0)
store i32 %8, i32* %4
%9 = load i32, i32* %4
ret i32 %9
}

LLVM IR (-O2):
define i32 @syspool_dobldobl_initialize(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @_ada_use_c2phc4c(i32 318, i32* %2, i32* undef, double* undef, i32 0)
ret i32 %3
}
/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
int tcpreuseaddr(int sock) {
  int yes = 1;
  return setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(int));
}


x86 assembly (clang, -O0):
<tcpreuseaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ebc(%rip),%rax
mov    (%rax),%esi
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcpreuseaddr>:
push   %rax
movl   $0x1,0x4(%rsp)
mov    0x2ec8(%rip),%rax
mov    (%rax),%esi
mov    0x2eaf(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
pop    %rcx
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
define i32 @tcpreuseaddr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
%4 = load i32, i32* %2
%5 = load i32, i32* @SOL_SOCKET
%6 = load i32, i32* @SO_REUSEADDR
%7 = bitcast i32* %3 to i8*
%8 = call i32 @setsockopt(i32 %4, i32 %5, i32 %6, i8* %7, i32 4)
ret i32 %8
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
define i32 @tcpreuseaddr(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = load i32, i32* @SOL_SOCKET
%5 = load i32, i32* @SO_REUSEADDR
%6 = call i32 @setsockopt(i32 %0, i32 %4, i32 %5, i8* %3, i32 4)
ret i32 %6
}
void g_slist_free_1() {}


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

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

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

LLVM IR (-O2):
define void @g_slist_free_1() {
ret void
}
/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fatal(char *);
int *ckalloc(int n) {
  int *p;
  if (p = (int *)calloc(1, n))
    return p;
  fatal("out of memory");
  return 0;
}


x86 assembly (clang, -O0):
<ckalloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1153 <ckalloc+0x33>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1167 <ckalloc+0x47>
lea    0xea6(%rip),%rdi
call   1040 <fatal@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ckalloc>:
push   %rax
mov    %edi,%esi
mov    $0x1,%edi
call   1030 <calloc@plt>
test   %rax,%rax
je     1134 <ckalloc+0x14>
pop    %rcx
ret
lea    0xec5(%rip),%rdi
call   1040 <fatal@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"out of memory\00"
define i32* @ckalloc(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32*
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = call i64 @calloc(i32 1, i32 %5)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i32*, i32** %4
store i32* %10, i32** %2
br label %13
11: ; preds = %1
%12 = call i32 @fatal(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32* null, i32** %2
br label %13
13: ; preds = %11, %9
%14 = load i32*, i32** %2
ret i32* %14
}

LLVM IR (-O2):
@.str = [14 x i8] c"out of memory\00"
define i32* @ckalloc(i32 %0) {
%2 = tail call i64 @calloc(i32 1, i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = inttoptr i64 %2 to i32*
br label %8
6: ; preds = %1
%7 = tail call i32 @fatal(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32* [ %5, %4 ], [ null, %6 ]
ret i32* %9
}
/* Variables and functions */
int /*<<< orphan*/ cleanUpAndFail(int);
void ioError() { cleanUpAndFail(1); }


x86 assembly (clang, -O0):
<ioError>:
push   %rbp
mov    %rsp,%rbp
mov    $0x1,%edi
call   1030 <cleanUpAndFail@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ioError>:
mov    $0x1,%edi
jmp    1030 <cleanUpAndFail@plt>

LLVM IR (-O0):
define void @ioError() {
%1 = call i32 @cleanUpAndFail(i32 1)
ret void
}

LLVM IR (-O2):
define void @ioError() {
%1 = tail call i32 @cleanUpAndFail(i32 1)
ret void
}
/* Variables and functions */
uintptr_t insn_len(uintptr_t pc) { return (*(unsigned short *)pc & 3) ? 4 : 2; }


x86 assembly (clang, -O0):
<insn_len>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzwl (%rax),%edx
and    $0x3,%edx
mov    $0x2,%eax
mov    $0x4,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
cltq
pop    %rbp
ret

x86 assembly (clang, -O2):
<insn_len>:
xor    %eax,%eax
testb  $0x3,(%rdi)
setne  %al
add    %rax,%rax
add    $0x2,%rax
ret

LLVM IR (-O0):
define i64 @insn_len(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = inttoptr i64 %3 to i16*
%5 = load i16, i16* %4
%6 = zext i16 %5 to i32
%7 = and i32 %6, 3
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i64
%10 = select i1 %8, i32 4, i32 2
%11 = sext i32 %10 to i64
ret i64 %11
}

LLVM IR (-O2):
define i64 @insn_len(i64 %0) {
%2 = inttoptr i64 %0 to i16*
%3 = load i16, i16* %2
%4 = and i16 %3, 3
%5 = icmp eq i16 %4, 0
%6 = select i1 %5, i64 2, i64 4
ret i64 %6
}
/* Variables and functions */
int /*<<< orphan*/ free(void *);
int posix_memalign(void **, int, size_t);
int main(void) {
  void *alloc_buf;
  int ret;
  ret = posix_memalign((void **)&alloc_buf, 64, (size_t)1024);
  if (!ret)
    free(alloc_buf);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x40,%esi
mov    $0x400,%edx
call   1040 <posix_memalign@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1158 <main+0x38>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    %rsp,%rdi
mov    $0x400,%edx
mov    $0x40,%esi
call   1040 <posix_memalign@plt>
test   %eax,%eax
jne    1140 <main+0x20>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @posix_memalign(i8** %2, i32 64, i64 1024)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 @free(i8* %8)
br label %10
10: ; preds = %7, %0
%11 = load i32, i32* %1
ret i32 %11
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i32 @posix_memalign(i8** %1, i32 64, i64 1024)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i8*, i8** %1
%7 = call i32 @free(i8* %6)
br label %8
8: ; preds = %5, %0
ret i32 0
}
/* Variables and functions */
scalar_t__ matchColor(char const **);
int CSSValueIsColor(const char *str) {
  if (str == NULL)
    return 0;
  return (matchColor(&str) && (*str == 0));
}


x86 assembly (clang, -O0):
<CSSValueIsColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <CSSValueIsColor+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1169 <CSSValueIsColor+0x59>
lea    -0x10(%rbp),%rdi
call   1030 <matchColor@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     115e <CSSValueIsColor+0x4e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CSSValueIsColor>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
xor    %ebx,%ebx
test   %rdi,%rdi
je     113d <CSSValueIsColor+0x2d>
lea    0x8(%rsp),%rdi
call   1030 <matchColor@plt>
test   %rax,%rax
je     113d <CSSValueIsColor+0x2d>
mov    0x8(%rsp),%rax
xor    %ebx,%ebx
cmpb   $0x0,(%rax)
sete   %bl
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @CSSValueIsColor(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = icmp eq i8* %0, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = call i64 @matchColor(i8** %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %4, %7, %1
%13 = phi i32 [ 0, %1 ], [ 0, %4 ], [ %11, %7 ]
ret i32 %13
}
/* Variables and functions */
int /*<<< orphan*/ kore_seccomp_enable();
void kore_platform_sandbox(void) { kore_seccomp_enable(); }


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

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

LLVM IR (-O0):
define void @kore_platform_sandbox() {
%1 = call i32 (...) @kore_seccomp_enable()
ret void
}

LLVM IR (-O2):
define void @kore_platform_sandbox() {
%1 = tail call i32 (...) @kore_seccomp_enable()
ret void
}
/* Type definitions */
typedef int uint16_t;
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ _pol_gen_flat(int /*<<< orphan*/ *, int const, int const);
scalar_t__ is_balance(int /*<<< orphan*/ *, int const);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
void pol_gen_flat(int64_t *ai, const uint16_t N, const uint16_t d) {
  do {
    memset(ai, 0, sizeof(int64_t) * N);
    _pol_gen_flat(ai, N, d);
  } while (is_balance(ai, N) == 0);
}


x86 assembly (clang, -O0):
<pol_gen_flat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <_pol_gen_flat@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <is_balance@plt>
cmp    $0x0,%rax
je     1142 <pol_gen_flat+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pol_gen_flat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0x0(,%rbx,4),%r15d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r15d,%edx
call   1040 <memset@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r14d,%edx
call   1030 <_pol_gen_flat@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1050 <is_balance@plt>
test   %rax,%rax
je     1150 <pol_gen_flat+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @pol_gen_flat(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
br label %7
7: ; preds = %18, %3
%8 = load i32*, i32** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = mul i64 4, %10
%12 = trunc i64 %11 to i32
%13 = call i32 @memset(i32* %8, i32 0, i32 %12)
%14 = load i32*, i32** %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @_pol_gen_flat(i32* %14, i32 %15, i32 %16)
br label %18
18: ; preds = %7
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = call i64 @is_balance(i32* %19, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %7, label %23
23: ; preds = %18
ret void
}

LLVM IR (-O2):
define void @pol_gen_flat(i32* %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 2
br label %5
5: ; preds = %5, %3
%6 = tail call i32 @memset(i32* %0, i32 0, i32 %4)
%7 = tail call i32 @_pol_gen_flat(i32* %0, i32 %1, i32 %2)
%8 = tail call i64 @is_balance(i32* %0, i32 %1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %5, label %10
10: ; preds = %5
ret void
}
/* Forward declarations */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ serial;
};
struct TYPE_4__ {
  TYPE_1__ xclient;
};
typedef TYPE_2__ XEvent;

/* Variables and functions */
unsigned long get_XEvent_xclient_serial(void *_p) {
  return (unsigned long)((XEvent *)_p)->xclient.serial;
}


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

x86 assembly (clang, -O2):
<get_XEvent_xclient_serial>:
mov    (%rdi),%rax
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i64 }
define i64 @get_XEvent_xclient_serial(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = bitcast i8* %3 to %struct.TYPE_4__*
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i32 0, i32 0
%6 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%7 = load i64, i64* %6
ret i64 %7
}

LLVM IR (-O2):
define i64 @get_XEvent_xclient_serial(i8* nocapture %0) {
%2 = bitcast i8* %0 to i64*
%3 = load i64, i64* %2
ret i64 %3
}
void irq_send_eoi() {}


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

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

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

LLVM IR (-O2):
define void @irq_send_eoi() {
ret void
}
/* Type definitions */
typedef int uint32_t;

/* Variables and functions */
uint32_t setBit_fun_uint32_t(uint32_t x, uint32_t i) { return x | 1 << i; }


x86 assembly (clang, -O0):
<setBit_fun_uint32_t>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<setBit_fun_uint32_t>:
mov    %edi,%eax
bts    %esi,%eax
ret

LLVM IR (-O0):
define i32 @setBit_fun_uint32_t(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 = shl i32 1, %6
%8 = or i32 %5, %7
ret i32 %8
}

LLVM IR (-O2):
define i32 @setBit_fun_uint32_t(i32 %0, i32 %1) {
%3 = shl nuw i32 1, %1
%4 = or i32 %3, %0
ret i32 %4
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *);
void usage(const char *prog) {
  printf("Usage: %s len file1 loff1 file2 loff2\n", prog);
}


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 = [39 x i8] c"Usage: %s len file1 loff1 file2 loff2\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 ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"Usage: %s len file1 loff1 file2 loff2\0A\00"
define void @usage(i8* %0) {
%2 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}
/* Type definitions */
typedef int /*<<< orphan*/ pthread_rwlockattr_t;
typedef int /*<<< orphan*/ pthread_rwlock_t;

/* Variables and functions */
scalar_t__ pthread_rwlock_destroy(int /*<<< orphan*/ *);
scalar_t__ pthread_rwlock_init(int /*<<< orphan*/ *,
                               int /*<<< orphan*/ const *);
int rwlock_reinit(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) {
  int result = 1;
  if (pthread_rwlock_destroy(rwlock) == 0 &&
      pthread_rwlock_init(rwlock, attr) == 0)
    result = 0;
  return result;
}


x86 assembly (clang, -O0):
<rwlock_reinit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <pthread_rwlock_destroy@plt>
cmp    $0x0,%rax
jne    1168 <rwlock_reinit+0x48>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <pthread_rwlock_init@plt>
cmp    $0x0,%rax
jne    1168 <rwlock_reinit+0x48>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rwlock_reinit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <pthread_rwlock_destroy@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1152 <rwlock_reinit+0x32>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <pthread_rwlock_init@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @rwlock_reinit(i32* %0, i32* %1) {
%3 = tail call i64 @pthread_rwlock_destroy(i32* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = tail call i64 @pthread_rwlock_init(i32* %0, i32* %1)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ 1, %2 ], [ %8, %5 ]
ret i32 %10
}
void reset_buff(char *buff, int size) {
  int i;
  for (i = 0; i < size; i++)
    buff[i] = '\0';
}


x86 assembly (clang, -O0):
<reset_buff>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1138 <reset_buff+0x38>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1112 <reset_buff+0x12>
pop    %rbp
ret

x86 assembly (clang, -O2):
<reset_buff>:
test   %esi,%esi
jle    1122 <reset_buff+0x12>
push   %rax
mov    %esi,%edx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x8,%rsp
ret

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

LLVM IR (-O2):
define void @reset_buff(i8* nocapture writeonly %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %2
ret void
}
int isOdd(int number) { return (number % 2 == 0); }


x86 assembly (clang, -O0):
<isOdd>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
sete   %al
and    $0x1,%al
movzbl %al,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<isOdd>:
mov    %edi,%eax
not    %eax
and    $0x1,%eax
ret

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

LLVM IR (-O2):
define i32 @isOdd(i32 %0) {
%2 = and i32 %0, 1
%3 = xor i32 %2, 1
ret i32 %3
}
void bit_set(unsigned char *bf, int n, int v) {
  bf[n >> 3] = (bf[n >> 3] & ~(1 << (n % 8))) | ((v ? 1 : 0) << (n % 8));
}


x86 assembly (clang, -O0):
<bit_set>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sar    $0x3,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x1c(%rbp),%eax
mov    %edx,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
mov    %edx,%ecx
mov    -0x14(%rbp),%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sar    $0x3,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
pop    %rbp
ret

x86 assembly (clang, -O2):
<bit_set>:
mov    %esi,%ecx
mov    %esi,%eax
sar    $0x3,%eax
movslq %eax,%r8
movzbl (%rdi,%r8,1),%esi
lea    0x7(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xf8,%eax
sub    %eax,%ecx
btr    %ecx,%esi
xor    %eax,%eax
test   %edx,%edx
setne  %al
shl    %cl,%eax
or     %esi,%eax
mov    %al,(%rdi,%r8,1)
ret

LLVM IR (-O0):
define void @bit_set(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i8*, i8** %4
%8 = load i32, i32* %5
%9 = ashr i32 %8, 3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = load i32, i32* %5
%15 = srem i32 %14, 8
%16 = shl i32 1, %15
%17 = xor i32 %16, -1
%18 = and i32 %13, %17
%19 = load i32, i32* %6
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 0
%23 = load i32, i32* %5
%24 = srem i32 %23, 8
%25 = shl i32 %22, %24
%26 = or i32 %18, %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = ashr i32 %29, 3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 %27, i8* %32
ret void
}

LLVM IR (-O2):
define void @bit_set(i8* nocapture %0, i32 %1, i32 %2) {
%4 = ashr i32 %1, 3
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = srem i32 %1, 8
%10 = shl nuw nsw i32 1, %9
%11 = xor i32 %10, -1
%12 = and i32 %8, %11
%13 = icmp ne i32 %2, 0
%14 = zext i1 %13 to i32
%15 = shl nuw nsw i32 %14, %9
%16 = or i32 %12, %15
%17 = trunc i32 %16 to i8
store i8 %17, i8* %6
ret void
}
/* Variables and functions */
char *strchr(char *, char);
void chomp(char *buff) {
  char *p;
  if ((p = strchr(buff, '\n')) != NULL) {
    *p = '\0';
  }
}


x86 assembly (clang, -O0):
<chomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     113f <chomp+0x2f>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chomp>:
push   %rax
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1123 <chomp+0x13>
movb   $0x0,(%rax)
pop    %rax
ret

LLVM IR (-O0):
define void @chomp(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strchr(i8* %4, i8 signext 10)
store i8* %5, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = load i8*, i8** %3
store i8 0, i8* %8
br label %9
9: ; preds = %7, %1
ret void
}

LLVM IR (-O2):
define void @chomp(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 10)
%3 = icmp eq i8* %2, null
br i1 %3, label %5, label %4
4: ; preds = %1
store i8 0, i8* %2
br label %5
5: ; preds = %4, %1
ret void
}
/* Variables and functions */
int /*<<< orphan*/ clang_analyzer_eval(int);
int strnlen(char const *, int);
void strnlen_constant1() {
  const char *a = "123";
  clang_analyzer_eval(strnlen(a, 10) == 3);
}


x86 assembly (clang, -O0):
<strnlen_constant1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strnlen@plt>
cmp    $0x3,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <clang_analyzer_eval@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strnlen_constant1>:
push   %rax
lea    0xed8(%rip),%rdi
mov    $0xa,%esi
call   1030 <strnlen@plt>
xor    %edi,%edi
cmp    $0x3,%eax
sete   %dil
pop    %rax
jmp    1040 <clang_analyzer_eval@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"123\00"
define void @strnlen_constant1() {
%1 = alloca i8*
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %1
%2 = load i8*, i8** %1
%3 = call i32 @strnlen(i8* %2, i32 10)
%4 = icmp eq i32 %3, 3
%5 = zext i1 %4 to i32
%6 = call i32 @clang_analyzer_eval(i32 %5)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"123\00"
define void @strnlen_constant1() {
%1 = tail call i32 @strnlen(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 10)
%2 = icmp eq i32 %1, 3
%3 = zext i1 %2 to i32
%4 = tail call i32 @clang_analyzer_eval(i32 %3)
ret void
}
/* Variables and functions */
int prime(long);
int /*<<< orphan*/ puts(char *);
long strtol(char *, char **, int);
int main(int argc, char *argv[]) {
  char *ptr;
  long n = strtol(argv[1], &ptr, 10);
  int p = prime(n);
  if (p) {
    puts("True");
  } else {
    puts("False");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <prime@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1187 <main+0x57>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
jmp    1193 <main+0x63>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x8(%rsi),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,%rdi
call   1050 <prime@plt>
test   %eax,%eax
lea    0xeb2(%rip),%rax
lea    0xea6(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"True\00"
@.str.1 = [6 x i8] c"False\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i64 @strtol(i8* %6, i8** %3, i32 10)
%8 = tail call i32 @prime(i64 %7)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 0
}
/* Variables and functions */
int getchar();
int /*<<< orphan*/ printf(char *);
int ask() {
  printf("1. Add user\n");
  printf("2. Quit\n");
  return getchar() - 48;
}


x86 assembly (clang, -O0):
<ask>:
push   %rbp
mov    %rsp,%rbp
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
sub    $0x30,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ask>:
push   %rax
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
lea    0xed8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
add    $0xffffffd0,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"1. Add user\0A\00"
@.str.1 = [9 x i8] c"2. Quit\0A\00"
define i32 @ask() {
%1 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 (...) @getchar()
%4 = sub nsw i32 %3, 48
ret i32 %4
}

LLVM IR (-O2):
@str = [12 x i8] c"1. Add user\00"
@str.2 = [8 x i8] c"2. Quit\00"
define i32 @ask() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.2, i64 0, i64 0))
%3 = tail call i32 (...) @getchar()
%4 = add nsw i32 %3, -48
ret i32 %4
}
/* Variables and functions */
unsigned char *encode(unsigned char *, unsigned int);
unsigned char *encode_color(unsigned char *buffer, unsigned int color) {
  return encode(buffer, color);
}


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

x86 assembly (clang, -O2):
<encode_color>:
jmp    1030 <encode@plt>

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

LLVM IR (-O2):
define i8* @encode_color(i8* %0, i32 %1) {
%3 = tail call i8* @encode(i8* %0, i32 %1)
ret i8* %3
}
/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
int testSecImplied();
int testSedImplied();
int testSeiImplied();
void testSet() {
  printf("testSecImplied: %d\r\n", testSecImplied());
  printf("testSedImplied: %d\r\n", testSedImplied());
  printf("testSeiImplied: %d\r\n", testSeiImplied());
}


x86 assembly (clang, -O0):
<testSet>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1050 <testSecImplied@plt>
mov    %eax,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <testSedImplied@plt>
mov    %eax,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <testSeiImplied@plt>
mov    %eax,%esi
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<testSet>:
push   %rax
xor    %eax,%eax
call   1050 <testSecImplied@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1060 <testSedImplied@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <testSeiImplied@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"testSecImplied: %d\0D\0A\00"
@.str.1 = [21 x i8] c"testSedImplied: %d\0D\0A\00"
@.str.2 = [21 x i8] c"testSeiImplied: %d\0D\0A\00"
define void @testSet() {
%1 = call i32 (...) @testSecImplied()
%2 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = call i32 (...) @testSedImplied()
%4 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 (...) @testSeiImplied()
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %5)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"testSecImplied: %d\0D\0A\00"
@.str.1 = [21 x i8] c"testSedImplied: %d\0D\0A\00"
@.str.2 = [21 x i8] c"testSeiImplied: %d\0D\0A\00"
define void @testSet() {
%1 = tail call i32 (...) @testSecImplied()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 (...) @testSedImplied()
%4 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @testSeiImplied()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %5)
ret void
}
/* Variables and functions */
int /*<<< orphan*/ assert(int);
int mystrlen(char *);
int /*<<< orphan*/ printf(char *);
main() {
  char *s = "Hello world";
  assert(mystrlen(s) == 11);
  printf("mystrlen test passed\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mystrlen@plt>
cmp    $0xb,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1050 <mystrlen@plt>
xor    %edi,%edi
cmp    $0xb,%eax
sete   %dil
call   1040 <assert@plt>
lea    0xeba(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Hello world\00"
@.str.1 = [22 x i8] c"mystrlen test passed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @mystrlen(i8* %3)
%5 = icmp eq i32 %4, 11
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello world\00"
@str = [21 x i8] c"mystrlen test passed\00"
define i32 @main() {
%1 = tail call i32 @mystrlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32 %1, 11
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
ret i32 0
}
void RTTestFailed(void) {}


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

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

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

LLVM IR (-O2):
define void @RTTestFailed() {
ret void
}
/* Variables and functions */
int /*<<< orphan*/ print_to_syslog(int /*<<< orphan*/, char const *);
void logger_critical_log(const char *message) { print_to_syslog(0, message); }


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

x86 assembly (clang, -O2):
<logger_critical_log>:
mov    %rdi,%rsi
xor    %edi,%edi
jmp    1030 <print_to_syslog@plt>

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

LLVM IR (-O2):
define void @logger_critical_log(i8* %0) {
%2 = tail call i32 @print_to_syslog(i32 0, i8* %0)
ret void
}
int get_eeprom_rev_9003(struct edump *edump) { return 0; }


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

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

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

LLVM IR (-O2):
%struct.edump = type opaque
define i32 @get_eeprom_rev_9003(%struct.edump* nocapture readnone %0) {
ret i32 0
}