#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_absolute(int);
char *my_put_big_nbr_base(int, int, int /*<<< orphan*/);
char *my_putnbr_base(int, int, int /*<<< orphan*/);
char *my_strcat(char *, char *);
char *my_put_decimal(int nbr) {
  int neg = 0;
  char *ret;
  if (nbr < 0) {
    nbr = my_absolute(nbr);
    neg = 1;
  }
  if (nbr < 2147483648) {
    ret = my_put_big_nbr_base(nbr, 10, 0);
  } else {
    ret = my_putnbr_base(nbr, 10, 0);
  }
  if (neg) {
    ret = my_strcat("-\0", ret);
  }
  return ret;
}


x86 assembly (clang, -O0):
<my_put_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    116e <my_put_decimal+0x2e>
mov    -0x4(%rbp),%edi
call   1060 <my_absolute@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movslq -0x4(%rbp),%rax
mov    $0x80000000,%ecx
cmp    %rcx,%rax
jge    1198 <my_put_decimal+0x58>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1030 <my_put_big_nbr_base@plt>
mov    %rax,-0x10(%rbp)
jmp    11ab <my_put_decimal+0x6b>
mov    -0x4(%rbp),%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1040 <my_putnbr_base@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11c9 <my_put_decimal+0x89>
mov    -0x10(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1050 <my_strcat@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_put_decimal>:
test   %edi,%edi
js     1140 <my_put_decimal+0x10>
mov    $0xa,%esi
xor    %edx,%edx
jmp    1030 <my_put_big_nbr_base@plt>
push   %rax
call   1050 <my_absolute@plt>
mov    %eax,%edi
mov    $0xa,%esi
xor    %edx,%edx
call   1030 <my_put_big_nbr_base@plt>
lea    0xea5(%rip),%rdi
mov    %rax,%rsi
pop    %rax
jmp    1040 <my_strcat@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-\00\00"
define i8* @my_put_decimal(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %3
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* %2
%9 = call i32 @my_absolute(i32 %8)
store i32 %9, i32* %2
store i32 1, i32* %3
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %12, 2147483648
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i8* @my_put_big_nbr_base(i32 %15, i32 10, i32 0)
store i8* %16, i8** %4
br label %20
17: ; preds = %10
%18 = load i32, i32* %2
%19 = call i8* @my_putnbr_base(i32 %18, i32 10, i32 0)
store i8* %19, i8** %4
br label %20
20: ; preds = %17, %14
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8*, i8** %4
%25 = call i8* @my_strcat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %24)
store i8* %25, i8** %4
br label %26
26: ; preds = %23, %20
%27 = load i8*, i8** %4
ret i8* %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"-\00\00"
define i8* @my_put_decimal(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i8* @my_put_big_nbr_base(i32 %0, i32 10, i32 0)
br label %9
5: ; preds = %1
%6 = tail call i32 @my_absolute(i32 %0)
%7 = tail call i8* @my_put_big_nbr_base(i32 %6, i32 10, i32 0)
%8 = tail call i8* @my_strcat(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %9
9: ; preds = %3, %5
%10 = phi i8* [ %8, %5 ], [ %4, %3 ]
ret i8* %10
}