#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 *, char *);
int /*<<< orphan*/ sprintf(char *, char *);
void print_x(int level) {
  char buffer[level + 16];
  char *p = &buffer[0];
  for (int i = 0; i < level; i++)
    p += sprintf(p, " ");
  p += sprintf(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    119b <print_x+0x7b>
mov    -0x20(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1040 <sprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1161 <print_x+0x41>
mov    -0x20(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x30(%rbp),%rsi
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
lea    0xe3e(%rip),%rdi
call   1030 <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
lea    0x10(%rdi),%eax
mov    %rsp,%rsi
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rsi
mov    %rsi,%rsp
mov    %rsi,%rcx
test   %edi,%edi
jle    119e <print_x+0x8e>
lea    -0x1(%rdi),%edx
mov    %edi,%eax
and    $0x7,%eax
mov    %rsi,%rcx
cmp    $0x7,%edx
jb     1188 <print_x+0x78>
and    $0xfffffff8,%edi
mov    %rsi,%rcx
cs nopw 0x0(%rax,%rax,1)
nop
movw   $0x20,(%rcx)
movw   $0x20,0x1(%rcx)
movw   $0x20,0x2(%rcx)
movw   $0x20,0x3(%rcx)
movw   $0x20,0x4(%rcx)
movw   $0x20,0x5(%rcx)
movw   $0x20,0x6(%rcx)
movw   $0x20,0x7(%rcx)
add    $0x8,%rcx
add    $0xfffffff8,%edi
jne    1150 <print_x+0x40>
test   %eax,%eax
je     119e <print_x+0x8e>
nopl   0x0(%rax)
movw   $0x20,(%rcx)
add    $0x1,%rcx
add    $0xffffffff,%eax
jne    1190 <print_x+0x80>
movw   $0x58,(%rcx)
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
mov    %rbp,%rsp
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 = %23, %1
%14 = load i32, i32* %6
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %26
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load i8*, i8** %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %20, i64 %21
store i8* %22, i8** %5
br label %23
23: ; preds = %17
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %13
26: ; preds = %13
%27 = load i8*, i8** %5
%28 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8*, i8** %5
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %5
%32 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%33 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.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 %6, label %23
6: ; preds = %1
%7 = add i32 %0, -1
%8 = and i32 %0, 7
%9 = icmp ult i32 %7, 7
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = and i32 %0, -8
br label %27
12: ; preds = %27, %6
%13 = phi i8* [ undef, %6 ], [ %45, %27 ]
%14 = phi i8* [ %4, %6 ], [ %45, %27 ]
%15 = icmp eq i32 %8, 0
br i1 %15, label %23, label %16
16: ; preds = %12, %16
%17 = phi i8* [ %20, %16 ], [ %14, %12 ]
%18 = phi i32 [ %21, %16 ], [ 0, %12 ]
%19 = bitcast i8* %17 to i16*
store i16 32, i16* %19
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = add i32 %18, 1
%22 = icmp eq i32 %21, %8
br i1 %22, label %23, label %16
23: ; preds = %12, %16, %1
%24 = phi i8* [ %4, %1 ], [ %13, %12 ], [ %20, %16 ]
%25 = bitcast i8* %24 to i16*
store i16 88, i16* %25
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret void
27: ; preds = %27, %10
%28 = phi i8* [ %4, %10 ], [ %45, %27 ]
%29 = phi i32 [ 0, %10 ], [ %46, %27 ]
%30 = bitcast i8* %28 to i16*
store i16 32, i16* %30
%31 = getelementptr inbounds i8, i8* %28, i64 1
%32 = bitcast i8* %31 to i16*
store i16 32, i16* %32
%33 = getelementptr inbounds i8, i8* %28, i64 2
%34 = bitcast i8* %33 to i16*
store i16 32, i16* %34
%35 = getelementptr inbounds i8, i8* %28, i64 3
%36 = bitcast i8* %35 to i16*
store i16 32, i16* %36
%37 = getelementptr inbounds i8, i8* %28, i64 4
%38 = bitcast i8* %37 to i16*
store i16 32, i16* %38
%39 = getelementptr inbounds i8, i8* %28, i64 5
%40 = bitcast i8* %39 to i16*
store i16 32, i16* %40
%41 = getelementptr inbounds i8, i8* %28, i64 6
%42 = bitcast i8* %41 to i16*
store i16 32, i16* %42
%43 = getelementptr inbounds i8, i8* %28, i64 7
%44 = bitcast i8* %43 to i16*
store i16 32, i16* %44
%45 = getelementptr inbounds i8, i8* %28, i64 8
%46 = add i32 %29, 8
%47 = icmp eq i32 %46, %11
br i1 %47, label %12, label %27
}