#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*/ append(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void print_x(int level) {
  char buffer[level + 16];
  char *p = &buffer[0];
  for (int i = 0; i < level; i++)
    append(p, " ");
  append(p, "X");
  printf("%s\n", buffer);
}


x86 assembly (clang, -O0):
<print_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x10(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x30(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118b <print_x+0x6b>
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <append@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <print_x+0x41>
mov    -0x20(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <append@plt>
mov    -0x30(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_x>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x10(%rbx),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
test   %edi,%edi
jle    1160 <print_x+0x40>
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <append@plt>
add    $0xffffffff,%ebx
jne    1150 <print_x+0x30>
lea    0xe9b(%rip),%rsi
mov    %r14,%rdi
call   1030 <append@plt>
lea    0xe8e(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @print_x(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = add nsw i32 %7, 16
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i8, i64 %9
store i64 %9, i64* %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8* %12, i8** %5
store i32 0, i32* %6
br label %13
13: ; preds = %20, %1
%14 = load i32, i32* %6
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %23
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call i32 @append(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %17
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %13
23: ; preds = %13
%24 = load i8*, i8** %5
%25 = call i32 @append(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%27 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @print_x(i32 %0) {
%2 = add nsw i32 %0, 16
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = icmp sgt i32 %0, 0
br i1 %5, label %9, label %6
6: ; preds = %9, %1
%7 = call i32 @append(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret void
9: ; preds = %1, %9
%10 = phi i32 [ %12, %9 ], [ 0, %1 ]
%11 = call i32 @append(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, %0
br i1 %13, label %6, label %9
}