#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(unsigned int);
int /*<<< orphan*/ write(int, char *, int);
void my_putnbr(int nbr) {
  unsigned int u_nbr;
  if (nbr < 0) {
    u_nbr = nbr * -1;
    write(1, "-", 1);
  } else
    u_nbr = nbr;
  if (u_nbr > 9)
    my_putnbr(u_nbr / 10);
  my_putchar(u_nbr % 10 + '0');
}


x86 assembly (clang, -O0):
<my_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1164 <my_putnbr+0x34>
imul   $0xffffffff,-0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x1,%edx
lea    0xea8(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
jmp    116a <my_putnbr+0x3a>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x9,-0x8(%rbp)
jbe    1187 <my_putnbr+0x57>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%edi
call   1050 <my_putnbr@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1040 <my_putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_putnbr>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
test   %edi,%edi
jns    1152 <my_putnbr+0x22>
neg    %ebx
lea    0xebd(%rip),%rsi
mov    $0x1,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebx,%r14d
cmp    $0xa,%ebx
jb     116c <my_putnbr+0x3c>
mov    $0xcccccccd,%edi
imul   %r14,%rdi
shr    $0x23,%rdi
call   1050 <my_putnbr@plt>
mov    $0xcccccccd,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <my_putchar@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
define void @my_putnbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = mul nsw i32 %7, -1
store i32 %8, i32* %3
%9 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %12
10: ; preds = %1
%11 = load i32, i32* %2
store i32 %11, i32* %3
br label %12
12: ; preds = %10, %6
%13 = load i32, i32* %3
%14 = icmp ugt i32 %13, 9
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* %3
%17 = udiv i32 %16, 10
br label %18
18: ; preds = %15, %12
%19 = load i32, i32* %3
%20 = urem i32 %19, 10
%21 = add i32 %20, 48
%22 = call i32 @my_putchar(i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
define void @my_putnbr(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = sub nsw i32 0, %0
%5 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
br label %6
6: ; preds = %1, %3
%7 = phi i32 [ %4, %3 ], [ %0, %1 ]
%8 = icmp ugt i32 %7, 9
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = udiv i32 %7, 10
tail call void @my_putnbr(i32 %10)
br label %11
11: ; preds = %9, %6
%12 = urem i32 %7, 10
%13 = or i32 %12, 48
%14 = tail call i32 @my_putchar(i32 %13)
ret void
}