#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_printnbr(unsigned long, char *, int);
int /*<<< orphan*/ my_putchar(char);
int my_printunbr(unsigned long nb, char *base, int bs) {
  if (nb > -bs && nb < bs) {
    (nb < 0) ? my_putchar(base[-1 * nb]) : my_putchar(base[nb]);
    return (0);
  }
  my_printnbr(nb / bs, base, bs);
  (nb < 0) ? my_putchar(base[-(nb % bs)]) : my_putchar(base[nb % bs]);
  return (0);
}


x86 assembly (clang, -O0):
<my_printunbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jbe    1198 <my_printunbr+0x78>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmp    %rcx,%rax
jae    1198 <my_printunbr+0x78>
cmpq   $0x0,-0x10(%rbp)
jae    117b <my_printunbr+0x5b>
mov    -0x18(%rbp),%rax
imul   $0xffffffffffffffff,-0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
jmp    118c <my_printunbr+0x6c>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    1214 <my_printunbr+0xf4>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <my_printnbr@plt>
cmpq   $0x0,-0x10(%rbp)
jae    11eb <my_printunbr+0xcb>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    -0x28(%rbp),%rax
xor    %ecx,%ecx
sub    %rdx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <my_putchar@plt>
jmp    120d <my_printunbr+0xed>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    -0x30(%rbp),%rax
movsbl (%rax,%rdx,1),%edi
call   1030 <my_putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_printunbr>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ecx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%eax
neg    %eax
cltq
movslq %edx,%rsi
cmp    %rdi,%rax
jae    113f <my_printunbr+0x1f>
cmp    %rbx,%rsi
ja     116d <my_printunbr+0x4d>
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1158 <my_printunbr+0x38>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
mov    %rdx,%rbx
jmp    1160 <my_printunbr+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %ecx,%edx
call   1040 <my_printnbr@plt>
movsbl (%r14,%rbx,1),%edi
call   1030 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @my_printunbr(i64 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
store i64 %0, i64* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i64, i64* %5
%9 = load i32, i32* %7
%10 = sub nsw i32 0, %9
%11 = sext i32 %10 to i64
%12 = icmp ugt i64 %8, %11
br i1 %12, label %13, label %36
13: ; preds = %3
%14 = load i64, i64* %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = icmp ult i64 %14, %16
br i1 %17, label %18, label %36
18: ; preds = %13
%19 = load i64, i64* %5
%20 = icmp ult i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = load i64, i64* %5
%24 = mul i64 -1, %23
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = call i32 @my_putchar(i8 signext %26)
br label %34
28: ; preds = %18
%29 = load i8*, i8** %6
%30 = load i64, i64* %5
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @my_putchar(i8 signext %32)
br label %34
34: ; preds = %28, %21
%35 = phi i32 [ %27, %21 ], [ %33, %28 ]
store i32 0, i32* %4
br label %67
36: ; preds = %13, %3
%37 = load i64, i64* %5
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = udiv i64 %37, %39
%41 = load i8*, i8** %6
%42 = load i32, i32* %7
%43 = call i32 @my_printnbr(i64 %40, i8* %41, i32 %42)
%44 = load i64, i64* %5
%45 = icmp ult i64 %44, 0
br i1 %45, label %46, label %56
46: ; preds = %36
%47 = load i8*, i8** %6
%48 = load i64, i64* %5
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = urem i64 %48, %50
%52 = sub i64 0, %51
%53 = getelementptr inbounds i8, i8* %47, i64 %52
%54 = load i8, i8* %53
%55 = call i32 @my_putchar(i8 signext %54)
br label %65
56: ; preds = %36
%57 = load i8*, i8** %6
%58 = load i64, i64* %5
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = urem i64 %58, %60
%62 = getelementptr inbounds i8, i8* %57, i64 %61
%63 = load i8, i8* %62
%64 = call i32 @my_putchar(i8 signext %63)
br label %65
65: ; preds = %56, %46
%66 = phi i32 [ %55, %46 ], [ %64, %56 ]
store i32 0, i32* %4
br label %67
67: ; preds = %65, %34
%68 = load i32, i32* %4
ret i32 %68
}

LLVM IR (-O2):
define i32 @my_printunbr(i64 %0, i8* %1, i32 %2) {
%4 = sub nsw i32 0, %2
%5 = sext i32 %4 to i64
%6 = icmp ult i64 %5, %0
%7 = sext i32 %2 to i64
%8 = icmp ugt i64 %7, %0
%9 = and i1 %6, %8
br i1 %9, label %14, label %10
10: ; preds = %3
%11 = udiv i64 %0, %7
%12 = tail call i32 @my_printnbr(i64 %11, i8* %1, i32 %2)
%13 = urem i64 %0, %7
br label %14
14: ; preds = %3, %10
%15 = phi i64 [ %13, %10 ], [ %0, %3 ]
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = tail call i32 @my_putchar(i8 signext %17)
ret i32 0
}