#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 */
long LONG_MAX;
long LONG_MIN;
int /*<<< orphan*/ pprint(char const *, int);
int p_putnbr(long nb, int fd) {
  if (nb >= LONG_MAX || nb <= LONG_MIN)
    return (84);
  if (nb < 0) {
    pprint("-", fd);
    p_putnbr(nb * -1, fd);
  }
  if (nb >= 0 && nb <= 9) {
    nb = nb + '0';
    pprint((const char *)&nb, fd);
  } else if (nb > 9) {
    p_putnbr(nb / 10, fd);
    nb = (nb % 10) + '0';
    pprint((const char *)&nb, fd);
  }
  return (0);
}


x86 assembly (clang, -O0):
<p_putnbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x2e9e(%rip),%rcx
cmp    (%rcx),%rax
jge    1157 <p_putnbr+0x37>
mov    -0x10(%rbp),%rax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%rax
jg     1163 <p_putnbr+0x43>
movl   $0x54,-0x4(%rbp)
jmp    120f <p_putnbr+0xef>
cmpq   $0x0,-0x10(%rbp)
jge    118a <p_putnbr+0x6a>
mov    -0x14(%rbp),%esi
lea    0xe88(%rip),%rdi
call   1040 <pprint@plt>
imul   $0xffffffffffffffff,-0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <p_putnbr@plt>
cmpq   $0x0,-0x10(%rbp)
jl     11bd <p_putnbr+0x9d>
cmpq   $0x9,-0x10(%rbp)
jg     11bd <p_putnbr+0x9d>
mov    -0x10(%rbp),%rax
add    $0x30,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <pprint@plt>
jmp    1208 <p_putnbr+0xe8>
cmpq   $0x9,-0x10(%rbp)
jle    1203 <p_putnbr+0xe3>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
mov    -0x14(%rbp),%esi
call   1030 <p_putnbr@plt>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
add    $0x30,%rdx
mov    %rdx,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <pprint@plt>
jmp    1208 <p_putnbr+0xe8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_putnbr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2ea9(%rip),%rcx
mov    $0x54,%eax
cmp    %rdi,(%rcx)
jle    11ca <p_putnbr+0xaa>
mov    %rdi,%rbx
mov    0x2ea1(%rip),%rcx
cmp    %rdi,(%rcx)
jge    11ca <p_putnbr+0xaa>
mov    %esi,%r14d
test   %rbx,%rbx
js     1160 <p_putnbr+0x40>
cmp    $0x9,%rbx
ja     117f <p_putnbr+0x5f>
add    $0x30,%rbx
jmp    11b6 <p_putnbr+0x96>
lea    0xe99(%rip),%rdi
mov    %r14d,%esi
call   1040 <pprint@plt>
neg    %rbx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1030 <p_putnbr@plt>
jmp    11c8 <p_putnbr+0xa8>
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%rbp
shr    $0x3,%rbp
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <p_putnbr@plt>
add    %rbp,%rbp
lea    0x0(,%rbp,4),%rax
add    %rbp,%rax
sub    %rax,%rbx
or     $0x30,%rbx
mov    %rbx,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    %r14d,%esi
call   1040 <pprint@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [2 x i8] c"-\00"
define i32 @p_putnbr(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
%6 = load i64, i64* %4
%7 = load i64, i64* @LONG_MAX
%8 = icmp sge i64 %6, %7
br i1 %8, label %13, label %9
9: ; preds = %2
%10 = load i64, i64* %4
%11 = load i64, i64* @LONG_MIN
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9, %2
store i32 84, i32* %3
br label %52
14: ; preds = %9
%15 = load i64, i64* %4
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* %5
%19 = call i32 @pprint(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i64, i64* %4
%21 = mul nsw i64 %20, -1
%22 = load i32, i32* %5
%23 = call i32 @p_putnbr(i64 %21, i32 %22)
br label %24
24: ; preds = %17, %14
%25 = load i64, i64* %4
%26 = icmp sge i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %24
%28 = load i64, i64* %4
%29 = icmp sle i64 %28, 9
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i64, i64* %4
%32 = add nsw i64 %31, 48
store i64 %32, i64* %4
%33 = bitcast i64* %4 to i8*
%34 = load i32, i32* %5
%35 = call i32 @pprint(i8* %33, i32 %34)
br label %51
36: ; preds = %27, %24
%37 = load i64, i64* %4
%38 = icmp sgt i64 %37, 9
br i1 %38, label %39, label %50
39: ; preds = %36
%40 = load i64, i64* %4
%41 = sdiv i64 %40, 10
%42 = load i32, i32* %5
%43 = call i32 @p_putnbr(i64 %41, i32 %42)
%44 = load i64, i64* %4
%45 = srem i64 %44, 10
%46 = add nsw i64 %45, 48
store i64 %46, i64* %4
%47 = bitcast i64* %4 to i8*
%48 = load i32, i32* %5
%49 = call i32 @pprint(i8* %47, i32 %48)
br label %50
50: ; preds = %39, %36
br label %51
51: ; preds = %50, %30
store i32 0, i32* %3
br label %52
52: ; preds = %51, %13
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@LONG_MAX = global i64 0
@LONG_MIN = global i64 0
@.str = [2 x i8] c"-\00"
define i32 @p_putnbr(i64 %0, i32 %1) {
%3 = alloca i64
%4 = load i64, i64* @LONG_MAX
%5 = icmp sgt i64 %4, %0
%6 = load i64, i64* @LONG_MIN
%7 = icmp slt i64 %6, %0
%8 = select i1 %5, i1 %7, i1 false
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = icmp slt i64 %0, 0
br i1 %10, label %17, label %11
11: ; preds = %9
%12 = icmp ult i64 %0, 10
br i1 %12, label %13, label %23
13: ; preds = %11
%14 = add nuw nsw i64 %0, 48
store i64 %14, i64* %3
%15 = bitcast i64* %3 to i8*
%16 = call i32 @pprint(i8* %15, i32 %1)
br label %21
17: ; preds = %9
%18 = tail call i32 @pprint(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %1)
%19 = sub nsw i64 0, %0
%20 = tail call i32 @p_putnbr(i64 %19, i32 %1)
br label %21
21: ; preds = %17, %2, %13, %23
%22 = phi i32 [ 0, %23 ], [ 84, %2 ], [ 0, %17 ], [ 0, %13 ]
ret i32 %22
23: ; preds = %11
%24 = udiv i64 %0, 10
%25 = tail call i32 @p_putnbr(i64 %24, i32 %1)
%26 = urem i64 %0, 10
%27 = or i64 %26, 48
store i64 %27, i64* %3
%28 = bitcast i64* %3 to i8*
%29 = call i32 @pprint(i8* %28, i32 %1)
br label %21
}