#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 *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int q, i, m = 1, p, basis;
  printf("Enter height");
  scanf("%d", &p);
  basis = (2 * p) - 1;
  while (p > 0) {
    for (i = 1; i < p; i++) {
      printf(" ");
    }
    for (q = 1; q <= m; q++)
      printf("*");
    if (m < basis)
      m = m + 2;
    printf("\n");
    p--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11f1 <main+0xd1>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1195 <main+0x75>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116f <main+0x4f>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11c2 <main+0xa2>
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119c <main+0x7c>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d7 <main+0xb7>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x3e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11d1 <main+0xa1>
lea    (%rax,%rax,1),%r14d
add    $0xffffffff,%r14d
mov    $0x1,%ebx
jmp    1195 <main+0x65>
nopl   0x0(%rax)
lea    0x2(%rbx),%ebp
cmp    %r14d,%ebx
cmovge %ebx,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ecx
lea    -0x1(%rcx),%eax
mov    %eax,0xc(%rsp)
mov    %ebp,%ebx
cmp    $0x1,%ecx
jle    11d1 <main+0xa1>
cmp    $0x2,%eax
jb     11b3 <main+0x83>
mov    $0x1,%ebp
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jl     11a0 <main+0x70>
mov    %ebx,%ebp
test   %ebx,%ebx
jle    1170 <main+0x40>
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    11c0 <main+0x90>
jmp    1170 <main+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [13 x i8] c"Enter height\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = shl nsw i32 %5, 1
%7 = add nsw i32 %6, -1
%8 = icmp sgt i32 %5, 0
br i1 %8, label %9, label %34
9: ; preds = %0, %26
%10 = phi i32 [ %32, %26 ], [ %5, %0 ]
%11 = phi i32 [ %29, %26 ], [ 1, %0 ]
%12 = icmp ugt i32 %10, 1
br i1 %12, label %15, label %13
13: ; preds = %15, %9
%14 = icmp slt i32 %11, 1
br i1 %14, label %26, label %21
15: ; preds = %9, %15
%16 = phi i32 [ %18, %15 ], [ 1, %9 ]
%17 = call i32 @putchar(i32 32)
%18 = add nuw nsw i32 %16, 1
%19 = load i32, i32* %1
%20 = icmp slt i32 %18, %19
br i1 %20, label %15, label %13
21: ; preds = %13, %21
%22 = phi i32 [ %24, %21 ], [ 1, %13 ]
%23 = call i32 @putchar(i32 42)
%24 = add nuw i32 %22, 1
%25 = icmp eq i32 %22, %11
br i1 %25, label %26, label %21
26: ; preds = %21, %13
%27 = icmp slt i32 %11, %7
%28 = add nsw i32 %11, 2
%29 = select i1 %27, i32 %28, i32 %11
%30 = call i32 @putchar(i32 10)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp sgt i32 %31, 1
br i1 %33, label %9, label %34
34: ; preds = %26, %0
ret i32 0
}