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


x86 assembly (clang, -O0):
<my_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    115a <my_putnbr_base+0x2a>
mov    $0x2d,%edi
call   1050 <my_putchar@plt>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     119b <my_putnbr_base+0x6b>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
call   1040 <my_putnbr_base@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
movslq %edx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <my_putchar@plt>
mov    $0x1,%eax
add    $0x30,%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
jns    1148 <my_putnbr_base+0x18>
mov    $0x2d,%edi
call   1050 <my_putchar@plt>
neg    %ebp
mov    %rbx,%rdi
call   1030 <my_strlen@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jl     1170 <my_putnbr_base+0x40>
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
call   1050 <my_putchar@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @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 = call i32 @my_putchar(i8 signext 45)
%9 = load i32, i32* %3
%10 = mul nsw i32 %9, -1
store i32 %10, i32* %3
br label %11
11: ; preds = %7, %2
%12 = load i32, i32* %3
%13 = load i8*, i8** %4
%14 = call i32 @my_strlen(i8* %13)
%15 = sub nsw i32 %14, 1
%16 = icmp sge i32 %12, %15
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i32, i32* %3
%19 = load i8*, i8** %4
%20 = call i32 @my_strlen(i8* %19)
%21 = sdiv i32 %18, %20
%22 = load i8*, i8** %4
%23 = call i32 @my_putnbr_base(i32 %21, i8* %22)
br label %24
24: ; preds = %17, %11
%25 = load i8*, i8** %4
%26 = load i32, i32* %3
%27 = load i8*, i8** %4
%28 = call i32 @my_strlen(i8* %27)
%29 = srem i32 %26, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %25, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @my_putchar(i8 signext %32)
ret i32 1
}

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