#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 its_a_rectangle(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int i, j;
  int width, heigth;
  int perimeter;
  printf("put de width :");
  scanf("%d", &width);
  printf("put de heigth :");
  scanf("%d", &heigth);
  if (its_a_rectangle(width, heigth) == 1) {
    perimeter = 2 * (width + heigth);
  } else {
    printf("its a square\n");
    return;
  }
  printf("------------------------------\n\n");
  for (i = 0; i < heigth; ++i) {
    for (j = 0; j < width; j++) {
      printf(" * ");
    }
    printf("\n");
  }
  printf("\n\nThe perimeter is %d\n", perimeter);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <its_a_rectangle@plt>
cmp    $0x1,%eax
jne    1199 <main+0x69>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ac <main+0x7c>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <main+0xf9>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1218 <main+0xe8>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fc <main+0xcc>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d4 <main+0xa4>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c1 <main+0x91>
mov    -0x14(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea3(%rip),%rbx
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1070 <its_a_rectangle@plt>
cmp    $0x1,%eax
jne    1205 <main+0xb5>
mov    (%rsp),%r14d
add    0x4(%rsp),%r14d
add    %r14d,%r14d
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,(%rsp)
jle    1213 <main+0xc3>
lea    0xe5a(%rip),%rbx
xor    %r15d,%r15d
jmp    11e4 <main+0x94>
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15d
cmp    (%rsp),%r15d
jge    1213 <main+0xc3>
cmpl   $0x0,0x4(%rsp)
jle    11d0 <main+0x80>
xor    %ebp,%ebp
nopl   (%rax)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    0x4(%rsp),%ebp
jl     11f0 <main+0xa0>
jmp    11d0 <main+0x80>
lea    0xe31(%rip),%rdi
call   1040 <puts@plt>
jmp    1224 <main+0xd4>
lea    0xe0c(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"put de width :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"put de heigth :\00"
@.str.3 = [14 x i8] c"its a square\0A\00"
@.str.4 = [33 x i8] c"------------------------------\0A\0A\00"
@.str.5 = [4 x i8] c" * \00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [23 x i8] c"\0A\0AThe perimeter is %d\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 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* %3)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = call i32 @its_a_rectangle(i32 %10, i32 %11)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = add nsw i32 %15, %16
%18 = mul nsw i32 2, %17
store i32 %18, i32* %5
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %45
21: ; preds = %14
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %23
23: ; preds = %39, %21
%24 = load i32, i32* %1
%25 = load i32, i32* %4
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %42
27: ; preds = %23
store i32 0, i32* %2
br label %28
28: ; preds = %34, %27
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %34
34: ; preds = %32
%35 = load i32, i32* %2
%36 = add nsw i32 %35, 1
store i32 %36, i32* %2
br label %28
37: ; preds = %28
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %1
%41 = add nsw i32 %40, 1
store i32 %41, i32* %1
br label %23
42: ; preds = %23
%43 = load i32, i32* %5
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %19
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"put de width :\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"put de heigth :\00"
@.str.5 = [4 x i8] c" * \00"
@.str.7 = [23 x i8] c"\0A\0AThe perimeter is %d\0A\00"
@str = [13 x i8] c"its a square\00"
@str.8 = [32 x i8] c"------------------------------\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 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 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, 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 = load i32, i32* %2
%11 = call i32 @its_a_rectangle(i32 %9, i32 %10)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %21
13: ; preds = %0
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = add nsw i32 %15, %14
%17 = shl nsw i32 %16, 1
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.8, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %23, label %38
21: ; preds = %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %40
23: ; preds = %13, %33
%24 = phi i32 [ %35, %33 ], [ 0, %13 ]
%25 = load i32, i32* %1
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %23, %27
%28 = phi i32 [ %30, %27 ], [ 0, %23 ]
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%30 = add nuw nsw i32 %28, 1
%31 = load i32, i32* %1
%32 = icmp slt i32 %30, %31
br i1 %32, label %27, label %33
33: ; preds = %27, %23
%34 = call i32 @putchar(i32 10)
%35 = add nuw nsw i32 %24, 1
%36 = load i32, i32* %2
%37 = icmp slt i32 %35, %36
br i1 %37, label %23, label %38
38: ; preds = %33, %13
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0), i32 %17)
br label %40
40: ; preds = %38, %21
ret void
}