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


x86 assembly (clang, -O0):
<pattern2>:
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     11a7 <pattern2+0x97>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     1160 <pattern2+0x50>
lea    0xeb4(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <pattern2+0x25>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     118d <pattern2+0x7d>
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1167 <pattern2+0x57>
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <pattern2+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11a7 <pattern2+0x87>
mov    %edi,%r14d
lea    0x1(%r14),%r15d
mov    $0x1,%ebp
mov    $0x2,%r12d
lea    0xeb8(%rip),%r13
nopl   0x0(%rax,%rax,1)
cmp    %r14d,%ebp
jge    1171 <pattern2+0x51>
mov    %r14d,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
cmp    %ebx,%ebp
jne    1160 <pattern2+0x40>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
call   1040 <printf@plt>
add    $0xffffffff,%ebx
jne    1180 <pattern2+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
lea    0x1(%r12),%eax
cmp    %r15d,%r12d
mov    %eax,%r12d
jne    1150 <pattern2+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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