#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*/ printf(char *, ...);
void printf_indented(char *str, int num_spaces) {
  char *c = str;
  for (int i = 0; i < num_spaces; i++) {
    printf(" ");
  }
  while (c && *c) {
    if (*c == '\n' && *(c + 1) != '\n' && *(c + 1) != '\0') {
      printf("\n");
      for (int i = 0; i < num_spaces; i++) {
        printf(" ");
      }
    } else {
      printf("%c", *c);
    }
    c++;
  }
}


x86 assembly (clang, -O0):
<printf_indented>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1156 <printf_indented+0x46>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <printf_indented+0x1e>
jmp    115b <printf_indented+0x4b>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     117b <printf_indented+0x6b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    118b <printf_indented+0x7b>
jmp    1225 <printf_indented+0x115>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11ff <printf_indented+0xef>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
je     11ff <printf_indented+0xef>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     11ff <printf_indented+0xef>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fa <printf_indented+0xea>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d2 <printf_indented+0xc2>
jmp    1214 <printf_indented+0x104>
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115b <printf_indented+0x4b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_indented>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
test   %esi,%esi
jle    113f <printf_indented+0x2f>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1130 <printf_indented+0x20>
test   %rbx,%rbx
jne    115e <printf_indented+0x4e>
pop    %rbx
pop    %r14
pop    %rbp
ret
nopl   0x0(%rax)
test   %dil,%dil
je     1144 <printf_indented+0x34>
call   1030 <putchar@plt>
add    $0x1,%rbx
movsbl (%rbx),%edi
cmp    $0xa,%edi
jne    1150 <printf_indented+0x40>
mov    0x1(%rbx),%al
test   %al,%al
je     1155 <printf_indented+0x45>
cmp    $0xa,%al
je     1155 <printf_indented+0x45>
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r14d,%r14d
jle    119f <printf_indented+0x8f>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1190 <printf_indented+0x80>
add    $0x1,%rbx
jmp    115e <printf_indented+0x4e>

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

LLVM IR (-O2):
define void @printf_indented(i8* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %6, label %4
4: ; preds = %6, %2
%5 = icmp eq i8* %0, null
br i1 %5, label %29, label %11
6: ; preds = %2, %6
%7 = phi i32 [ %9, %6 ], [ 0, %2 ]
%8 = tail call i32 @putchar(i32 32)
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, %1
br i1 %10, label %4, label %6
11: ; preds = %4, %27
%12 = phi i8* [ %28, %27 ], [ %0, %4 ]
%13 = load i8, i8* %12
switch i8 %13, label %24 [
i8 0, label %29
i8 10, label %14
]
14: ; preds = %11
%15 = getelementptr inbounds i8, i8* %12, i64 1
%16 = load i8, i8* %15
switch i8 %16, label %17 [
i8 10, label %24
i8 0, label %24
]
17: ; preds = %14
%18 = tail call i32 @putchar(i32 10)
br i1 %3, label %19, label %27
19: ; preds = %17, %19
%20 = phi i32 [ %22, %19 ], [ 0, %17 ]
%21 = tail call i32 @putchar(i32 32)
%22 = add nuw nsw i32 %20, 1
%23 = icmp eq i32 %22, %1
br i1 %23, label %27, label %19
24: ; preds = %14, %14, %11
%25 = sext i8 %13 to i32
%26 = tail call i32 @putchar(i32 %25)
br label %27
27: ; preds = %19, %17, %24
%28 = getelementptr inbounds i8, i8* %12, i64 1
br label %11
29: ; preds = %11, %4
ret void
}