#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 */
typedef int /*<<< orphan*/ tab;

/* Variables and functions */
int /*<<< orphan*/ print(char *, int);
void printlbase(unsigned long l, int base, unsigned char flags) {
  static char tab[32] = "0123456789abcdef0123456789ABCDEF";
  if (l / base != 0)
    printlbase(l / base, base, flags);
  if (flags & 0x01) {
    print(&tab[(l % base) + 16], sizeof(tab[l % base]));
  } else {
    print(&tab[l % base], sizeof(tab[l % base]));
  }
}


x86 assembly (clang, -O0):
<printlbase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rax
je     1167 <printlbase+0x47>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
movzbl -0xd(%rbp),%edx
call   1040 <printlbase@plt>
movzbl -0xd(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a1 <printlbase+0x81>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
add    $0x10,%rdx
lea    0x2eb1(%rip),%rdi
add    %rdx,%rdi
mov    $0x1,%esi
call   1030 <print@plt>
jmp    11c2 <printlbase+0xa2>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
xor    %edx,%edx
div    %rcx
lea    0x2e8b(%rip),%rdi
add    %rdx,%rdi
mov    $0x1,%esi
call   1030 <print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printlbase>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
movslq %esi,%rbp
cmp    %rdi,%rbp
ja     1164 <printlbase+0x44>
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     114e <printlbase+0x2e>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
jmp    1155 <printlbase+0x35>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
movzbl %r14b,%edx
mov    %rax,%rdi
mov    %r15d,%esi
call   1040 <printlbase@plt>
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
je     117a <printlbase+0x5a>
mov    %rbx,%rax
xor    %edx,%edx
div    %rbp
jmp    1181 <printlbase+0x61>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
lea    0x10(%rdx),%rax
test   $0x1,%r14b
cmove  %rdx,%rax
lea    0x2eac(%rip),%rdi
add    %rax,%rdi
mov    $0x1,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <print@plt>

LLVM IR (-O0):
@printlbase.tab = internal global [32 x i8] c"0123456789abcdef0123456789ABCDEF"
define void @printlbase(i64 %0, i32 %1, i8 zeroext %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8
store i64 %0, i64* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
%7 = load i64, i64* %4
%8 = load i32, i32* %5
%9 = sext i32 %8 to i64
%10 = udiv i64 %7, %9
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i64, i64* %4
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = udiv i64 %13, %15
%17 = load i32, i32* %5
%18 = load i8, i8* %6
br label %19
19: ; preds = %12, %3
%20 = load i8, i8* %6
%21 = zext i8 %20 to i32
%22 = and i32 %21, 1
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %19
%25 = load i64, i64* %4
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = urem i64 %25, %27
%29 = add i64 %28, 16
%30 = getelementptr inbounds [32 x i8], [32 x i8]* @printlbase.tab, i64 0, i64 %29
%31 = call i32 @print(i8* %30, i32 1)
br label %39
32: ; preds = %19
%33 = load i64, i64* %4
%34 = load i32, i32* %5
%35 = sext i32 %34 to i64
%36 = urem i64 %33, %35
%37 = getelementptr inbounds [32 x i8], [32 x i8]* @printlbase.tab, i64 0, i64 %36
%38 = call i32 @print(i8* %37, i32 1)
br label %39
39: ; preds = %32, %24
ret void
}

LLVM IR (-O2):
@printlbase.tab = internal global [32 x i8] c"0123456789abcdef0123456789ABCDEF"
define void @printlbase(i64 %0, i32 %1, i8 zeroext %2) {
%4 = sext i32 %1 to i64
%5 = icmp ugt i64 %4, %0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = udiv i64 %0, %4
tail call void @printlbase(i64 %7, i32 %1, i8 zeroext %2)
br label %8
8: ; preds = %6, %3
%9 = and i8 %2, 1
%10 = icmp eq i8 %9, 0
%11 = urem i64 %0, %4
%12 = add i64 %11, 16
%13 = select i1 %10, i64 %11, i64 %12
%14 = getelementptr inbounds [32 x i8], [32 x i8]* @printlbase.tab, i64 0, i64 %13
%15 = tail call i32 @print(i8* %14, i32 1)
ret void
}