#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 = h;
  for (i = 0; i < h; i++) {
    if (i == 0) {
      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>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1252 <main+0x132>
cmpl   $0x0,-0xc(%rbp)
jne    11c2 <main+0xa2>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11af <main+0x8f>
lea    0xe8c(%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    117e <main+0x5e>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123b <main+0x11b>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    122d <main+0x10d>
cmpl   $0x0,-0x10(%rbp)
je     11f0 <main+0xd0>
mov    -0x10(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    120c <main+0xec>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    121a <main+0xfa>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121f <main+0xff>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c9 <main+0xa9>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1161 <main+0x41>
mov    -0x18(%rbp),%esi
lea    0xdc3(%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   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
je     11f7 <main+0xc7>
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    1188 <main+0x58>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
add    $0x1,%r14d
cmp    0x4(%rsp),%r14d
jae    11f7 <main+0xc7>
test   %r14d,%r14d
je     11d0 <main+0xa0>
test   %ebp,%ebp
je     1170 <main+0x40>
xor    %eax,%eax
xor    %ebx,%ebx
jmp    11b6 <main+0x86>
nopw   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
mov    %ebp,%ecx
mov    %ebx,%eax
add    %ebx,%ecx
je     1170 <main+0x40>
sub    $0x1,%ebx
jb     11a0 <main+0x70>
add    %ebp,%eax
cmp    $0x1,%eax
je     11a0 <main+0x70>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11ae <main+0x7e>
xchg   %ax,%ax
test   %ebp,%ebp
je     1170 <main+0x40>
mov    %ebp,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    11e0 <main+0xb0>
add    %ebp,%r15d
jmp    1170 <main+0x40>
lea    0xe1f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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"\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)
%9 = load i32, i32* %2
store i32 %9, i32* %5
store i32 0, i32* %3
br label %10
10: ; preds = %59, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp ult i32 %11, %12
br i1 %13, label %14, label %62
14: ; preds = %10
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %31
17: ; preds = %14
store i32 0, i32* %4
br label %18
18: ; preds = %26, %17
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* %6
%25 = add i32 %24, 1
store i32 %25, i32* %6
br label %26
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add i32 %27, 1
store i32 %28, i32* %4
br label %18
29: ; preds = %18
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
31: ; preds = %14
store i32 0, i32* %4
br label %32
32: ; preds = %51, %31
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = icmp ult i32 %33, %34
br i1 %35, label %36, label %54
36: ; preds = %32
%37 = load i32, i32* %4
%38 = icmp eq i32 %37, 0
br i1 %38, label %44, label %39
39: ; preds = %36
%40 = load i32, i32* %4
%41 = load i32, i32* %5
%42 = sub i32 %41, 1
%43 = icmp eq i32 %40, %42
br i1 %43, label %44, label %48
44: ; preds = %39, %36
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32, i32* %6
%47 = add i32 %46, 1
store i32 %47, i32* %6
br label %50
48: ; preds = %39
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add i32 %52, 1
store i32 %53, i32* %4
br label %32
54: ; preds = %32
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54, %29
%57 = load i32, i32* %5
%58 = add i32 %57, -1
store i32 %58, i32* %5
br label %59
59: ; preds = %56
%60 = load i32, i32* %3
%61 = add i32 %60, 1
store i32 %61, i32* %3
br label %10
62: ; preds = %10
%63 = load i32, i32* %6
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0), i32 %63)
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, %39
%8 = phi i32 [ %40, %39 ], [ 0, %0 ]
%9 = phi i32 [ %42, %39 ], [ %5, %0 ]
%10 = phi i32 [ %43, %39 ], [ 0, %0 ]
%11 = icmp eq i32 %10, 0
%12 = icmp eq i32 %9, 0
br i1 %11, label %16, label %13
13: ; preds = %7
br i1 %12, label %39, label %14
14: ; preds = %13
%15 = add i32 %9, -1
br label %24
16: ; preds = %7
br i1 %12, label %39, label %17
17: ; preds = %16, %17
%18 = phi i32 [ %20, %17 ], [ 0, %16 ]
%19 = call i32 @putchar(i32 42)
%20 = add nuw i32 %18, 1
%21 = icmp eq i32 %20, %9
br i1 %21, label %22, label %17
22: ; preds = %17
%23 = add i32 %8, %9
br label %39
24: ; preds = %14, %35
%25 = phi i32 [ %8, %14 ], [ %36, %35 ]
%26 = phi i32 [ 0, %14 ], [ %37, %35 ]
%27 = icmp eq i32 %26, 0
%28 = icmp eq i32 %26, %15
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = call i32 @putchar(i32 42)
%32 = add i32 %25, 1
br label %35
33: ; preds = %24
%34 = call i32 @putchar(i32 32)
br label %35
35: ; preds = %30, %33
%36 = phi i32 [ %32, %30 ], [ %25, %33 ]
%37 = add nuw i32 %26, 1
%38 = icmp eq i32 %37, %9
br i1 %38, label %39, label %24
39: ; preds = %35, %13, %16, %22
%40 = phi i32 [ %8, %16 ], [ %23, %22 ], [ %8, %13 ], [ %36, %35 ]
%41 = call i32 @putchar(i32 10)
%42 = add i32 %9, -1
%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 = %39, %0
%47 = phi i32 [ 0, %0 ], [ %40, %39 ]
%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
}