#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 */
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char *);
char *make_staircase(int size) {
  char *staircase;
  staircase = malloc(sizeof(char) * size * (size + 1));
  for (int step = 1; step <= size; step++) {
    for (int gap = 0; gap < size - step; gap++) {
      strcat(staircase, " \x00");
    }
    for (int solid = 0; solid < step; solid++) {
      strcat(staircase, "#\x00");
    }
    strcat(staircase, "\n");
  }
  return staircase;
}


x86 assembly (clang, -O0):
<make_staircase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x0,%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11e3 <make_staircase+0xc3>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    1194 <make_staircase+0x74>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <make_staircase+0x45>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c5 <make_staircase+0xa5>
mov    -0x10(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119b <make_staircase+0x7b>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1040 <strcat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <make_staircase+0x32>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_staircase>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0x1(%rbx),%edi
imul   %ebx,%edi
call   1030 <malloc@plt>
mov    %rbx,%rcx
mov    %rax,%rbx
test   %ecx,%ecx
jle    11bd <make_staircase+0x9d>
mov    $0x1,%ebp
lea    0xeb2(%rip),%r15
lea    0xeae(%rip),%r12
mov    %rcx,(%rsp)
nopl   0x0(%rax)
mov    %ecx,%r14d
mov    %ebp,%r13d
cmp    %ecx,%ebp
jge    1190 <make_staircase+0x70>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%r14d
cmp    %r14d,%ebp
jne    1170 <make_staircase+0x50>
mov    %ebp,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <strcat@plt>
add    $0xffffffff,%r13d
jne    1190 <make_staircase+0x70>
mov    %rbx,%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcat@plt>
lea    0x1(%rbp),%eax
mov    (%rsp),%rcx
cmp    %ecx,%ebp
mov    %eax,%ebp
jne    1160 <make_staircase+0x40>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" \00\00"
@.str.1 = [3 x i8] c"#\00\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @make_staircase(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 1, %8
%10 = load i32, i32* %2
%11 = add nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = mul i64 %9, %12
%14 = trunc i64 %13 to i32
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %3
store i32 1, i32* %4
br label %16
16: ; preds = %47, %1
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %50
20: ; preds = %16
store i32 0, i32* %5
br label %21
21: ; preds = %30, %20
%22 = load i32, i32* %5
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = sub nsw i32 %23, %24
%26 = icmp slt i32 %22, %25
br i1 %26, label %27, label %33
27: ; preds = %21
%28 = load i8*, i8** %3
%29 = call i32 @strcat(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %21
33: ; preds = %21
store i32 0, i32* %6
br label %34
34: ; preds = %41, %33
%35 = load i32, i32* %6
%36 = load i32, i32* %4
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %44
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %38
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %34
44: ; preds = %34
%45 = load i8*, i8** %3
%46 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %44
%48 = load i32, i32* %4
%49 = add nsw i32 %48, 1
store i32 %49, i32* %4
br label %16
50: ; preds = %16
%51 = load i8*, i8** %3
ret i8* %51
}

LLVM IR (-O2):
@.str = [3 x i8] c" \00\00"
@.str.1 = [3 x i8] c"#\00\00"
@.str.2 = [2 x i8] c"\0A\00"
define i8* @make_staircase(i32 %0) {
%2 = add i32 %0, 1
%3 = mul i32 %2, %0
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp slt i32 %0, 1
br i1 %5, label %12, label %6
6: ; preds = %1, %18
%7 = phi i32 [ %9, %18 ], [ %0, %1 ]
%8 = phi i32 [ %20, %18 ], [ 1, %1 ]
%9 = add i32 %7, -1
%10 = icmp slt i32 %8, %0
br i1 %10, label %13, label %11
11: ; preds = %13, %6
br label %22
12: ; preds = %18, %1
ret i8* %4
13: ; preds = %6, %13
%14 = phi i32 [ %16, %13 ], [ 0, %6 ]
%15 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = add nuw nsw i32 %14, 1
%17 = icmp eq i32 %16, %9
br i1 %17, label %11, label %13
18: ; preds = %22
%19 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%20 = add nuw i32 %8, 1
%21 = icmp eq i32 %8, %0
br i1 %21, label %12, label %6
22: ; preds = %11, %22
%23 = phi i32 [ %25, %22 ], [ 0, %11 ]
%24 = tail call i32 @strcat(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%25 = add nuw nsw i32 %23, 1
%26 = icmp eq i32 %25, %8
br i1 %26, label %18, label %22
}