#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 f_calculate(int);
int /*<<< orphan*/ printf(char *);
main() {
  int i = 0;
  printf("-------------------------------------------------------|\n");
  printf("|Perimeter Calculation Program                         |\n");
  printf("|The program calculates the perimeter of square,       |\n");
  printf("|rectangle, right triangle and cycle.                  |\n");
  printf("|Use:                                                  |\n");
  printf("|Select a number indicating the shape's perimeter      |\n");
  printf("|you want to calculate and input the proper dimensions.|\n");
  printf("|Select 0 to exit the program.                         |\n");
  printf("|------------------------------------------------------|\n");
  printf("\n");
  printf("\n");
  while (i == 0) {
    int ret;
    ret = f_calculate(i);
    i = ret;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf4d(%rip),%rdi
call   1030 <printf@plt>
lea    0xf7b(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa9(%rip),%rdi
call   1030 <printf@plt>
lea    0xfd7(%rip),%rdi
call   1030 <printf@plt>
lea    0x1005(%rip),%rdi
call   1030 <printf@plt>
lea    0x1033(%rip),%rdi
call   1030 <printf@plt>
lea    0xf77(%rip),%rdi
call   1030 <printf@plt>
lea    0xf6b(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    11da <main+0xba>
mov    -0x8(%rbp),%edi
call   1040 <f_calculate@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11ba <main+0x9a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
lea    0xef5(%rip),%rdi
call   1040 <puts@plt>
lea    0xf22(%rip),%rdi
call   1040 <puts@plt>
lea    0xf4f(%rip),%rdi
call   1040 <puts@plt>
lea    0xf7c(%rip),%rdi
call   1040 <puts@plt>
lea    0xfa9(%rip),%rdi
call   1040 <puts@plt>
lea    0xfd6(%rip),%rdi
call   1040 <puts@plt>
lea    0x1003(%rip),%rdi
call   1040 <puts@plt>
lea    0x1030(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
call   1050 <f_calculate@plt>
test   %eax,%eax
je     11c0 <main+0x90>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [58 x i8] c"-------------------------------------------------------|\0A\00"
@.str.1 = [58 x i8] c"|Perimeter Calculation Program |\0A\00"
@.str.2 = [58 x i8] c"|The program calculates the perimeter of square, |\0A\00"
@.str.3 = [58 x i8] c"|rectangle, right triangle and cycle. |\0A\00"
@.str.4 = [58 x i8] c"|Use: |\0A\00"
@.str.5 = [58 x i8] c"|Select a number indicating the shape's perimeter |\0A\00"
@.str.6 = [58 x i8] c"|you want to calculate and input the proper dimensions.|\0A\00"
@.str.7 = [58 x i8] c"|Select 0 to exit the program. |\0A\00"
@.str.8 = [58 x i8] c"|------------------------------------------------------|\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.8, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %15
15: ; preds = %18, %0
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %2
%20 = call i32 @f_calculate(i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
store i32 %21, i32* %2
br label %15
22: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@str = [57 x i8] c"-------------------------------------------------------|\00"
@str.10 = [57 x i8] c"|Perimeter Calculation Program |\00"
@str.11 = [57 x i8] c"|The program calculates the perimeter of square, |\00"
@str.12 = [57 x i8] c"|rectangle, right triangle and cycle. |\00"
@str.13 = [57 x i8] c"|Use: |\00"
@str.14 = [57 x i8] c"|Select a number indicating the shape's perimeter |\00"
@str.15 = [57 x i8] c"|you want to calculate and input the proper dimensions.|\00"
@str.16 = [57 x i8] c"|Select 0 to exit the program. |\00"
@str.17 = [57 x i8] c"|------------------------------------------------------|\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.10, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.11, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.12, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.13, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.14, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.15, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.16, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.17, i64 0, i64 0))
%10 = tail call i32 @putchar(i32 10)
%11 = tail call i32 @putchar(i32 10)
br label %12
12: ; preds = %0, %12
%13 = tail call i32 @f_calculate(i32 0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %12, label %15
15: ; preds = %12
ret i32 0
}