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


x86 assembly (clang, -O0):
<pattern1>:
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     11af <pattern1+0x9f>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    -0x8(%rbp),%ecx
cmp    %ecx,%eax
jg     1160 <pattern1+0x50>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <pattern1+0x25>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1195 <pattern1+0x85>
lea    0xe81(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1167 <pattern1+0x57>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <pattern1+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pattern1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
jle    11a5 <pattern1+0x85>
mov    %edi,%r14d
mov    $0x1,%r15d
lea    0xec1(%rip),%r12
lea    0xebd(%rip),%r13
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
cmp    %r14d,%ebx
jge    116f <pattern1+0x4f>
mov    %r14d,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
cmp    %ebp,%ebx
jne    1160 <pattern1+0x40>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1180 <pattern1+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
add    $0x2,%r15d
cmp    %r14d,%ebx
mov    %eax,%ebx
jne    1150 <pattern1+0x30>
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"
@.str.1 = [3 x i8] c"* \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @pattern1(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 = %36, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %39
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 ([3 x i8], [3 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 = %31, %22
%24 = load i32, i32* %5
%25 = load i32, i32* %3
%26 = mul nsw i32 2, %25
%27 = sub nsw i32 %26, 1
%28 = icmp sle i32 %24, %27
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %23
34: ; preds = %23
%35 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %6
39: ; preds = %6
ret void
}

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