#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 /*<<< orphan*/ my_putnbr_base_l(int, char *, int);
int my_putnbr_base(int nbr, char *base) {
  int l;
  l = 0;
  while (base[l] != '\0') {
    l = l + 1;
  }
  if (nbr < 0) {
    my_putchar('-');
  } else {
    nbr = -nbr;
  }
  my_putnbr_base_l(nbr, base, l);
  return (nbr);
}


x86 assembly (clang, -O0):
<my_putnbr_base>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1159 <my_putnbr_base+0x39>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1136 <my_putnbr_base+0x16>
cmpl   $0x0,-0x4(%rbp)
jge    1172 <my_putnbr_base+0x52>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
jmp    117a <my_putnbr_base+0x5a>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <my_putnbr_base_l@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr_base>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
xor    %ebp,%ebp
nopl   0x0(%rax)
cmpb   $0x0,(%rbx,%rbp,1)
lea    0x1(%rbp),%rbp
jne    1130 <my_putnbr_base+0x10>
test   %r14d,%r14d
js     1144 <my_putnbr_base+0x24>
neg    %r14d
jmp    114e <my_putnbr_base+0x2e>
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
add    $0xffffffff,%ebp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <my_putnbr_base_l@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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