#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_strlen(char *);
void my_putnbr_base(int nbr, char *base) {
  if (nbr < 0) {
    nbr = -nbr;
    my_putchar('-');
  }
  if (nbr != 0) {
    my_putnbr_base((nbr / my_strlen(base)), base);
    my_putchar(base[(nbr % my_strlen(base))]);
  }
}


x86 assembly (clang, -O0):
<my_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115b <my_putnbr_base+0x2b>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    $0x2d,%edi
call   1050 <my_putchar@plt>
cmpl   $0x0,-0x4(%rbp)
je     11b6 <my_putnbr_base+0x86>
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <my_putnbr_base@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <my_putchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr_base>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
test   %edi,%edi
js     1145 <my_putnbr_base+0x15>
jne    1151 <my_putnbr_base+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
neg    %ebp
mov    $0x2d,%edi
call   1050 <my_putchar@plt>
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <my_putnbr_base@plt>
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
movsbl (%rbx,%rdx,1),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <my_putchar@plt>

LLVM IR (-O0):
define void @my_putnbr_base(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* %3
%9 = sub nsw i32 0, %8
store i32 %9, i32* %3
%10 = call i32 @my_putchar(i8 signext 45)
br label %11
11: ; preds = %7, %2
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %11
%15 = load i32, i32* %3
%16 = load i8*, i8** %4
%17 = call i32 @my_strlen(i8* %16)
%18 = sdiv i32 %15, %17
%19 = load i8*, i8** %4
%20 = load i8*, i8** %4
%21 = load i32, i32* %3
%22 = load i8*, i8** %4
%23 = call i32 @my_strlen(i8* %22)
%24 = srem i32 %21, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %20, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @my_putchar(i8 signext %27)
br label %29
29: ; preds = %14, %11
ret void
}

LLVM IR (-O2):
define void @my_putnbr_base(i32 %0, i8* %1) {
%3 = icmp slt i32 %0, 0
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = sub nsw i32 0, %0
%6 = tail call i32 @my_putchar(i8 signext 45)
br label %10
7: ; preds = %2
%8 = icmp eq i32 %0, 0
br i1 %8, label %9, label %10
9: ; preds = %7, %10
ret void
10: ; preds = %4, %7
%11 = phi i32 [ %5, %4 ], [ %0, %7 ]
%12 = tail call i32 @my_strlen(i8* %1)
%13 = sdiv i32 %11, %12
tail call void @my_putnbr_base(i32 %13, i8* %1)
%14 = tail call i32 @my_strlen(i8* %1)
%15 = srem i32 %11, %14
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = load i8, i8* %17
%19 = tail call i32 @my_putchar(i8 signext %18)
br label %9
}