#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 */
scalar_t__ printf(char *, ...);
int strlen(char *);
void printNumber(char *n, int startPos) {
  int i, len, leading, printed;
  printed = 0;
  for (i = 0; i < startPos; i++) {
    printf(" ");
  }
  len = strlen(n);
  leading = 1;
  for (i = 0; i < len; i++) {
    if ((!printed) && (i == len - 1)) {
      printf("0\n");
      return;
    }
    if ((leading) && (n[i] == '0')) {
      printf("%c", ' ');
    } else {
      leading = 0;
      printed += printf("%c", n[i]);
    }
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1165 <printNumber+0x45>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    113d <printNumber+0x1d>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1231 <printNumber+0x111>
cmpl   $0x0,-0x1c(%rbp)
jne    11b9 <printNumber+0x99>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11b9 <printNumber+0x99>
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123f <printNumber+0x11f>
cmpl   $0x0,-0x18(%rbp)
je     11f0 <printNumber+0xd0>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
jne    11f0 <printNumber+0xd0>
lea    0xe26(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121e <printNumber+0xfe>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    %rax,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    1223 <printNumber+0x103>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117f <printNumber+0x5f>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printNumber>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
test   %esi,%esi
jle    116f <printNumber+0x2f>
mov    %esi,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1160 <printNumber+0x20>
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11d8 <printNumber+0x98>
lea    -0x1(%rax),%r15d
mov    %eax,%r13d
mov    $0x1,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11af <printNumber+0x6f>
xchg   %ax,%ax
movsbl %al,%esi
xor    %r14d,%r14d
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    %eax,%ebp
add    $0x1,%rbx
cmp    %rbx,%r13
je     11d8 <printNumber+0x98>
test   %ebp,%ebp
jne    11b8 <printNumber+0x78>
cmp    %rbx,%r15
je     11f0 <printNumber+0xb0>
movzbl (%r12,%rbx,1),%eax
test   %r14d,%r14d
je     1190 <printNumber+0x50>
cmp    $0x30,%al
jne    1190 <printNumber+0x50>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x1,%r14d
jmp    11a6 <printNumber+0x66>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
lea    0xe0c(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"0\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @printNumber(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %8
store i32 0, i32* %5
br label %9
9: ; preds = %15, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %9
18: ; preds = %9
%19 = load i8*, i8** %3
%20 = call i32 @strlen(i8* %19)
store i32 %20, i32* %6
store i32 1, i32* %7
store i32 0, i32* %5
br label %21
21: ; preds = %61, %18
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %64
25: ; preds = %21
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %35, label %28
28: ; preds = %25
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = sub nsw i32 %30, 1
%32 = icmp eq i32 %29, %31
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %66
35: ; preds = %28, %25
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %48
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 48
br i1 %45, label %46, label %48
46: ; preds = %38
%47 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 32)
br label %60
48: ; preds = %38, %35
store i32 0, i32* %7
%49 = load i8*, i8** %3
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %8
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %55
%59 = trunc i64 %58 to i32
store i32 %59, i32* %8
br label %60
60: ; preds = %48, %46
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %21
64: ; preds = %21
%65 = call i64 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %66
66: ; preds = %64, %33
ret void
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%c\00"
@str = [2 x i8] c"0\00"
define void @printNumber(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %9
4: ; preds = %2, %4
%5 = phi i32 [ %7, %4 ], [ 0, %2 ]
%6 = tail call i32 @putchar(i32 32)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, %1
br i1 %8, label %9, label %4
9: ; preds = %4, %2
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %43
12: ; preds = %9
%13 = add nsw i32 %10, -1
%14 = zext i32 %13 to i64
%15 = zext i32 %10 to i64
br label %16
16: ; preds = %12, %38
%17 = phi i64 [ 0, %12 ], [ %41, %38 ]
%18 = phi i32 [ 0, %12 ], [ %40, %38 ]
%19 = phi i32 [ 1, %12 ], [ %39, %38 ]
%20 = icmp eq i32 %18, 0
%21 = icmp eq i64 %17, %14
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %45
25: ; preds = %16
%26 = icmp ne i32 %19, 0
%27 = getelementptr inbounds i8, i8* %0, i64 %17
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 48
%30 = select i1 %26, i1 %29, i1 false
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = tail call i32 @putchar(i32 32)
br label %38
33: ; preds = %25
%34 = sext i8 %28 to i32
%35 = tail call i64 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = trunc i64 %35 to i32
%37 = add i32 %18, %36
br label %38
38: ; preds = %31, %33
%39 = phi i32 [ 1, %31 ], [ 0, %33 ]
%40 = phi i32 [ %18, %31 ], [ %37, %33 ]
%41 = add nuw nsw i64 %17, 1
%42 = icmp eq i64 %41, %15
br i1 %42, label %43, label %16
43: ; preds = %38, %9
%44 = tail call i32 @putchar(i32 10)
br label %45
45: ; preds = %43, %23
ret void
}