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


x86 assembly (clang, -O0):
<my_put_nbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1142 <my_put_nbr+0x32>
mov    $0x30,%edi
call   1030 <my_putchar@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e3 <my_put_nbr+0xd3>
cmpl   $0x0,-0x8(%rbp)
jge    115d <my_put_nbr+0x4d>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1187 <my_put_nbr+0x77>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    1163 <my_put_nbr+0x53>
jmp    118c <my_put_nbr+0x7c>
cmpl   $0x1,-0xc(%rbp)
jle    11e3 <my_put_nbr+0xd3>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <my_putchar@plt>
mov    -0x10(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x10(%rbp)
jmp    118c <my_put_nbr+0x7c>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_nbr>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
je     1186 <my_put_nbr+0x76>
mov    %edi,%r15d
jns    112d <my_put_nbr+0x1d>
neg    %r15d
mov    $0x2d,%edi
call   1030 <my_putchar@plt>
mov    $0x1,%ebx
mov    $0xcccccccd,%eax
mov    %r15d,%ecx
nopw   0x0(%rax,%rax,1)
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
cmp    $0x9,%ecx
mov    %edx,%ecx
ja     1140 <my_put_nbr+0x30>
mov    $0xcccccccd,%r14d
nopl   0x0(%rax)
mov    %r15d,%eax
cltd
idiv   %ebx
mov    %edx,%eax
mov    %ebx,%ebp
imul   %r14,%rbp
shr    $0x23,%rbp
cltd
idiv   %ebp
lea    0x30(%rax),%edi
call   1030 <my_putchar@plt>
cmp    $0x13,%ebx
mov    %ebp,%ebx
ja     1160 <my_put_nbr+0x50>
jmp    1190 <my_put_nbr+0x80>
mov    $0x30,%edi
call   1030 <my_putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @my_put_nbr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @my_putchar(i32 48)
store i32 0, i32* %2
br label %46
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, -1
store i32 %15, i32* %3
%16 = call i32 @my_putchar(i32 45)
br label %17
17: ; preds = %13, %10
%18 = load i32, i32* %3
store i32 %18, i32* %5
br label %19
19: ; preds = %22, %17
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %4
%24 = mul nsw i32 %23, 10
store i32 %24, i32* %4
%25 = load i32, i32* %5
%26 = sdiv i32 %25, 10
store i32 %26, i32* %5
br label %19
27: ; preds = %19
br label %28
28: ; preds = %31, %27
%29 = load i32, i32* %4
%30 = icmp sgt i32 %29, 1
br i1 %30, label %31, label %46
31: ; preds = %28
%32 = load i32, i32* %3
%33 = load i32, i32* %4
%34 = srem i32 %32, %33
%35 = load i32, i32* %4
%36 = sdiv i32 %35, 10
%37 = sdiv i32 %34, %36
store i32 %37, i32* %5
%38 = load i32, i32* %4
%39 = sdiv i32 %38, 10
store i32 %39, i32* %4
%40 = load i32, i32* %5
%41 = add nsw i32 %40, 48
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = call i32 @my_putchar(i32 %42)
%44 = load i32, i32* %5
%45 = sub nsw i32 %44, 48
store i32 %45, i32* %5
br label %28
46: ; preds = %8, %28
%47 = load i32, i32* %2
ret i32 %47
}

LLVM IR (-O2):
define i32 @my_put_nbr(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @my_putchar(i32 48)
br label %26
5: ; preds = %1
%6 = icmp slt i32 %0, 0
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = sub nsw i32 0, %0
%9 = tail call i32 @my_putchar(i32 45)
br label %10
10: ; preds = %5, %7
%11 = phi i32 [ %8, %7 ], [ %0, %5 ]
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %16, %12 ], [ %11, %10 ]
%14 = phi i32 [ %15, %12 ], [ 1, %10 ]
%15 = mul nsw i32 %14, 10
%16 = udiv i32 %13, 10
%17 = icmp ult i32 %13, 10
br i1 %17, label %18, label %12
18: ; preds = %12, %18
%19 = phi i32 [ %21, %18 ], [ %15, %12 ]
%20 = srem i32 %11, %19
%21 = udiv i32 %19, 10
%22 = sdiv i32 %20, %21
%23 = add nsw i32 %22, 48
%24 = tail call i32 @my_putchar(i32 %23)
%25 = icmp ugt i32 %19, 19
br i1 %25, label %18, label %26
26: ; preds = %18, %3
ret i32 0
}