#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*/ clear_scanf();
int /*<<< orphan*/ error_show();
int /*<<< orphan*/ explanation_matrix();
float f_cycle(float);
float f_rectangle(float, float);
float f_right_triangle(float, float);
float f_square(float);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, ...);
int f_calculate(int i) {
  i = 0;
  int a_num;
  float b_num = 0;
  float c_num = 0;
  float res_num = 0;
  explanation_matrix();
  printf("Enter your selection: ");
  if (scanf("%d", &a_num) == 1) {
    clear_scanf();
    if (a_num == 1) {
      printf("\n-Square's perimeter calculation.\n");
      printf("Be careful a square's side dimension can't be <=0.\n\n");
      printf("Input the square's side dimension : ");
      scanf("%f", &b_num);
      if (b_num > 0) {
        res_num = f_square(b_num);
        printf("|--------------------------------------------------------|\n");
        printf("  Square's perimeter = %f\n                               \n",
               res_num);
        printf("|--------------------------------------------------------|\n");
      } else {
        error_show();
      }
    } else if (a_num == 2) {
      printf("\n-Rectangle's perimeter calculation.\n");
      printf("Be careful a rectangle's side dimension can't be <=0.\n\n");
      printf("Input the rectangle's side A  dimension : ");
      scanf("%f", &b_num);
      printf("\n");
      printf("Input the rectangle's side B  dimension : ");
      scanf("%f", &c_num);
      if (b_num > 0 && c_num > 0) {
        res_num = f_rectangle(b_num, c_num);
        printf("|--------------------------------------------------------|\n");
        printf("  Rectangle's perimeter = %f\n                            \n",
               res_num);
        printf("|--------------------------------------------------------|\n");
      } else {
        error_show();
      }
    } else if (a_num == 3) {
      printf("\n-Right triangle's perimeter calculation.\n");
      printf("Be careful a right triangle's side dimension can't be <=0.\n\n");
      printf("Input the right triangle's side  A  dimension (vertical | ): ");
      scanf("%f", &b_num);
      printf("\n");
      printf("Input the right triangle's side  B  dimension (horizontal _ ): ");
      scanf("%f", &c_num);
      if (b_num > 0 && c_num > 0) {
        res_num = f_right_triangle(b_num, c_num);
        printf("|--------------------------------------------------------|\n");
        printf("  Right triangle's perimeter = %f\n                       \n",
               res_num);
        printf("|--------------------------------------------------------|\n");
      } else {
        error_show();
      }
    } else if (a_num == 4) {
      printf("\n-Cycle's perimeter calculation.\n");
      printf("Be careful a cycles's radius dimension can't be <=0.\n\n");
      printf("Input the cycles's radius : ");
      scanf("%f", &b_num);
      if (b_num > 0) {
        res_num = f_cycle(b_num);
        printf("|--------------------------------------------------------|\n");
        printf("  Cycle's perimeter = %f\n                               \n",
               res_num);
        printf("|--------------------------------------------------------|\n");
      } else {
        error_show();
      }
    } else if (a_num == 0) {
      printf("Thanks for using this program\n");
      printf("EAP / exercise 1 / theme 2\n");
      i = -1;
    } else {
      printf("\n2. Error on selection! Use only Numbers from 0 to 4. Please "
             "try again\n");
    }
  } else {
    error_show();
  }
  return i;
}


x86 assembly (clang, -O0):
<f_calculate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    $0x0,%al
call   1090 <explanation_matrix@plt>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe41(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    157a <f_calculate+0x3ea>
mov    $0x0,%al
call   1050 <clear_scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    129b <f_calculate+0x10b>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe6b(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    128f <f_calculate+0xff>
movss  -0xc(%rbp),%xmm0
call   10a0 <f_square@plt>
movss  %xmm0,-0x14(%rbp)
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe61(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1296 <f_calculate+0x106>
mov    $0x0,%al
call   1030 <error_show@plt>
jmp    1575 <f_calculate+0x3e5>
cmpl   $0x2,-0x8(%rbp)
jne    1389 <f_calculate+0x1f9>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdc1(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xf7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd93(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    137d <f_calculate+0x1ed>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    137d <f_calculate+0x1ed>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   1060 <f_rectangle@plt>
movss  %xmm0,-0x14(%rbp)
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe62(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xd29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1384 <f_calculate+0x1f4>
mov    $0x0,%al
call   1030 <error_show@plt>
jmp    1570 <f_calculate+0x3e0>
cmpl   $0x3,-0x8(%rbp)
jne    1477 <f_calculate+0x2e7>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcd3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xca5(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    146b <f_calculate+0x2db>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    146b <f_calculate+0x2db>
movss  -0xc(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
call   10b0 <f_right_triangle@plt>
movss  %xmm0,-0x14(%rbp)
lea    0xc60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe95(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xc3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1472 <f_calculate+0x2e2>
mov    $0x0,%al
call   1030 <error_show@plt>
jmp    156b <f_calculate+0x3db>
cmpl   $0x4,-0x8(%rbp)
jne    1521 <f_calculate+0x391>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xbe5(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
movss  -0xc(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1515 <f_calculate+0x385>
movss  -0xc(%rbp),%xmm0
call   1080 <f_cycle@plt>
movss  %xmm0,-0x14(%rbp)
lea    0xbb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    151c <f_calculate+0x38c>
mov    $0x0,%al
call   1030 <error_show@plt>
jmp    1566 <f_calculate+0x3d6>
cmpl   $0x0,-0x8(%rbp)
jne    1553 <f_calculate+0x3c3>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1561 <f_calculate+0x3d1>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1566 <f_calculate+0x3d6>
jmp    156b <f_calculate+0x3db>
jmp    1570 <f_calculate+0x3e0>
jmp    1575 <f_calculate+0x3e5>
jmp    1581 <f_calculate+0x3f1>
mov    $0x0,%al
call   1030 <error_show@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_calculate>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <explanation_matrix@plt>
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe46(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
cmp    $0x1,%eax
jne    14ae <f_calculate+0x2fe>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <clear_scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x4,%rax
ja     14bf <f_calculate+0x30f>
lea    0xde8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1051(%rip),%rdi
call   1050 <puts@plt>
lea    0x1063(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%ebx
jmp    14b5 <f_calculate+0x305>
lea    0x1181(%rip),%rdi
call   1050 <puts@plt>
lea    0x1197(%rip),%rdi
call   1050 <puts@plt>
lea    0xdcc(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xde1(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    14ae <f_calculate+0x2fe>
call   10c0 <f_square@plt>
movss  %xmm0,0xc(%rsp)
lea    0x117f(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd9b(%rip),%rdi
jmp    149d <f_calculate+0x2ed>
lea    0x10a8(%rip),%rdi
call   1050 <puts@plt>
lea    0x10c1(%rip),%rdi
call   1050 <puts@plt>
lea    0xdb2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd64(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xdad(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jbe    14ae <f_calculate+0x2fe>
movss  0x10(%rsp),%xmm1
ucomiss %xmm2,%xmm1
jbe    14ae <f_calculate+0x2fe>
call   1080 <f_rectangle@plt>
movss  %xmm0,0xc(%rsp)
lea    0x10c9(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd76(%rip),%rdi
jmp    149d <f_calculate+0x2ed>
lea    0xf8c(%rip),%rdi
call   1050 <puts@plt>
lea    0xfaa(%rip),%rdi
call   1050 <puts@plt>
lea    0xd8d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcae(%rip),%r14
lea    0x8(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xd9b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
ucomiss %xmm2,%xmm0
jbe    14ae <f_calculate+0x2fe>
movss  0x10(%rsp),%xmm1
ucomiss %xmm2,%xmm1
jbe    14ae <f_calculate+0x2fe>
call   10d0 <f_right_triangle@plt>
movss  %xmm0,0xc(%rsp)
lea    0x1013(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd79(%rip),%rdi
jmp    149d <f_calculate+0x2ed>
lea    0xe82(%rip),%rdi
call   1050 <puts@plt>
lea    0xe97(%rip),%rdi
call   1050 <puts@plt>
lea    0xd93(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xbfb(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movss  0x8(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    14ae <f_calculate+0x2fe>
call   10a0 <f_cycle@plt>
movss  %xmm0,0xc(%rsp)
lea    0xf9d(%rip),%r14
mov    %r14,%rdi
call   1050 <puts@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd5b(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    %r14,%rdi
call   1050 <puts@plt>
jmp    14b5 <f_calculate+0x305>
xor    %eax,%eax
call   1030 <error_show@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd6c(%rip),%rdi
call   1050 <puts@plt>
jmp    14b5 <f_calculate+0x305>

LLVM IR (-O0):
@.str = [23 x i8] c"Enter your selection: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [35 x i8] c"\0A-Square's perimeter calculation.\0A\00"
@.str.3 = [53 x i8] c"Be careful a square's side dimension can't be <=0.\0A\0A\00"
@.str.4 = [37 x i8] c"Input the square's side dimension : \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [60 x i8] c"|--------------------------------------------------------|\0A\00"
@.str.7 = [59 x i8] c" Square's perimeter = %f\0A \0A\00"
@.str.8 = [38 x i8] c"\0A-Rectangle's perimeter calculation.\0A\00"
@.str.9 = [56 x i8] c"Be careful a rectangle's side dimension can't be <=0.\0A\0A\00"
@.str.10 = [43 x i8] c"Input the rectangle's side A dimension : \00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [43 x i8] c"Input the rectangle's side B dimension : \00"
@.str.13 = [59 x i8] c" Rectangle's perimeter = %f\0A \0A\00"
@.str.14 = [43 x i8] c"\0A-Right triangle's perimeter calculation.\0A\00"
@.str.15 = [61 x i8] c"Be careful a right triangle's side dimension can't be <=0.\0A\0A\00"
@.str.16 = [62 x i8] c"Input the right triangle's side A dimension (vertical | ): \00"
@.str.17 = [64 x i8] c"Input the right triangle's side B dimension (horizontal _ ): \00"
@.str.18 = [59 x i8] c" Right triangle's perimeter = %f\0A \0A\00"
@.str.19 = [34 x i8] c"\0A-Cycle's perimeter calculation.\0A\00"
@.str.20 = [55 x i8] c"Be careful a cycles's radius dimension can't be <=0.\0A\0A\00"
@.str.21 = [29 x i8] c"Input the cycles's radius : \00"
@.str.22 = [58 x i8] c" Cycle's perimeter = %f\0A \0A\00"
@.str.23 = [31 x i8] c"Thanks for using this program\0A\00"
@.str.24 = [28 x i8] c"EAP / exercise 1 / theme 2\0A\00"
@.str.25 = [72 x i8] c"\0A2. Error on selection! Use only Numbers from 0 to 4. Please try again\0A\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 %0, i32* %2
store i32 0, i32* %2
store float 0.000000e+00, float* %4
store float 0.000000e+00, float* %5
store float 0.000000e+00, float* %6
%7 = call i32 (...) @explanation_matrix()
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %123
11: ; preds = %1
%12 = call i32 (...) @clear_scanf()
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%20 = load float, float* %4
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %30
22: ; preds = %15
%23 = load float, float* %4
%24 = call float @f_square(float %23)
store float %24, float* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%26 = load float, float* %6
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), double %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %32
30: ; preds = %15
%31 = call i32 (...) @error_show()
br label %32
32: ; preds = %30, %22
br label %122
33: ; preds = %11
%34 = load i32, i32* %3
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %61
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0))
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
%43 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %5)
%44 = load float, float* %4
%45 = fcmp ogt float %44, 0.000000e+00
br i1 %45, label %46, label %58
46: ; preds = %36
%47 = load float, float* %5
%48 = fcmp ogt float %47, 0.000000e+00
br i1 %48, label %49, label %58
49: ; preds = %46
%50 = load float, float* %4
%51 = load float, float* %5
%52 = call float @f_rectangle(float %50, float %51)
store float %52, float* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%54 = load float, float* %6
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.13, i64 0, i64 0), double %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %60
58: ; preds = %46, %36
%59 = call i32 (...) @error_show()
br label %60
60: ; preds = %58, %49
br label %121
61: ; preds = %33
%62 = load i32, i32* %3
%63 = icmp eq i32 %62, 3
br i1 %63, label %64, label %89
64: ; preds = %61
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0))
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.15, i64 0, i64 0))
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.16, i64 0, i64 0))
%68 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.17, i64 0, i64 0))
%71 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %5)
%72 = load float, float* %4
%73 = fcmp ogt float %72, 0.000000e+00
br i1 %73, label %74, label %86
74: ; preds = %64
%75 = load float, float* %5
%76 = fcmp ogt float %75, 0.000000e+00
br i1 %76, label %77, label %86
77: ; preds = %74
%78 = load float, float* %4
%79 = load float, float* %5
%80 = call float @f_right_triangle(float %78, float %79)
store float %80, float* %6
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%82 = load float, float* %6
%83 = fpext float %82 to double
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.18, i64 0, i64 0), double %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %88
86: ; preds = %74, %64
%87 = call i32 (...) @error_show()
br label %88
88: ; preds = %86, %77
br label %120
89: ; preds = %61
%90 = load i32, i32* %3
%91 = icmp eq i32 %90, 4
br i1 %91, label %92, label %110
92: ; preds = %89
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.19, i64 0, i64 0))
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.20, i64 0, i64 0))
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0))
%96 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%97 = load float, float* %4
%98 = fcmp ogt float %97, 0.000000e+00
br i1 %98, label %99, label %107
99: ; preds = %92
%100 = load float, float* %4
%101 = call float @f_cycle(float %100)
store float %101, float* %6
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
%103 = load float, float* %6
%104 = fpext float %103 to double
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.22, i64 0, i64 0), double %104)
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %109
107: ; preds = %92
%108 = call i32 (...) @error_show()
br label %109
109: ; preds = %107, %99
br label %119
110: ; preds = %89
%111 = load i32, i32* %3
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.23, i64 0, i64 0))
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.24, i64 0, i64 0))
store i32 -1, i32* %2
br label %118
116: ; preds = %110
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.25, i64 0, i64 0))
br label %118
118: ; preds = %116, %113
br label %119
119: ; preds = %118, %109
br label %120
120: ; preds = %119, %88
br label %121
121: ; preds = %120, %60
br label %122
122: ; preds = %121, %32
br label %125
123: ; preds = %1
%124 = call i32 (...) @error_show()
br label %125
125: ; preds = %123, %122
%126 = load i32, i32* %2
ret i32 %126
}

LLVM IR (-O2):
@.str = [23 x i8] c"Enter your selection: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [37 x i8] c"Input the square's side dimension : \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.7 = [59 x i8] c" Square's perimeter = %f\0A \0A\00"
@.str.10 = [43 x i8] c"Input the rectangle's side A dimension : \00"
@.str.12 = [43 x i8] c"Input the rectangle's side B dimension : \00"
@.str.13 = [59 x i8] c" Rectangle's perimeter = %f\0A \0A\00"
@.str.16 = [62 x i8] c"Input the right triangle's side A dimension (vertical | ): \00"
@.str.17 = [64 x i8] c"Input the right triangle's side B dimension (horizontal _ ): \00"
@.str.18 = [59 x i8] c" Right triangle's perimeter = %f\0A \0A\00"
@.str.21 = [29 x i8] c"Input the cycles's radius : \00"
@.str.22 = [58 x i8] c" Cycle's perimeter = %f\0A \0A\00"
@str = [71 x i8] c"\0A2. Error on selection! Use only Numbers from 0 to 4. Please try again\00"
@str.26 = [30 x i8] c"Thanks for using this program\00"
@str.27 = [27 x i8] c"EAP / exercise 1 / theme 2\00"
@str.28 = [33 x i8] c"\0A-Cycle's perimeter calculation.\00"
@str.29 = [54 x i8] c"Be careful a cycles's radius dimension can't be <=0.\0A\00"
@str.32 = [42 x i8] c"\0A-Right triangle's perimeter calculation.\00"
@str.33 = [60 x i8] c"Be careful a right triangle's side dimension can't be <=0.\0A\00"
@str.36 = [37 x i8] c"\0A-Rectangle's perimeter calculation.\00"
@str.37 = [55 x i8] c"Be careful a rectangle's side dimension can't be <=0.\0A\00"
@str.40 = [34 x i8] c"\0A-Square's perimeter calculation.\00"
@str.41 = [52 x i8] c"Be careful a square's side dimension can't be <=0.\0A\00"
@str.43 = [59 x i8] c"|--------------------------------------------------------|\00"
define i32 @f_calculate(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = bitcast i32* %2 to i8*
%6 = bitcast float* %3 to i8*
store float 0.000000e+00, float* %3
%7 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%8 = tail call i32 (...) @explanation_matrix()
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %92
12: ; preds = %1
%13 = call i32 (...) @clear_scanf()
%14 = load i32, i32* %2
switch i32 %14, label %90 [
i32 1, label %15
i32 2, label %30
i32 3, label %51
i32 4, label %72
i32 0, label %87
]
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.40, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.41, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%20 = load float, float* %3
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %28
22: ; preds = %15
%23 = call float @f_square(float %20)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
%25 = fpext float %23 to double
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), double %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
br label %94
28: ; preds = %15
%29 = call i32 (...) @error_show()
br label %94
30: ; preds = %12
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.36, i64 0, i64 0))
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.37, i64 0, i64 0))
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.10, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%35 = call i32 @putchar(i32 10)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%38 = load float, float* %3
%39 = fcmp ogt float %38, 0.000000e+00
%40 = load float, float* %4
%41 = fcmp ogt float %40, 0.000000e+00
%42 = select i1 %39, i1 %41, i1 false
br i1 %42, label %43, label %49
43: ; preds = %30
%44 = call float @f_rectangle(float %38, float %40)
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
%46 = fpext float %44 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.13, i64 0, i64 0), double %46)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
br label %94
49: ; preds = %30
%50 = call i32 (...) @error_show()
br label %94
51: ; preds = %12
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.32, i64 0, i64 0))
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.33, i64 0, i64 0))
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.16, i64 0, i64 0))
%55 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%56 = call i32 @putchar(i32 10)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.17, i64 0, i64 0))
%58 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%59 = load float, float* %3
%60 = fcmp ogt float %59, 0.000000e+00
%61 = load float, float* %4
%62 = fcmp ogt float %61, 0.000000e+00
%63 = select i1 %60, i1 %62, i1 false
br i1 %63, label %64, label %70
64: ; preds = %51
%65 = call float @f_right_triangle(float %59, float %61)
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
%67 = fpext float %65 to double
%68 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.18, i64 0, i64 0), double %67)
%69 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
br label %94
70: ; preds = %51
%71 = call i32 (...) @error_show()
br label %94
72: ; preds = %12
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.28, i64 0, i64 0))
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.29, i64 0, i64 0))
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.21, i64 0, i64 0))
%76 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%77 = load float, float* %3
%78 = fcmp ogt float %77, 0.000000e+00
br i1 %78, label %79, label %85
79: ; preds = %72
%80 = call float @f_cycle(float %77)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
%82 = fpext float %80 to double
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.22, i64 0, i64 0), double %82)
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.43, i64 0, i64 0))
br label %94
85: ; preds = %72
%86 = call i32 (...) @error_show()
br label %94
87: ; preds = %12
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.26, i64 0, i64 0))
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.27, i64 0, i64 0))
br label %94
90: ; preds = %12
%91 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str, i64 0, i64 0))
br label %94
92: ; preds = %1
%93 = call i32 (...) @error_show()
br label %94
94: ; preds = %28, %22, %70, %64, %87, %90, %79, %85, %43, %49, %92
%95 = phi i32 [ 0, %22 ], [ 0, %28 ], [ 0, %43 ], [ 0, %49 ], [ 0, %64 ], [ 0, %70 ], [ 0, %79 ], [ 0, %85 ], [ -1, %87 ], [ 0, %90 ], [ 0, %92 ]
ret i32 %95
}