#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*/ putchar(char const);
void fmt_level(const char *buf, size_t nbuf, int levels) {
  const char *c = buf;
  int ii;
  for (ii = 0; ii < levels; ii++) {
    putchar('\t');
  }
  while (nbuf && *c) {
    putchar(*c);
    if (*c == '\n') {
      for (ii = 0; ii < levels; ii++) {
        putchar(' ');
      }
    }
    c++;
    nbuf--;
  }
  putchar('\n');
}


x86 assembly (clang, -O0):
<fmt_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1156 <fmt_level+0x46>
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1132 <fmt_level+0x22>
jmp    115b <fmt_level+0x4b>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x25(%rbp)
je     117b <fmt_level+0x6b>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    118b <fmt_level+0x7b>
jmp    11f4 <fmt_level+0xe4>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11d7 <fmt_level+0xc7>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d2 <fmt_level+0xc2>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ae <fmt_level+0x9e>
jmp    11d7 <fmt_level+0xc7>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    115b <fmt_level+0x4b>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_level>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
test   %edx,%edx
jle    113f <fmt_level+0x2f>
mov    %r14d,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x9,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1130 <fmt_level+0x20>
test   %r15,%r15
jne    116a <fmt_level+0x5a>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
add    $0xffffffffffffffff,%r15
je     1144 <fmt_level+0x34>
mov    0x0(%rbp),%al
test   %al,%al
je     1144 <fmt_level+0x34>
movsbl %al,%edi
call   1030 <putchar@plt>
cmpb   $0xa,0x0(%rbp)
jne    1160 <fmt_level+0x50>
test   %r14d,%r14d
jle    1160 <fmt_level+0x50>
mov    %r14d,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1190 <fmt_level+0x80>
jmp    1160 <fmt_level+0x50>

LLVM IR (-O0):
define void @fmt_level(i8* %0, i64 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
store i32 0, i32* %8
br label %10
10: ; preds = %16, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = call i32 @putchar(i8 signext 9)
br label %16
16: ; preds = %14
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
br label %10
19: ; preds = %10
br label %20
20: ; preds = %49, %19
%21 = load i64, i64* %5
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %23, %20
%29 = phi i1 [ false, %20 ], [ %27, %23 ]
br i1 %29, label %30, label %54
30: ; preds = %28
%31 = load i8*, i8** %7
%32 = load i8, i8* %31
%33 = call i32 @putchar(i8 signext %32)
%34 = load i8*, i8** %7
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 10
br i1 %37, label %38, label %49
38: ; preds = %30
store i32 0, i32* %8
br label %39
39: ; preds = %45, %38
%40 = load i32, i32* %8
%41 = load i32, i32* %6
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %48
43: ; preds = %39
%44 = call i32 @putchar(i8 signext 32)
br label %45
45: ; preds = %43
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %39
48: ; preds = %39
br label %49
49: ; preds = %48, %30
%50 = load i8*, i8** %7
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %7
%52 = load i64, i64* %5
%53 = add i64 %52, -1
store i64 %53, i64* %5
br label %20
54: ; preds = %28
%55 = call i32 @putchar(i8 signext 10)
ret void
}

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