#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 a, b, i, j, c = 0;
  printf("Podaj kolumny: \n");
  scanf("%d", &a);
  printf("Podaj wiersze: \n");
  scanf("%d", &b);
  for (i = 1; i <= a; i++) {
    for (j = 1; j <= b; j++) {
      if (i == 1 || i == a || j == 1 || j == b) {
        printf("*");
        c++;
      } else {
        printf(" ");
      }
    }
    printf("\n");
  }
  printf("Uzyto %d gwiazdek do narysowania tej figury\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    0xec6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     121d <main+0xfd>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1201 <main+0xe1>
cmpl   $0x1,-0x10(%rbp)
je     11c4 <main+0xa4>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
je     11c4 <main+0xa4>
cmpl   $0x1,-0x14(%rbp)
je     11c4 <main+0xa4>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11e0 <main+0xc0>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ee <main+0xce>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11f3 <main+0xd3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118c <main+0x6c>
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1179 <main+0x59>
mov    -0x18(%rbp),%esi
lea    0xe02(%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    0xee1(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    120a <main+0xca>
mov    $0x1,%ebx
xor    %r14d,%r14d
jmp    11b5 <main+0x75>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%eax
cmp    0x8(%rsp),%ebx
mov    %eax,%ebx
jge    120d <main+0xcd>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    11a0 <main+0x60>
xor    %ecx,%ecx
jmp    11e8 <main+0xa8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
mov    0xc(%rsp),%eax
mov    %ebp,%ecx
cmp    %eax,%ebp
jge    11a0 <main+0x60>
lea    0x1(%rcx),%ebp
cmp    $0x1,%ebx
je     11d0 <main+0x90>
cmp    0x8(%rsp),%ebx
je     11d0 <main+0x90>
test   %ecx,%ecx
je     11d0 <main+0x90>
cmp    %eax,%ebp
je     11d0 <main+0x90>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11de <main+0x9e>
xor    %r14d,%r14d
lea    0xdef(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Podaj kolumny: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Podaj wiersze: \0A\00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [45 x i8] c"Uzyto %d gwiazdek do narysowania tej figury\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 ([17 x i8], [17 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 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 1, i32* %4
br label %11
11: ; preds = %46, %0
%12 = load i32, i32* %4
%13 = load i32, i32* %2
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %49
15: ; preds = %11
store i32 1, i32* %5
br label %16
16: ; preds = %41, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %3
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %44
20: ; preds = %16
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %34, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = icmp eq i32 %24, %25
br i1 %26, label %34, label %27
27: ; preds = %23
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 1
br i1 %29, label %34, label %30
30: ; preds = %27
%31 = load i32, i32* %5
%32 = load i32, i32* %3
%33 = icmp eq i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %30, %27, %23, %20
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %40
38: ; preds = %30
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %16
44: ; preds = %16
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %46
46: ; preds = %44
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %11
49: ; preds = %11
%50 = load i32, i32* %6
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %50)
ret i32 0
}

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