#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 atoi(char *);
int /*<<< orphan*/ itoa(int, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Usage: %s Decimal\n", argv[0]);
    return -1;
  }
  int d = atoi(argv[1]);
  char buf[12];
  itoa(d, buf, 16);
  printf("0x%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    116f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea2(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a7 <main+0x77>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <itoa@plt>
lea    -0x20(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1150 <main+0x20>
mov    (%rsi),%rsi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
jmp    117e <main+0x4e>
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
lea    0x4(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <itoa@plt>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Usage: %s Decimal\0A\00"
@.str.1 = [6 x i8] c"0x%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [12 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 -1, i32* %3
br label %25
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%22 = call i32 @itoa(i32 %20, i8* %21, i32 16)
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %23)
store i32 0, i32* %3
br label %25
25: ; preds = %15, %10
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@.str = [19 x i8] c"Usage: %s Decimal\0A\00"
@.str.1 = [6 x i8] c"0x%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [12 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %15
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%13 = call i32 @itoa(i32 %11, i8* %12, i32 16)
%14 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %15
15: ; preds = %8, %5
%16 = phi i32 [ -1, %5 ], [ 0, %8 ]
ret i32 %16
}