#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 *, char *);
main() {
  unsigned int k = 987, i = 0;
  char trans[10];
  do {
    trans[i++] = (k % 16 > 9 ? k % 16 - 10 + 'a' : k % 16 - '0');
  } while (k /= 16);
  printf("%s\n", trans);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3db,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0xf,%eax
cmp    $0x9,%eax
jbe    1150 <main+0x40>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
sub    $0xa,%eax
add    $0x61,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <main+0x4c>
mov    -0x8(%rbp),%eax
and    $0xf,%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
mov    %eax,%eax
mov    %cl,-0x16(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
shr    $0x4,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    112d <main+0x1d>
lea    -0x16(%rbp),%rsi
lea    0xe71(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movw   $0x6462,0xe(%rsp)
movb   $0xd3,0x10(%rsp)
lea    0xed9(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
store i32 0, i32* %1
store i32 987, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %25, %0
%6 = load i32, i32* %2
%7 = urem i32 %6, 16
%8 = icmp ugt i32 %7, 9
br i1 %8, label %9, label %14
9: ; preds = %5
%10 = load i32, i32* %2
%11 = urem i32 %10, 16
%12 = sub i32 %11, 10
%13 = add i32 %12, 97
br label %18
14: ; preds = %5
%15 = load i32, i32* %2
%16 = urem i32 %15, 16
%17 = sub i32 %16, 48
br label %18
18: ; preds = %14, %9
%19 = phi i32 [ %13, %9 ], [ %17, %14 ]
%20 = trunc i32 %19 to i8
%21 = load i32, i32* %3
%22 = add i32 %21, 1
store i32 %22, i32* %3
%23 = zext i32 %21 to i64
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %23
store i8 %20, i8* %24
br label %25
25: ; preds = %18
%26 = load i32, i32* %2
%27 = udiv i32 %26, 16
store i32 %27, i32* %2
%28 = icmp ne i32 %27, 0
br i1 %28, label %5, label %29
29: ; preds = %25
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %30)
%32 = load i32, i32* %1
ret i32 %32
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
store i8 98, i8* %2
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 1
store i8 100, i8* %3
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 2
store i8 -45, i8* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}