#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 *, unsigned int *);
int main(void) {
  unsigned int h, i, j, tmp;
  unsigned int c = 0;
  printf("Podaj wysokosc trojkata: ");
  scanf("%d", &h);
  tmp = 0;
  for (i = 0; i < h; i++) {
    if (i == h - 1) {
      for (j = 0; j < tmp; j++) {
        printf("*");
        c++;
      }
      printf("\n");
    } else {
      for (j = 0; j < tmp; j++) {
        if ((j == 0) || (j == tmp - 1)) {
          printf("*");
          c++;
        } else {
          printf(" ");
        }
      }
      printf("\n");
    }
    tmp++;
  }
  printf("\nUzyto %d gwiazdek do narysowania tego trojkata\n", c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    125a <main+0x13a>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11ca <main+0xaa>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11b7 <main+0x97>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1186 <main+0x66>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1243 <main+0x123>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1235 <main+0x115>
cmpl   $0x0,-0x10(%rbp)
je     11f8 <main+0xd8>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1214 <main+0xf4>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1222 <main+0x102>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1227 <main+0x107>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11d1 <main+0xb1>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1162 <main+0x42>
mov    -0x18(%rbp),%esi
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     11fe <main+0xce>
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1185 <main+0x55>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0xc(%rsp),%eax
cmp    %eax,%ebp
jae    11fe <main+0xce>
add    $0xffffffff,%eax
cmp    %eax,%ebp
jne    11c0 <main+0x90>
test   %ebp,%ebp
je     1170 <main+0x40>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11a0 <main+0x70>
add    %ebp,%r14d
jmp    1170 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
test   %ebp,%ebp
je     1170 <main+0x40>
xor    %eax,%eax
xor    %ebx,%ebx
jmp    11e6 <main+0xb6>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
mov    %ebp,%ecx
mov    %ebx,%eax
add    %ebx,%ecx
je     1170 <main+0x40>
sub    $0x1,%ebx
jb     11d0 <main+0xa0>
add    %ebp,%eax
cmp    $0x1,%eax
je     11d0 <main+0xa0>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11de <main+0xae>
lea    0xe18(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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"\0A\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [49 x i8] c"\0AUzyto %d gwiazdek do narysowania tego trojkata\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 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 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* %2)
store i32 0, i32* %5
store i32 0, i32* %3
br label %9
9: ; preds = %60, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp ult i32 %10, %11
br i1 %12, label %13, label %63
13: ; preds = %9
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = sub i32 %15, 1
%17 = icmp eq i32 %14, %16
br i1 %17, label %18, label %32
18: ; preds = %13
store i32 0, i32* %4
br label %19
19: ; preds = %27, %18
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* %6
%26 = add i32 %25, 1
store i32 %26, i32* %6
br label %27
27: ; preds = %23
%28 = load i32, i32* %4
%29 = add i32 %28, 1
store i32 %29, i32* %4
br label %19
30: ; preds = %19
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %57
32: ; preds = %13
store i32 0, i32* %4
br label %33
33: ; preds = %52, %32
%34 = load i32, i32* %4
%35 = load i32, i32* %5
%36 = icmp ult i32 %34, %35
br i1 %36, label %37, label %55
37: ; preds = %33
%38 = load i32, i32* %4
%39 = icmp eq i32 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %37
%41 = load i32, i32* %4
%42 = load i32, i32* %5
%43 = sub i32 %42, 1
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %49
45: ; preds = %40, %37
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* %6
%48 = add i32 %47, 1
store i32 %48, i32* %6
br label %51
49: ; preds = %40
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
br label %52
52: ; preds = %51
%53 = load i32, i32* %4
%54 = add i32 %53, 1
store i32 %54, i32* %4
br label %33
55: ; preds = %33
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %55, %30
%58 = load i32, i32* %5
%59 = add i32 %58, 1
store i32 %59, i32* %5
br label %60
60: ; preds = %57
%61 = load i32, i32* %3
%62 = add i32 %61, 1
store i32 %62, i32* %3
br label %9
63: ; preds = %9
%64 = load i32, i32* %6
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %64)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Podaj wysokosc trojkata: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.5 = [49 x i8] c"\0AUzyto %d gwiazdek do narysowania tego trojkata\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @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 eq i32 %5, 0
br i1 %6, label %46, label %7
7: ; preds = %0, %40
%8 = phi i32 [ %44, %40 ], [ %5, %0 ]
%9 = phi i32 [ %41, %40 ], [ 0, %0 ]
%10 = phi i32 [ %43, %40 ], [ 0, %0 ]
%11 = add i32 %8, -1
%12 = icmp eq i32 %10, %11
%13 = icmp eq i32 %10, 0
br i1 %12, label %17, label %14
14: ; preds = %7
br i1 %13, label %40, label %15
15: ; preds = %14
%16 = add i32 %10, -1
br label %25
17: ; preds = %7
br i1 %13, label %40, label %18
18: ; preds = %17, %18
%19 = phi i32 [ %21, %18 ], [ 0, %17 ]
%20 = call i32 @putchar(i32 42)
%21 = add nuw i32 %19, 1
%22 = icmp eq i32 %21, %10
br i1 %22, label %23, label %18
23: ; preds = %18
%24 = add i32 %9, %10
br label %40
25: ; preds = %15, %36
%26 = phi i32 [ %9, %15 ], [ %37, %36 ]
%27 = phi i32 [ 0, %15 ], [ %38, %36 ]
%28 = icmp eq i32 %27, 0
%29 = icmp eq i32 %27, %16
%30 = select i1 %28, i1 true, i1 %29
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = call i32 @putchar(i32 42)
%33 = add i32 %26, 1
br label %36
34: ; preds = %25
%35 = call i32 @putchar(i32 32)
br label %36
36: ; preds = %31, %34
%37 = phi i32 [ %33, %31 ], [ %26, %34 ]
%38 = add nuw i32 %27, 1
%39 = icmp eq i32 %38, %10
br i1 %39, label %40, label %25
40: ; preds = %36, %14, %17, %23
%41 = phi i32 [ %9, %17 ], [ %24, %23 ], [ %9, %14 ], [ %37, %36 ]
%42 = call i32 @putchar(i32 10)
%43 = add nuw i32 %10, 1
%44 = load i32, i32* %1
%45 = icmp ult i32 %43, %44
br i1 %45, label %7, label %46
46: ; preds = %40, %0
%47 = phi i32 [ 0, %0 ], [ %41, %40 ]
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %47)
ret i32 0
}