#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 libc_write(int, char *, size_t);
void writeLongcard(long unsigned int l) {
  char ch;
  int i;
  if (l > 16) {
    writeLongcard(l / 16);
    writeLongcard(l % 16);
  } else if (l < 10) {
    ch = ((char)(((unsigned int)('0')) + ((unsigned int)(l))));
    i = libc_write(1, &ch, (size_t)1);
  } else if (l < 16) {
    ch = ((char)((((unsigned int)('a')) + ((unsigned int)(l))) - 10));
    i = libc_write(1, &ch, (size_t)1);
  }
}


x86 assembly (clang, -O0):
<writeLongcard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x10,-0x8(%rbp)
jbe    1156 <writeLongcard+0x36>
mov    -0x8(%rbp),%rdi
shr    $0x4,%rdi
call   1040 <writeLongcard@plt>
mov    -0x8(%rbp),%rdi
and    $0xf,%rdi
call   1040 <writeLongcard@plt>
jmp    11be <writeLongcard+0x9e>
cmpq   $0xa,-0x8(%rbp)
jae    1186 <writeLongcard+0x66>
mov    -0x8(%rbp),%rax
add    $0x30,%eax
mov    %al,-0x9(%rbp)
mov    $0x1,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <libc_write@plt>
mov    %eax,-0x10(%rbp)
jmp    11b9 <writeLongcard+0x99>
cmpq   $0x10,-0x8(%rbp)
jae    11b4 <writeLongcard+0x94>
mov    -0x8(%rbp),%rax
add    $0x61,%eax
sub    $0xa,%eax
mov    %al,-0x9(%rbp)
mov    $0x1,%edi
lea    -0x9(%rbp),%rsi
mov    $0x1,%edx
call   1030 <libc_write@plt>
mov    %eax,-0x10(%rbp)
jmp    11b9 <writeLongcard+0x99>
jmp    11be <writeLongcard+0x9e>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeLongcard>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cmp    $0x11,%rdi
jb     114a <writeLongcard+0x2a>
mov    %rbx,%rdi
shr    $0x4,%rdi
call   1040 <writeLongcard@plt>
and    $0xf,%ebx
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1040 <writeLongcard@plt>
cmp    $0x9,%rbx
ja     1155 <writeLongcard+0x35>
add    $0x30,%bl
jmp    115e <writeLongcard+0x3e>
cmp    $0xf,%rbx
ja     1176 <writeLongcard+0x56>
add    $0x57,%bl
mov    %bl,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
mov    $0x1,%edi
call   1030 <libc_write@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @writeLongcard(i64 %0) {
%2 = alloca i64
%3 = alloca i8
%4 = alloca i32
store i64 %0, i64* %2
%5 = load i64, i64* %2
%6 = icmp ugt i64 %5, 16
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i64, i64* %2
%9 = udiv i64 %8, 16
%10 = load i64, i64* %2
%11 = urem i64 %10, 16
br label %33
12: ; preds = %1
%13 = load i64, i64* %2
%14 = icmp ult i64 %13, 10
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i64, i64* %2
%17 = trunc i64 %16 to i32
%18 = add i32 48, %17
%19 = trunc i32 %18 to i8
store i8 %19, i8* %3
%20 = call i32 @libc_write(i32 1, i8* %3, i64 1)
store i32 %20, i32* %4
br label %32
21: ; preds = %12
%22 = load i64, i64* %2
%23 = icmp ult i64 %22, 16
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i64, i64* %2
%26 = trunc i64 %25 to i32
%27 = add i32 97, %26
%28 = sub i32 %27, 10
%29 = trunc i32 %28 to i8
store i8 %29, i8* %3
%30 = call i32 @libc_write(i32 1, i8* %3, i64 1)
store i32 %30, i32* %4
br label %31
31: ; preds = %24, %21
br label %32
32: ; preds = %31, %15
br label %33
33: ; preds = %32, %7
ret void
}

LLVM IR (-O2):
define void @writeLongcard(i64 %0) {
%2 = alloca i8
%3 = icmp ugt i64 %0, 16
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = lshr i64 %0, 4
tail call void @writeLongcard(i64 %5)
%6 = and i64 %0, 15
tail call void @writeLongcard(i64 %6)
br label %19
7: ; preds = %1
%8 = icmp ult i64 %0, 10
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = trunc i64 %0 to i8
%11 = add nuw nsw i8 %10, 48
store i8 %11, i8* %2
%12 = call i32 @libc_write(i32 1, i8* %2, i64 1)
br label %19
13: ; preds = %7
%14 = icmp ult i64 %0, 16
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = trunc i64 %0 to i8
%17 = add nuw nsw i8 %16, 87
store i8 %17, i8* %2
%18 = call i32 @libc_write(i32 1, i8* %2, i64 1)
br label %19
19: ; preds = %9, %15, %13, %4
ret void
}