#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*/ my_putchar(char);
int my_put_long_int_base(long int li, int base, int capitalized) {
  if (li < 0) {
    my_putchar('-');
    my_put_long_int_base(li, base, capitalized);
  } else if (li >= base) {
    my_put_long_int_base(li / base, base, capitalized);
    my_put_long_int_base(li % base, base, capitalized);
  } else if (li <= 9) {
    my_putchar(li + '0');
  } else {
    my_putchar((capitalized == 1 ? 'A' : 'a') + li - 10);
  }
  return (0);
}


x86 assembly (clang, -O0):
<my_put_long_int_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jge    115b <my_put_long_int_base+0x3b>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <my_put_long_int_base@plt>
jmp    11f6 <my_put_long_int_base+0xd6>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jl     11a7 <my_put_long_int_base+0x87>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <my_put_long_int_base@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
mov    %rdx,%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <my_put_long_int_base@plt>
jmp    11f1 <my_put_long_int_base+0xd1>
cmpq   $0x9,-0x8(%rbp)
jg     11c7 <my_put_long_int_base+0xa7>
mov    -0x8(%rbp),%rax
add    $0x30,%rax
movsbl %al,%edi
call   1030 <my_putchar@plt>
jmp    11ec <my_put_long_int_base+0xcc>
mov    -0x10(%rbp),%edx
mov    $0x61,%eax
mov    $0x41,%ecx
cmp    $0x1,%edx
cmove  %ecx,%eax
cltq
add    -0x8(%rbp),%rax
sub    $0xa,%rax
movsbl %al,%edi
call   1030 <my_putchar@plt>
jmp    11f1 <my_put_long_int_base+0xd1>
jmp    11f6 <my_put_long_int_base+0xd6>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_long_int_base>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
js     117a <my_put_long_int_base+0x5a>
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
movslq %esi,%rbp
jmp    115e <my_put_long_int_base+0x3e>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
cqto
idiv   %rbp
mov    %rdx,%rbx
mov    %rax,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1040 <my_put_long_int_base@plt>
test   %rbx,%rbx
js     117a <my_put_long_int_base+0x5a>
cmp    %rbp,%rbx
jl     119c <my_put_long_int_base+0x7c>
mov    %rbx,%rax
or     %rbp,%rax
shr    $0x20,%rax
jne    1140 <my_put_long_int_base+0x20>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
mov    %edx,%ebx
jmp    114b <my_put_long_int_base+0x2b>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
jmp    1190 <my_put_long_int_base+0x70>
xor    %eax,%eax
cmp    $0x1,%r14d
setne  %al
shl    $0x5,%eax
or     $0x41,%eax
xor    %ecx,%ecx
cmp    $0xa,%rbx
cmovb  %ecx,%eax
mov    $0x30,%ecx
mov    $0xf6,%edx
cmovb  %ecx,%edx
add    %eax,%ebx
add    %dl,%bl
movsbl %bl,%edi
call   1030 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_put_long_int_base(i64 %0, i32 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i64, i64* %4
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %3
%10 = call i32 @my_putchar(i8 signext 45)
%11 = load i64, i64* %4
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @my_put_long_int_base(i64 %11, i32 %12, i32 %13)
br label %56
15: ; preds = %3
%16 = load i64, i64* %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = icmp sge i64 %16, %18
br i1 %19, label %20, label %35
20: ; preds = %15
%21 = load i64, i64* %4
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = sdiv i64 %21, %23
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 @my_put_long_int_base(i64 %24, i32 %25, i32 %26)
%28 = load i64, i64* %4
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = srem i64 %28, %30
%32 = load i32, i32* %5
%33 = load i32, i32* %6
%34 = call i32 @my_put_long_int_base(i64 %31, i32 %32, i32 %33)
br label %55
35: ; preds = %15
%36 = load i64, i64* %4
%37 = icmp sle i64 %36, 9
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i64, i64* %4
%40 = add nsw i64 %39, 48
%41 = trunc i64 %40 to i8
%42 = call i32 @my_putchar(i8 signext %41)
br label %54
43: ; preds = %35
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 1
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 65, i32 97
%48 = sext i32 %47 to i64
%49 = load i64, i64* %4
%50 = add nsw i64 %48, %49
%51 = sub nsw i64 %50, 10
%52 = trunc i64 %51 to i8
%53 = call i32 @my_putchar(i8 signext %52)
br label %54
54: ; preds = %43, %38
br label %55
55: ; preds = %54, %20
br label %56
56: ; preds = %55, %9
ret i32 0
}

LLVM IR (-O2):
define i32 @my_put_long_int_base(i64 %0, i32 %1, i32 %2) {
%4 = sext i32 %1 to i64
%5 = icmp slt i64 %0, 0
br i1 %5, label %6, label %10
6: ; preds = %13, %3
%7 = tail call i32 @my_putchar(i8 signext 45)
br label %8
8: ; preds = %8, %6
%9 = tail call i32 @my_putchar(i8 signext 45)
br label %8
10: ; preds = %3, %13
%11 = phi i64 [ %16, %13 ], [ %0, %3 ]
%12 = icmp slt i64 %11, %4
br i1 %12, label %18, label %13
13: ; preds = %10
%14 = sdiv i64 %11, %4
%15 = tail call i32 @my_put_long_int_base(i64 %14, i32 %1, i32 %2)
%16 = srem i64 %11, %4
%17 = icmp slt i64 %16, 0
br i1 %17, label %6, label %10
18: ; preds = %10
%19 = icmp ult i64 %11, 10
%20 = icmp eq i32 %2, 1
%21 = select i1 %20, i64 65, i64 97
%22 = select i1 %19, i64 0, i64 %21
%23 = add nuw nsw i64 %11, %22
%24 = select i1 %19, i8 48, i8 -10
%25 = trunc i64 %23 to i8
%26 = add i8 %24, %25
%27 = tail call i32 @my_putchar(i8 signext %26)
ret i32 0
}