#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 print_pyramid(int n) {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j < i; j++) {
      printf("* ");
    }
    for (j = i; j <= n; j++) {
      printf("%d ", j);
    }
    printf("\n");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_pyramid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11aa <print_pyramid+0x9a>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    115d <print_pyramid+0x4d>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <print_pyramid+0x25>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     118e <print_pyramid+0x7e>
mov    -0xc(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <print_pyramid+0x53>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <print_pyramid+0x12>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pyramid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,0x4(%rsp)
test   %edi,%edi
jle    11ca <print_pyramid+0xaa>
mov    0x4(%rsp),%eax
mov    %eax,%ebp
neg    %ebp
mov    $0x1,%r13d
lea    0xeb4(%rip),%r15
lea    0xeb0(%rip),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
cmp    $0x2,%r13d
jb     117f <print_pyramid+0x5f>
mov    %r14d,%ebx
nopl   0x0(%rax)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1170 <print_pyramid+0x50>
mov    %r13d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1190 <print_pyramid+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r13),%eax
add    $0x1,%r14d
cmp    0x4(%rsp),%r13d
mov    %eax,%r13d
jne    1160 <print_pyramid+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"* \00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_pyramid(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %5
5: ; preds = %33, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %36
9: ; preds = %5
store i32 1, i32* %4
br label %10
10: ; preds = %16, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %10
19: ; preds = %10
%20 = load i32, i32* %3
store i32 %20, i32* %4
br label %21
21: ; preds = %28, %19
%22 = load i32, i32* %4
%23 = load i32, i32* %2
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %21
31: ; preds = %21
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %5
36: ; preds = %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"* \00"
@.str.1 = [4 x i8] c"%d \00"
define void @print_pyramid(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %21, label %3
3: ; preds = %1, %17
%4 = phi i32 [ %19, %17 ], [ 1, %1 ]
%5 = icmp ugt i32 %4, 1
br i1 %5, label %6, label %11
6: ; preds = %3, %6
%7 = phi i32 [ %9, %6 ], [ 1, %3 ]
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, %4
br i1 %10, label %11, label %6
11: ; preds = %6, %3
br label %12
12: ; preds = %11, %12
%13 = phi i32 [ %15, %12 ], [ %4, %11 ]
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw i32 %13, 1
%16 = icmp eq i32 %13, %0
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = tail call i32 @putchar(i32 10)
%19 = add nuw i32 %4, 1
%20 = icmp eq i32 %4, %0
br i1 %20, label %21, label %3
21: ; preds = %17, %1
%22 = tail call i32 @putchar(i32 10)
ret void
}