#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int cmp(void *local, void *out) {
  int *a = (int *)local;
  int *b = (int *)out;
  printf("[====local is %d and out is %d====]\n", *a, *b);
  if (*a > *b)
    return 1;
  if (*a < *b)
    return -1;
  if (*a == *b)
    return 0;
  return 0;
}


x86 assembly (clang, -O0):
<cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jle    1166 <cmp+0x56>
movl   $0x1,-0x4(%rbp)
jmp    11a9 <cmp+0x99>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jge    1184 <cmp+0x74>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <cmp+0x99>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
cmp    (%rcx),%eax
jne    11a2 <cmp+0x92>
movl   $0x0,-0x4(%rbp)
jmp    11a9 <cmp+0x99>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%esi
mov    (%r14),%edx
lea    0xeda(%rip),%rdi
call   1030 <printf@plt>
mov    (%rbx),%eax
mov    (%r14),%ecx
xor    %edx,%edx
cmp    %ecx,%eax
setl   %dl
neg    %edx
cmp    %ecx,%eax
mov    $0x1,%eax
cmovle %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"[====local is %d and out is %d====]\0A\00"
define i32 @cmp(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
%10 = load i8*, i8** %5
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %7
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = load i32*, i32** %7
%15 = load i32, i32* %14
%16 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15)
%17 = load i32*, i32** %6
%18 = load i32, i32* %17
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = icmp sgt i32 %18, %20
br i1 %21, label %22, label %23
22: ; preds = %2
store i32 1, i32* %3
br label %38
23: ; preds = %2
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = load i32*, i32** %7
%27 = load i32, i32* %26
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 -1, i32* %3
br label %38
30: ; preds = %23
%31 = load i32*, i32** %6
%32 = load i32, i32* %31
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %30
store i32 0, i32* %3
br label %38
37: ; preds = %30
store i32 0, i32* %3
br label %38
38: ; preds = %37, %36, %29, %22
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [37 x i8] c"[====local is %d and out is %d====]\0A\00"
define i32 @cmp(i8* nocapture %0, i8* nocapture %1) {
%3 = bitcast i8* %0 to i32*
%4 = bitcast i8* %1 to i32*
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = icmp sgt i32 %8, %9
%11 = icmp slt i32 %8, %9
%12 = sext i1 %11 to i32
%13 = select i1 %10, i32 1, i32 %12
ret i32 %13
}