#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(int);
void my_put_nbr(int nb) {
  if (nb < 0) {
    my_putchar('-');
    my_put_nbr((nb / 10) * -1);
    my_putchar(((nb % 10) * -1) + '0');
  } else {
    if (nb >= 10)
      my_put_nbr(nb / 10);
    my_putchar((nb % 10) + '0');
  }
}


x86 assembly (clang, -O0):
<my_put_nbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    116d <my_put_nbr+0x4d>
mov    $0x2d,%edi
call   1040 <my_putchar@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xffffffff,%eax,%edi
call   1030 <my_put_nbr@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xffffffff,%edx,%edi
add    $0x30,%edi
call   1040 <my_putchar@plt>
jmp    119e <my_put_nbr+0x7e>
cmpl   $0xa,-0x4(%rbp)
jl     1189 <my_put_nbr+0x69>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <my_put_nbr@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1040 <my_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_nbr>:
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
js     112e <my_put_nbr+0xe>
cmp    $0x9,%ebx
ja     113a <my_put_nbr+0x1a>
jmp    114e <my_put_nbr+0x2e>
mov    $0x2d,%edi
call   1040 <my_putchar@plt>
neg    %ebx
mov    %ebx,%eax
mov    $0xcccccccd,%edi
imul   %rax,%rdi
shr    $0x23,%rdi
call   1030 <my_put_nbr@plt>
mov    %ebx,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
pop    %rbx
jmp    1040 <my_putchar@plt>

LLVM IR (-O0):
define void @my_put_nbr(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = call i32 @my_putchar(i32 45)
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 10
%9 = mul nsw i32 %8, -1
%10 = load i32, i32* %2
%11 = srem i32 %10, 10
%12 = mul nsw i32 %11, -1
%13 = add nsw i32 %12, 48
%14 = call i32 @my_putchar(i32 %13)
br label %26
15: ; preds = %1
%16 = load i32, i32* %2
%17 = icmp sge i32 %16, 10
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
br label %21
21: ; preds = %18, %15
%22 = load i32, i32* %2
%23 = srem i32 %22, 10
%24 = add nsw i32 %23, 48
%25 = call i32 @my_putchar(i32 %24)
br label %26
26: ; preds = %21, %5
ret void
}

LLVM IR (-O2):
define void @my_put_nbr(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %11, label %14
3: ; preds = %14, %11
%4 = phi i32 [ %13, %11 ], [ %0, %14 ]
%5 = udiv i32 %4, 10
tail call void @my_put_nbr(i32 %5)
br label %6
6: ; preds = %3, %14
%7 = phi i32 [ %0, %14 ], [ %4, %3 ]
%8 = urem i32 %7, 10
%9 = or i32 %8, 48
%10 = tail call i32 @my_putchar(i32 %9)
ret void
11: ; preds = %1
%12 = tail call i32 @my_putchar(i32 45)
%13 = sub i32 0, %0
br label %3
14: ; preds = %1
%15 = icmp ugt i32 %0, 9
br i1 %15, label %3, label %6
}