#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*/ os_puts(char *);
void supcon_puti(int num) {
  int sign;
  int temp;
  char buffer[128];
  int position = 126;
  if (num == 0) {
    os_puts("0");
    return;
  }
  if (num < 0) {
    sign = 1;
    temp = -num;
  } else {
    sign = 0;
    temp = num;
  }
  buffer[127] = 0;
  while (temp > 0) {
    buffer[position--] = '0' + (temp % 10);
    temp = temp / 10;
  }
  if (sign == 1)
    buffer[position--] = '-';
  os_puts(buffer + position + 1);
}


x86 assembly (clang, -O0):
<supcon_puti>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x7e,-0x94(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1143 <supcon_puti+0x33>
lea    0xec7(%rip),%rdi
call   1030 <os_puts@plt>
jmp    11f8 <supcon_puti+0xe8>
cmpl   $0x0,-0x4(%rbp)
jge    1161 <supcon_puti+0x51>
movl   $0x1,-0x8(%rbp)
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    116e <supcon_puti+0x5e>
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0xc(%rbp)
movb   $0x0,-0x11(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11b9 <supcon_puti+0xa9>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
add    $0x30,%edx
mov    %dl,%cl
mov    -0x94(%rbp),%eax
mov    %eax,%edx
add    $0xffffffff,%edx
mov    %edx,-0x94(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    1172 <supcon_puti+0x62>
cmpl   $0x1,-0x8(%rbp)
jne    11de <supcon_puti+0xce>
mov    -0x94(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x94(%rbp)
cltq
movb   $0x2d,-0x90(%rbp,%rax,1)
2d
lea    -0x90(%rbp),%rdi
movslq -0x94(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
call   1030 <os_puts@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supcon_puti>:
test   %edi,%edi
je     11a2 <supcon_puti+0x92>
sub    $0x88,%rsp
mov    %edi,%eax
neg    %eax
cmovs  %edi,%eax
movb   $0x0,0x7f(%rsp)
mov    $0x7e,%r11d
movabs $0x7e00000000,%r10
mov    $0xcccccccd,%r8d
movabs $0xffffffff00000000,%r9
ff ff ff
nopl   0x0(%rax,%rax,1)
add    %r9,%r10
mov    %eax,%esi
imul   %r8,%rsi
shr    $0x23,%rsi
lea    (%rsi,%rsi,1),%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edx
sub    %ecx,%edx
or     $0x30,%dl
mov    %dl,(%rsp,%r11,1)
add    $0xffffffffffffffff,%r11
cmp    $0x9,%eax
mov    %esi,%eax
ja     1150 <supcon_puti+0x40>
test   %edi,%edi
jns    118a <supcon_puti+0x7a>
add    $0xffffffffffffffff,%r11
sar    $0x20,%r10
movb   $0x2d,(%rsp,%r10,1)
movslq %r11d,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x1,%rdi
call   1030 <os_puts@plt>
add    $0x88,%rsp
ret
lea    0xe57(%rip),%rdi
jmp    1030 <os_puts@plt>

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

LLVM IR (-O2):
@.str = [2 x i8] c"0\00"
define void @supcon_puti(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @os_puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %35
7: ; preds = %1
%8 = icmp slt i32 %0, 0
%9 = sub nsw i32 0, %0
%10 = select i1 %8, i32 %9, i32 %0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 127
store i8 0, i8* %11
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 126, %7 ], [ %18, %12 ]
%14 = phi i32 [ %10, %7 ], [ %20, %12 ]
%15 = urem i32 %14, 10
%16 = trunc i32 %15 to i8
%17 = or i8 %16, 48
%18 = add i64 %13, -1
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %13
store i8 %17, i8* %19
%20 = udiv i32 %14, 10
%21 = icmp ult i32 %14, 10
br i1 %21, label %22, label %12
22: ; preds = %12
br i1 %8, label %23, label %28
23: ; preds = %22
%24 = add i64 %13, -2
%25 = shl i64 %18, 32
%26 = ashr exact i64 %25, 32
%27 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %26
store i8 45, i8* %27
br label %28
28: ; preds = %23, %22
%29 = phi i64 [ %24, %23 ], [ %18, %22 ]
%30 = shl i64 %29, 32
%31 = ashr exact i64 %30, 32
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %31
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = call i32 @os_puts(i8* %33)
br label %35
35: ; preds = %28, %5
ret void
}