#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*/ reverse(char *);
void dispAsHexNumber(int val) {
  int temp;
  char str[10], ii = 0;
  while (val) {
    temp = val % 16;
    if ((temp > 9) && (temp < 16))
      temp = (temp % 10) + 'a';
    else
      temp += '0';
    str[ii] = temp;
    val = val / 16;
    ii++;
  }
  str[ii] = '\0';
  reverse(str);
}


x86 assembly (clang, -O0):
<dispAsHexNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,-0x13(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1193 <dispAsHexNumber+0x83>
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jle    1161 <dispAsHexNumber+0x51>
cmpl   $0x10,-0x8(%rbp)
jge    1161 <dispAsHexNumber+0x51>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %edx,-0x8(%rbp)
jmp    116a <dispAsHexNumber+0x5a>
mov    -0x8(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %al,%cl
movsbq -0x13(%rbp),%rax
mov    %cl,-0x12(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    111f <dispAsHexNumber+0xf>
movsbq -0x13(%rbp),%rax
movb   $0x0,-0x12(%rbp,%rax,1)
lea    -0x12(%rbp),%rdi
call   1030 <reverse@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispAsHexNumber>:
sub    $0x18,%rsp
xor    %eax,%eax
test   %edi,%edi
jne    1138 <dispAsHexNumber+0x28>
jmp    1172 <dispAsHexNumber+0x62>
nopl   0x0(%rax)
add    $0x30,%edi
sar    $0x4,%edx
movsbq %al,%rax
mov    %dil,0xe(%rsp,%rax,1)
add    $0x1,%al
mov    %edx,%edi
cmp    $0x1e,%ecx
jbe    116e <dispAsHexNumber+0x5e>
lea    0xf(%rdi),%ecx
test   %edi,%edi
mov    %edi,%edx
cmovs  %ecx,%edx
mov    %edx,%esi
and    $0xfffffff0,%esi
sub    %esi,%edi
cmp    $0xa,%edi
jl     1120 <dispAsHexNumber+0x10>
movzbl %dil,%esi
imul   $0xcd,%esi,%edi
shr    $0xa,%edi
and    $0xfffffffe,%edi
lea    (%rdi,%rdi,4),%edi
sub    %dil,%sil
add    $0x61,%sil
movzbl %sil,%edi
jmp    1123 <dispAsHexNumber+0x13>
movsbq %al,%rax
movb   $0x0,0xe(%rsp,%rax,1)
lea    0xe(%rsp),%rdi
call   1030 <reverse@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define void @dispAsHexNumber(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca i8
store i32 %0, i32* %2
store i8 0, i8* %5
br label %6
6: ; preds = %24, %1
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %34
9: ; preds = %6
%10 = load i32, i32* %2
%11 = srem i32 %10, 16
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp sgt i32 %12, 9
br i1 %13, label %14, label %21
14: ; preds = %9
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 16
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* %3
%19 = srem i32 %18, 10
%20 = add nsw i32 %19, 97
store i32 %20, i32* %3
br label %24
21: ; preds = %14, %9
%22 = load i32, i32* %3
%23 = add nsw i32 %22, 48
store i32 %23, i32* %3
br label %24
24: ; preds = %21, %17
%25 = load i32, i32* %3
%26 = trunc i32 %25 to i8
%27 = load i8, i8* %5
%28 = sext i8 %27 to i64
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %28
store i8 %26, i8* %29
%30 = load i32, i32* %2
%31 = sdiv i32 %30, 16
store i32 %31, i32* %2
%32 = load i8, i8* %5
%33 = add i8 %32, 1
store i8 %33, i8* %5
br label %6
34: ; preds = %6
%35 = load i8, i8* %5
%36 = sext i8 %35 to i64
%37 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %36
store i8 0, i8* %37
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%39 = call i32 @reverse(i8* %38)
ret void
}

LLVM IR (-O2):
define void @dispAsHexNumber(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 0
br i1 %4, label %28, label %5
5: ; preds = %1, %18
%6 = phi i8 [ %23, %18 ], [ 0, %1 ]
%7 = phi i32 [ %9, %18 ], [ %0, %1 ]
%8 = srem i32 %7, 16
%9 = sdiv i32 %7, 16
%10 = icmp sgt i32 %8, 9
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = trunc i32 %8 to i8
%13 = urem i8 %12, 10
%14 = add nuw nsw i8 %13, 97
%15 = zext i8 %14 to i32
br label %18
16: ; preds = %5
%17 = add nsw i32 %8, 48
br label %18
18: ; preds = %16, %11
%19 = phi i32 [ %15, %11 ], [ %17, %16 ]
%20 = trunc i32 %19 to i8
%21 = sext i8 %6 to i64
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %21
store i8 %20, i8* %22
%23 = add i8 %6, 1
%24 = add i32 %7, 15
%25 = icmp ult i32 %24, 31
br i1 %25, label %26, label %5
26: ; preds = %18
%27 = sext i8 %23 to i64
br label %28
28: ; preds = %26, %1
%29 = phi i64 [ 0, %1 ], [ %27, %26 ]
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %29
store i8 0, i8* %30
%31 = call i32 @reverse(i8* %3)
ret void
}