#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*/ print(char *);
void putnum(unsigned int num) {
  char buf[9];
  int cnt;
  char *ptr;
  int digit;
  ptr = buf;
  for (cnt = 7; cnt >= 0; cnt--) {
    digit = (num >> (cnt * 4)) & 0xf;
    if (digit <= 9)
      *ptr++ = (char)('0' + digit);
    else
      *ptr++ = (char)('a' - 10 + digit);
  }
  *ptr = (char)0;
  print(buf);
}


x86 assembly (clang, -O0):
<putnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xd(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1199 <putnum+0x89>
mov    -0x4(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x2,%ecx
shr    %cl,%eax
and    $0xf,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x9,-0x24(%rbp)
jg     116d <putnum+0x5d>
mov    -0x24(%rbp),%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1186 <putnum+0x76>
mov    -0x24(%rbp),%eax
add    $0x57,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    118b <putnum+0x7b>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <putnum+0x1a>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xd(%rbp),%rdi
call   1030 <print@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putnum>:
sub    $0x18,%rsp
mov    %edi,%eax
shr    $0x1c,%eax
lea    0x57(%rax),%ecx
or     $0x30,%al
cmp    $0xa0000000,%edi
movzbl %al,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
mov    %cl,0xf(%rsp)
mov    %edi,%eax
shr    $0x18,%eax
and    $0xf,%eax
lea    0x57(%rax),%ecx
lea    0x30(%rax),%edx
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
mov    %edi,%eax
shr    $0x14,%eax
and    $0xf,%eax
lea    0x57(%rax),%edx
cmp    $0xa,%eax
lea    0x30(%rax),%eax
movzbl %al,%eax
movzbl %dl,%edx
cmovb  %eax,%edx
mov    %cl,0x10(%rsp)
mov    %dl,0x11(%rsp)
mov    %edi,%eax
shr    $0x10,%eax
and    $0xf,%eax
lea    0x57(%rax),%ecx
lea    0x30(%rax),%edx
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
mov    %edi,%eax
shr    $0xc,%eax
and    $0xf,%eax
lea    0x57(%rax),%edx
cmp    $0xa,%eax
lea    0x30(%rax),%eax
movzbl %al,%eax
movzbl %dl,%edx
cmovb  %eax,%edx
mov    %cl,0x12(%rsp)
mov    %dl,0x13(%rsp)
mov    %edi,%eax
shr    $0x8,%eax
and    $0xf,%eax
lea    0x57(%rax),%ecx
lea    0x30(%rax),%edx
cmp    $0xa,%eax
movzbl %dl,%eax
movzbl %cl,%ecx
cmovb  %eax,%ecx
mov    %edi,%eax
shr    $0x4,%eax
and    $0xf,%eax
lea    0x57(%rax),%edx
cmp    $0xa,%eax
lea    0x30(%rax),%eax
movzbl %al,%eax
movzbl %dl,%edx
cmovb  %eax,%edx
mov    %cl,0x14(%rsp)
mov    %dl,0x15(%rsp)
and    $0xf,%edi
lea    0x57(%rdi),%eax
lea    0x30(%rdi),%ecx
cmp    $0xa,%edi
movzbl %cl,%ecx
movzbl %al,%eax
cmovb  %ecx,%eax
mov    %al,0x16(%rsp)
movb   $0x0,0x17(%rsp)
lea    0xf(%rsp),%rdi
call   1030 <print@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define void @putnum(i32 %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = lshr i32 %0, 28
%5 = icmp ult i32 %0, -1610612736
%6 = trunc i32 %4 to i8
%7 = add nuw nsw i8 %6, 87
%8 = or i8 %6, 48
%9 = select i1 %5, i8 %8, i8 %7
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 1
store i8 %9, i8* %3
%11 = lshr i32 %0, 24
%12 = and i32 %11, 15
%13 = icmp ult i32 %12, 10
%14 = trunc i32 %12 to i8
%15 = add nuw nsw i8 %14, 87
%16 = or i8 %14, 48
%17 = select i1 %13, i8 %16, i8 %15
%18 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 2
store i8 %17, i8* %10
%19 = lshr i32 %0, 20
%20 = and i32 %19, 15
%21 = icmp ult i32 %20, 10
%22 = trunc i32 %20 to i8
%23 = add nuw nsw i8 %22, 87
%24 = or i8 %22, 48
%25 = select i1 %21, i8 %24, i8 %23
%26 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 3
store i8 %25, i8* %18
%27 = lshr i32 %0, 16
%28 = and i32 %27, 15
%29 = icmp ult i32 %28, 10
%30 = trunc i32 %28 to i8
%31 = add nuw nsw i8 %30, 87
%32 = or i8 %30, 48
%33 = select i1 %29, i8 %32, i8 %31
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 4
store i8 %33, i8* %26
%35 = lshr i32 %0, 12
%36 = and i32 %35, 15
%37 = icmp ult i32 %36, 10
%38 = trunc i32 %36 to i8
%39 = add nuw nsw i8 %38, 87
%40 = or i8 %38, 48
%41 = select i1 %37, i8 %40, i8 %39
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 5
store i8 %41, i8* %34
%43 = lshr i32 %0, 8
%44 = and i32 %43, 15
%45 = icmp ult i32 %44, 10
%46 = trunc i32 %44 to i8
%47 = add nuw nsw i8 %46, 87
%48 = or i8 %46, 48
%49 = select i1 %45, i8 %48, i8 %47
%50 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 6
store i8 %49, i8* %42
%51 = lshr i32 %0, 4
%52 = and i32 %51, 15
%53 = icmp ult i32 %52, 10
%54 = trunc i32 %52 to i8
%55 = add nuw nsw i8 %54, 87
%56 = or i8 %54, 48
%57 = select i1 %53, i8 %56, i8 %55
%58 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 7
store i8 %57, i8* %50
%59 = and i32 %0, 15
%60 = icmp ult i32 %59, 10
%61 = trunc i32 %59 to i8
%62 = add nuw nsw i8 %61, 87
%63 = or i8 %61, 48
%64 = select i1 %60, i8 %63, i8 %62
%65 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 8
store i8 %64, i8* %58
store i8 0, i8* %65
%66 = call i32 @print(i8* %3)
ret void
}