#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
void printdec(FILE *fp, int val) {
  int scale;
  int zeroflag = 0;
  if (val < 0) {
    fputc('-', fp);
    val = -val;
  }
  for (scale = 1000000000; scale > 1; scale /= 10) {
    if (val >= scale) {
      fputc('0' + val / scale, fp);
      val %= scale;
      zeroflag = 1;
    } else if (zeroflag)
      fputc('0', fp);
    else
      fputc(' ', fp);
  }
  fputc('0' + val, fp);
}


x86 assembly (clang, -O0):
<printdec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1146 <printdec+0x36>
mov    -0x8(%rbp),%rsi
mov    $0x2d,%edi
call   1030 <fputc@plt>
xor    %eax,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x3b9aca00,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jle    11d8 <printdec+0xc8>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1190 <printdec+0x80>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,%edi
add    $0x30,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11c0 <printdec+0xb0>
cmpl   $0x0,-0x14(%rbp)
je     11ad <printdec+0x9d>
mov    -0x8(%rbp),%rsi
mov    $0x30,%edi
call   1030 <fputc@plt>
jmp    11bb <printdec+0xab>
mov    -0x8(%rbp),%rsi
mov    $0x20,%edi
call   1030 <fputc@plt>
jmp    11c0 <printdec+0xb0>
jmp    11c5 <printdec+0xb5>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    114d <printdec+0x3d>
mov    -0xc(%rbp),%edi
add    $0x30,%edi
mov    -0x8(%rbp),%rsi
call   1030 <fputc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printdec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%r14
test   %esi,%esi
jns    112f <printdec+0x1f>
mov    $0x2d,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
neg    %ebp
mov    $0x3b9aca00,%ebx
xor    %eax,%eax
mov    $0xcccccccd,%r15d
jmp    1168 <printdec+0x58>
xchg   %ax,%ax
mov    %ebp,%eax
cltd
idiv   %ebx
lea    0x30(%rax),%edi
mov    %edx,%ebp
mov    %r14,%rsi
call   1030 <fputc@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
imul   %r15,%rcx
shr    $0x23,%rcx
cmp    $0x13,%ebx
mov    %ecx,%ebx
jbe    1188 <printdec+0x78>
cmp    %ebx,%ebp
jge    1140 <printdec+0x30>
test   %eax,%eax
je     1177 <printdec+0x67>
mov    $0x30,%edi
jmp    114a <printdec+0x3a>
mov    $0x20,%edi
mov    %r14,%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
jmp    1157 <printdec+0x47>
add    $0x30,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

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

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