#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(void) {
  int i, j, k, h;
  printf("Podaj wysokosc trojkata: ");
  scanf("%d", &h);
  for (i = 0; i < h; i++) {
    for (k = 0; k < h - i - 1; k++) {
      printf(" ");
    }
    if (i < h - 1) {
      for (j = 0; j < (i + 1) * 2; j++) {
        if (j == 0 || j == ((i + 1) * 2) - 1) {
          printf("*");
        } else {
          printf(" ");
        }
      }
    } else {
      for (j = 0; j < (i + 1) * 2; j++) {
        printf("*");
      }
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1269 <main+0x149>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1193 <main+0x73>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1165 <main+0x45>
mov    -0x8(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1215 <main+0xf5>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1210 <main+0xf0>
cmpl   $0x0,-0xc(%rbp)
je     11e0 <main+0xc0>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
shl    $0x1,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11f1 <main+0xd1>
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
jmp    1202 <main+0xe2>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11ab <main+0x8b>
jmp    124f <main+0x12f>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    124a <main+0x12a>
lea    0xde6(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    121c <main+0xfc>
jmp    124f <main+0x12f>
lea    0xdc9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1152 <main+0x32>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    1244 <main+0x114>
xor    %r14d,%r14d
mov    $0x2,%r13d
mov    $0x1,%r12d
mov    $0x2a,%r15d
jmp    11a3 <main+0x73>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
mov    0x4(%rsp),%eax
add    $0x2,%r13d
add    $0x2,%r12d
cmp    %eax,%r14d
jge    1244 <main+0x114>
mov    %r14d,%ebx
not    %ebx
lea    (%rax,%rbx,1),%ecx
test   %ecx,%ecx
jle    11d8 <main+0xa8>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
lea    (%rax,%rbx,1),%ecx
cmp    %ecx,%ebp
jl     11c0 <main+0x90>
add    $0xffffffff,%eax
lea    (%r14,%r14,1),%ecx
add    $0x2,%ecx
cmp    %eax,%r14d
jge    1220 <main+0xf0>
test   %ecx,%ecx
jle    1180 <main+0x50>
xor    %ebx,%ebx
nopl   (%rax)
cmp    %ebx,%r12d
mov    $0x20,%edi
cmove  %r15d,%edi
test   %ebx,%ebx
cmove  %r15d,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    11f0 <main+0xc0>
jmp    1180 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13d,%ebx
test   %ecx,%ecx
jle    1180 <main+0x50>
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1230 <main+0x100>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Podaj wysokosc trojkata: \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
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 0, i32* %2
br label %8
8: ; preds = %71, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %5
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %74
12: ; preds = %8
store i32 0, i32* %4
br label %13
13: ; preds = %22, %12
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = sub nsw i32 %15, %16
%18 = sub nsw i32 %17, 1
%19 = icmp slt i32 %14, %18
br i1 %19, label %20, label %25
20: ; preds = %13
%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* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %13
25: ; preds = %13
%26 = load i32, i32* %2
%27 = load i32, i32* %5
%28 = sub nsw i32 %27, 1
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %56
30: ; preds = %25
store i32 0, i32* %3
br label %31
31: ; preds = %52, %30
%32 = load i32, i32* %3
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
%35 = mul nsw i32 %34, 2
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %55
37: ; preds = %31
%38 = load i32, i32* %3
%39 = icmp eq i32 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = load i32, i32* %3
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
%44 = mul nsw i32 %43, 2
%45 = sub nsw i32 %44, 1
%46 = icmp eq i32 %41, %45
br i1 %46, label %47, label %49
47: ; preds = %40, %37
%48 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %51
49: ; preds = %40
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
br label %52
52: ; preds = %51
%53 = load i32, i32* %3
%54 = add nsw i32 %53, 1
store i32 %54, i32* %3
br label %31
55: ; preds = %31
br label %69
56: ; preds = %25
store i32 0, i32* %3
br label %57
57: ; preds = %65, %56
%58 = load i32, i32* %3
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
%61 = mul nsw i32 %60, 2
%62 = icmp slt i32 %58, %61
br i1 %62, label %63, label %68
63: ; preds = %57
%64 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %63
%66 = load i32, i32* %3
%67 = add nsw i32 %66, 1
store i32 %67, i32* %3
br label %57
68: ; preds = %57
br label %69
69: ; preds = %68, %55
%70 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %71
71: ; preds = %69
%72 = load i32, i32* %2
%73 = add nsw i32 %72, 1
store i32 %73, i32* %2
br label %8
74: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Podaj wysokosc trojkata: \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 ([26 x i8], [26 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 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %52
7: ; preds = %0, %46
%8 = phi i32 [ %49, %46 ], [ %5, %0 ]
%9 = phi i32 [ %51, %46 ], [ 2, %0 ]
%10 = phi i32 [ %48, %46 ], [ 0, %0 ]
%11 = xor i32 %10, -1
%12 = add i32 %8, %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %7, %14
%15 = phi i32 [ %17, %14 ], [ 0, %7 ]
%16 = call i32 @putchar(i32 32)
%17 = add nuw nsw i32 %15, 1
%18 = load i32, i32* %1
%19 = add i32 %18, %11
%20 = icmp slt i32 %17, %19
br i1 %20, label %14, label %21
21: ; preds = %14, %7
%22 = phi i32 [ %8, %7 ], [ %18, %14 ]
%23 = add nsw i32 %22, -1
%24 = icmp slt i32 %10, %23
%25 = shl nuw i32 %10, 1
%26 = add nuw i32 %25, 2
%27 = icmp sgt i32 %26, 0
br i1 %24, label %29, label %28
28: ; preds = %21
br i1 %27, label %41, label %46
29: ; preds = %21
br i1 %27, label %30, label %46
30: ; preds = %29
%31 = or i32 %25, 1
br label %32
32: ; preds = %30, %32
%33 = phi i32 [ 0, %30 ], [ %39, %32 ]
%34 = icmp eq i32 %33, 0
%35 = icmp eq i32 %33, %31
%36 = select i1 %34, i1 true, i1 %35
%37 = select i1 %36, i32 42, i32 32
%38 = call i32 @putchar(i32 %37)
%39 = add nuw nsw i32 %33, 1
%40 = icmp eq i32 %39, %9
br i1 %40, label %46, label %32
41: ; preds = %28, %41
%42 = phi i32 [ %44, %41 ], [ 0, %28 ]
%43 = call i32 @putchar(i32 42)
%44 = add nuw nsw i32 %42, 1
%45 = icmp eq i32 %44, %9
br i1 %45, label %46, label %41
46: ; preds = %41, %32, %28, %29
%47 = call i32 @putchar(i32 10)
%48 = add nuw nsw i32 %10, 1
%49 = load i32, i32* %1
%50 = icmp slt i32 %48, %49
%51 = add i32 %9, 2
br i1 %50, label %7, label %52
52: ; preds = %46, %0
ret i32 0
}