#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(long, char *, int /*<<< orphan*/);
int /*<<< orphan*/ my_putchar(char);
int /*<<< orphan*/ my_strlen(char *);
int my_putnbr_base(long nbr, char *base) {
  if (nbr == 0) {
    my_putchar('0');
    return (0);
  } else if (nbr < 0)
    my_putchar('-');
  my_printnbr(nbr, base, my_strlen(base));
  return (0);
}


x86 assembly (clang, -O0):
<my_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1161 <my_putnbr_base+0x31>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    11aa <my_putnbr_base+0x7a>
cmpq   $0x0,-0x10(%rbp)
jge    1176 <my_putnbr_base+0x46>
mov    $0x2d,%edi
call   1040 <my_putchar@plt>
jmp    117b <my_putnbr_base+0x4b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1050 <my_printnbr@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr_base>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1162 <my_putnbr_base+0x32>
mov    %rsi,%r14
mov    %rdi,%rbx
jns    114b <my_putnbr_base+0x1b>
mov    $0x2d,%edi
call   1040 <my_putchar@plt>
mov    %r14,%rdi
call   1030 <my_strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <my_printnbr@plt>
jmp    116c <my_putnbr_base+0x3c>
mov    $0x30,%edi
call   1040 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @my_putnbr_base(i64 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i8*
store i64 %0, i64* %4
store i8* %1, i8** %5
%6 = load i64, i64* %4
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @my_putchar(i8 signext 48)
store i32 0, i32* %3
br label %22
10: ; preds = %2
%11 = load i64, i64* %4
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @my_putchar(i8 signext 45)
br label %15
15: ; preds = %13, %10
br label %16
16: ; preds = %15
%17 = load i64, i64* %4
%18 = load i8*, i8** %5
%19 = load i8*, i8** %5
%20 = call i32 @my_strlen(i8* %19)
%21 = call i32 @my_printnbr(i64 %17, i8* %18, i32 %20)
store i32 0, i32* %3
br label %22
22: ; preds = %16, %8
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @my_putnbr_base(i64 %0, i8* %1) {
%3 = icmp eq i64 %0, 0
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @my_putchar(i8 signext 48)
br label %13
6: ; preds = %2
%7 = icmp slt i64 %0, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @my_putchar(i8 signext 45)
br label %10
10: ; preds = %6, %8
%11 = tail call i32 @my_strlen(i8* %1)
%12 = tail call i32 @my_printnbr(i64 %0, i8* %1, i32 %11)
br label %13
13: ; preds = %10, %4
ret i32 0
}