#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);
void conversion(int colour) {
  char hex[7];
  int checker, i, k;
  i = k = 0;
  if (colour == 0) {
    for (i = 0; i < 2; i++)
      hex[i] = '0';
  } else
    while (colour != 0) {
      checker = colour % 16;
      if (checker < 10)
        checker = checker + '0';
      else
        checker = checker + 87;
      hex[i] = checker;
      colour = colour / 16;
      i++;
    }
  for (k = i - 1; k >= 0; k--)
    printf("%c", hex[k]);
}


x86 assembly (clang, -O0):
<conversion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1160 <conversion+0x50>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    115b <conversion+0x4b>
movslq -0x14(%rbp),%rax
movb   $0x30,-0xb(%rbp,%rax,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113a <conversion+0x2a>
jmp    11cc <conversion+0xbc>
jmp    1165 <conversion+0x55>
cmpl   $0x0,-0x4(%rbp)
je     11c7 <conversion+0xb7>
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1195 <conversion+0x85>
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    119e <conversion+0x8e>
mov    -0x10(%rbp),%eax
add    $0x57,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %al,%cl
movslq -0x14(%rbp),%rax
mov    %cl,-0xb(%rbp,%rax,1)
mov    -0x4(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <conversion+0x55>
jmp    11cc <conversion+0xbc>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1202 <conversion+0xf2>
movslq -0x18(%rbp),%rax
lea    0xe16(%rip),%rdi
movsbl -0xb(%rbp,%rax,1),%esi
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11d5 <conversion+0xc5>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conversion>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %edi,%edi
je     1159 <conversion+0x49>
xor    %eax,%eax
xchg   %ax,%ax
lea    0xf(%rdi),%ecx
test   %edi,%edi
mov    %edi,%edx
cmovs  %ecx,%edx
mov    %edx,%esi
and    $0xfffffff0,%esi
mov    %edi,%ebp
sub    %esi,%ebp
lea    0x30(%rbp),%ebx
neg    %esi
cmp    $0xa,%ebp
lea    0x57(%rdi,%rsi,1),%esi
cmovl  %ebx,%esi
mov    %sil,0x8(%rsp,%rax,1)
sar    $0x4,%edx
add    $0x1,%rax
mov    %edx,%edi
cmp    $0x1e,%ecx
ja     1120 <conversion+0x10>
mov    %eax,%eax
jmp    1165 <conversion+0x55>
movw   $0x3030,0x8(%rsp)
mov    $0x2,%eax
lea    0x1(%rax),%ebp
add    $0xffffffff,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x8,%rbx
lea    0xe86(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%ebp
jg     1180 <conversion+0x70>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
define void @conversion(i32 %0) {
%2 = alloca [7 x i8]
%3 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = bitcast [7 x i8]* %2 to i16*
store i16 12336, i16* %6
br label %22
7: ; preds = %1, %7
%8 = phi i64 [ %17, %7 ], [ 0, %1 ]
%9 = phi i32 [ %16, %7 ], [ %0, %1 ]
%10 = srem i32 %9, 16
%11 = icmp slt i32 %10, 10
%12 = select i1 %11, i32 48, i32 87
%13 = add nsw i32 %12, %10
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %8
store i8 %14, i8* %15
%16 = sdiv i32 %9, 16
%17 = add nuw i64 %8, 1
%18 = add i32 %9, 15
%19 = icmp ult i32 %18, 31
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = and i64 %17, 4294967295
br label %22
22: ; preds = %5, %20
%23 = phi i64 [ %21, %20 ], [ 2, %5 ]
br label %24
24: ; preds = %22, %24
%25 = phi i64 [ %26, %24 ], [ %23, %22 ]
%26 = add nsw i64 %25, -1
%27 = and i64 %26, 4294967295
%28 = getelementptr inbounds [7 x i8], [7 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %29)
%31 = trunc i64 %25 to i32
%32 = icmp sgt i32 %31, 1
br i1 %32, label %24, label %33
33: ; preds = %24
ret void
}