#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 INT_MIN;
int /*<<< orphan*/ strcpy(char *, char *);
char *uint_hex(unsigned int, char *);
char *int_hex(int x, char *buf) {
  if (x == INT_MIN) {
    strcpy(buf, "-80000000");
    return buf + 10;
  } else if (x < 0) {
    *buf++ = '-';
    return uint_hex((unsigned int)(-x), buf);
  } else
    return uint_hex((unsigned int)x, buf);
}


x86 assembly (clang, -O0):
<int_hex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2eaf(%rip),%rcx
cmp    (%rcx),%eax
jne    1162 <int_hex+0x42>
mov    -0x18(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
add    $0xa,%rax
mov    %rax,-0x8(%rbp)
jmp    11a5 <int_hex+0x85>
cmpl   $0x0,-0xc(%rbp)
jge    1195 <int_hex+0x75>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2d,(%rax)
xor    %edi,%edi
sub    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <uint_hex@plt>
mov    %rax,-0x8(%rbp)
jmp    11a5 <int_hex+0x85>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <uint_hex@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_hex>:
push   %rbx
mov    %rsi,%rbx
mov    0x2ebd(%rip),%rax
cmp    %edi,(%rax)
jne    1147 <int_hex+0x27>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0xa,%rbx
mov    %rbx,%rax
pop    %rbx
ret
test   %edi,%edi
jns    1154 <int_hex+0x34>
movb   $0x2d,(%rbx)
add    $0x1,%rbx
neg    %edi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <uint_hex@plt>

LLVM IR (-O0):
@INT_MIN = global i32 0
@.str = [10 x i8] c"-80000000\00"
define i8* @int_hex(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i32, i32* %4
%7 = load i32, i32* @INT_MIN
%8 = icmp eq i32 %6, %7
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 10
store i8* %13, i8** %3
br label %28
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
store i8 45, i8* %18
%20 = load i32, i32* %4
%21 = sub nsw i32 0, %20
%22 = load i8*, i8** %5
%23 = call i8* @uint_hex(i32 %21, i8* %22)
store i8* %23, i8** %3
br label %28
24: ; preds = %14
%25 = load i32, i32* %4
%26 = load i8*, i8** %5
%27 = call i8* @uint_hex(i32 %25, i8* %26)
store i8* %27, i8** %3
br label %28
28: ; preds = %24, %17, %9
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@INT_MIN = global i32 0
@.str = [10 x i8] c"-80000000\00"
define i8* @int_hex(i32 %0, i8* %1) {
%3 = load i32, i32* @INT_MIN
%4 = icmp eq i32 %3, %0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds i8, i8* %1, i64 10
br label %16
8: ; preds = %2
%9 = icmp slt i32 %0, 0
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = getelementptr inbounds i8, i8* %1, i64 1
store i8 45, i8* %1
%12 = sub nsw i32 0, %0
%13 = tail call i8* @uint_hex(i32 %12, i8* %11)
br label %16
14: ; preds = %8
%15 = tail call i8* @uint_hex(i32 %0, i8* %1)
br label %16
16: ; preds = %14, %10, %5
%17 = phi i8* [ %7, %5 ], [ %13, %10 ], [ %15, %14 ]
ret i8* %17
}