#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 my_abs(int);
int /*<<< orphan*/ my_putchar(char);
int my_putnbr(int nombre, int base) {
  int flag = 0;
  char base16[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                     '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  char base_16[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
                      '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  if (nombre >= my_abs(base)) {
    my_putnbr(nombre / my_abs(base), base);
  }
  if (base < 0) {
    my_putchar(base_16[nombre % my_abs(base)]);
  } else {
    my_putchar(base16[nombre % my_abs(base)]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<my_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jl     11ac <my_putnbr+0x7c>
mov    -0x4(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%esi
call   1050 <my_putnbr@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11de <my_putnbr+0xae>
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1040 <my_putchar@plt>
jmp    1201 <my_putnbr+0xd1>
mov    -0x4(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
cltd
idiv   %ecx
movslq %edx,%rax
movsbl -0x20(%rbp,%rax,1),%edi
call   1040 <my_putchar@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
mov    %esi,%edi
call   1030 <my_abs@plt>
cmp    %ebp,%eax
jg     1159 <my_putnbr+0x29>
mov    %ebx,%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %eax,%edi
mov    %ebx,%esi
call   1050 <my_putnbr@plt>
mov    %ebx,%edi
call   1030 <my_abs@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
test   %ebx,%ebx
movslq %edx,%rax
lea    0xe9d(%rip),%rcx
lea    0xe86(%rip),%rdx
cmovs  %rcx,%rdx
movsbl (%rdx,%rax,1),%edi
call   1040 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.my_putnbr.base16 = [16 x i8] c"0123456789abcdef"
@__const.my_putnbr.base_16 = [16 x i8] c"0123456789ABCDEF"
define i32 @my_putnbr(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [16 x i8]
%7 = alloca [16 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %5
%8 = bitcast [16 x i8]* %6 to i8*
%9 = bitcast [16 x i8]* %7 to i8*
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 @my_abs(i32 %11)
%13 = icmp sge i32 %10, %12
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @my_abs(i32 %16)
%18 = sdiv i32 %15, %17
%19 = load i32, i32* %4
%20 = call i32 @my_putnbr(i32 %18, i32 %19)
br label %21
21: ; preds = %14, %2
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %21
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = call i32 @my_abs(i32 %26)
%28 = srem i32 %25, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = call i32 @my_putchar(i8 signext %31)
br label %42
33: ; preds = %21
%34 = load i32, i32* %3
%35 = load i32, i32* %4
%36 = call i32 @my_abs(i32 %35)
%37 = srem i32 %34, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @my_putchar(i8 signext %40)
br label %42
42: ; preds = %33, %24
ret i32 0
}

LLVM IR (-O2):
@__const.my_putnbr.base16 = [16 x i8] c"0123456789abcdef"
@__const.my_putnbr.base_16 = [16 x i8] c"0123456789ABCDEF"
define i32 @my_putnbr(i32 %0, i32 %1) {
%3 = tail call i32 @my_abs(i32 %1)
%4 = icmp sgt i32 %3, %0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @my_abs(i32 %1)
%7 = sdiv i32 %0, %6
%8 = tail call i32 @my_putnbr(i32 %7, i32 %1)
br label %9
9: ; preds = %5, %2
%10 = icmp slt i32 %1, 0
%11 = tail call i32 @my_abs(i32 %1)
%12 = srem i32 %0, %11
%13 = sext i32 %12 to i64
%14 = select i1 %10, [16 x i8]* @__const.my_putnbr.base_16, [16 x i8]* @__const.my_putnbr.base16
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %14, i64 0, i64 %13
%16 = load i8, i8* %15
%17 = tail call i32 @my_putchar(i8 signext %16)
ret i32 0
}