#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 /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char const *argv[]) {
  printf("please input an integer\n");
  int i, p, n;
  int number[40];
  scanf("%d", &n);
  p = -1;
  while (n != 0) {
    number[++p] = n % 16;
    n /= 16;
  }
  for (i = p; i >= 0; i--) {
    if (number[i] < 10)
      printf("%d", number[i]);
    else
      printf("%c", 'A' + number[i] - 10);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0xffffffff,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1198 <main+0x78>
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cltq
mov    %edx,-0xc0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
jmp    115e <main+0x3e>
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     120a <main+0xea>
movslq -0x14(%rbp),%rax
cmpl   $0xa,-0xc0(%rbp,%rax,4)
0a
jge    11d8 <main+0xb8>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,4),%esi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f7 <main+0xd7>
movslq -0x14(%rbp),%rax
mov    -0xc0(%rbp,%rax,4),%esi
add    $0x41,%esi
sub    $0xa,%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11fc <main+0xdc>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    119e <main+0x7e>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xb8,%rsp
lea    0xeb2(%rip),%rdi
call   1040 <puts@plt>
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11e9 <main+0xa9>
mov    $0xffffffffffffffff,%rcx
cs nopw 0x0(%rax,%rax,1)
lea    0xf(%rax),%edx
test   %eax,%eax
mov    %eax,%esi
cmovs  %edx,%esi
mov    %esi,%edi
and    $0xfffffff0,%edi
sub    %edi,%eax
mov    %eax,0x14(%rsp,%rcx,4)
add    $0x1,%rcx
mov    %esi,%eax
sar    $0x4,%eax
cmp    $0x1f,%edx
jae    1180 <main+0x40>
mov    %eax,0xc(%rsp)
test   $0x80000000,%ecx
jne    11e9 <main+0xa9>
mov    %ecx,%ebx
add    $0x1,%rbx
lea    0xe44(%rip),%r14
jmp    11d0 <main+0x90>
xchg   %ax,%ax
add    $0x37,%esi
mov    %esi,%edi
call   1030 <putchar@plt>
add    $0xffffffffffffffff,%rbx
jle    11e9 <main+0xa9>
mov    0xc(%rsp,%rbx,4),%esi
cmp    $0x9,%esi
jg     11c0 <main+0x80>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
jg     11d0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [25 x i8] c"please input an integer\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [40 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
store i32 -1, i32* %7
br label %12
12: ; preds = %15, %2
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %8
%17 = srem i32 %16, 16
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
store i32 %19, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [40 x i32], [40 x i32]* %9, i64 0, i64 %20
store i32 %17, i32* %21
%22 = load i32, i32* %8
%23 = sdiv i32 %22, 16
store i32 %23, i32* %8
br label %12
24: ; preds = %12
%25 = load i32, i32* %7
store i32 %25, i32* %6
br label %26
26: ; preds = %50, %24
%27 = load i32, i32* %6
%28 = icmp sge i32 %27, 0
br i1 %28, label %29, label %53
29: ; preds = %26
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [40 x i32], [40 x i32]* %9, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = icmp slt i32 %33, 10
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = load i32, i32* %6
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [40 x i32], [40 x i32]* %9, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
br label %49
41: ; preds = %29
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [40 x i32], [40 x i32]* %9, i64 0, i64 %43
%45 = load i32, i32* %44
%46 = add nsw i32 65, %45
%47 = sub nsw i32 %46, 10
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %47)
br label %49
49: ; preds = %41, %35
br label %50
50: ; preds = %49
%51 = load i32, i32* %6
%52 = add nsw i32 %51, -1
store i32 %52, i32* %6
br label %26
53: ; preds = %26
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@str = [24 x i8] c"please input an integer\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [40 x i32]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%6 = bitcast i32* %3 to i8*
%7 = bitcast [40 x i32]* %4 to i8*
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 0
br i1 %10, label %38, label %16
11: ; preds = %16
store i32 %22, i32* %3
%12 = and i64 %20, 2147483648
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %11
%15 = and i64 %20, 4294967295
br label %25
16: ; preds = %2, %16
%17 = phi i64 [ %20, %16 ], [ -1, %2 ]
%18 = phi i32 [ %22, %16 ], [ %9, %2 ]
%19 = srem i32 %18, 16
%20 = add nsw i64 %17, 1
%21 = getelementptr inbounds [40 x i32], [40 x i32]* %4, i64 0, i64 %20
store i32 %19, i32* %21
%22 = sdiv i32 %18, 16
%23 = add i32 %18, 15
%24 = icmp ult i32 %23, 31
br i1 %24, label %11, label %16
25: ; preds = %14, %35
%26 = phi i64 [ %15, %14 ], [ %36, %35 ]
%27 = getelementptr inbounds [40 x i32], [40 x i32]* %4, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = icmp slt i32 %28, 10
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %35
32: ; preds = %25
%33 = add nuw nsw i32 %28, 55
%34 = call i32 @putchar(i32 %33)
br label %35
35: ; preds = %30, %32
%36 = add nsw i64 %26, -1
%37 = icmp sgt i64 %26, 0
br i1 %37, label %25, label %38
38: ; preds = %35, %2, %11
%39 = call i32 @putchar(i32 10)
ret i32 0
}