#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 */
char EOF;
char getchar();
int /*<<< orphan*/ inputSides(double *, int);
int /*<<< orphan*/ printTriangleArea(int /*<<< orphan*/);
int /*<<< orphan*/ printTriangleSides(double *);
int /*<<< orphan*/ printTriangleType(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ triangleArea(double *);
int triangleSidesCheck(double *);
int /*<<< orphan*/ triangleType(double *);
void triangleTest() {
  char response[512] = {'y'};
  printf("Welcome. Let's test some triangles, shall we?\n");
  while ((response[0] == 'y') || (response[0] == 'Y')) {
    char c;
    double triangleSidesArr[3] = {0.0, 0.0, 0.0};
    inputSides(triangleSidesArr, 3);
    if (triangleSidesCheck(triangleSidesArr) == 3) {
      printf("Success! The lengths ");
      printTriangleSides(triangleSidesArr);
      printf(" can make a");
      printTriangleType(triangleType(triangleSidesArr));
      printf(" triangle with an approximate area of ");
      printTriangleArea(triangleArea(triangleSidesArr));
      printf(".\nWould you like to try again (Y/N)?\n");
    } else {
      printf("It is NOT possible to make a triangle with sides of length ");
      printTriangleSides(triangleSidesArr);
      printf(".\nWould you like to try again (Y/N)?\n");
    }
    while ((c = getchar()) != '\n' && c != EOF) {
    }
    scanf("%s", response);
  }
}


x86 assembly (clang, -O0):
<triangleTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
lea    -0x200(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1060 <memset@plt>
movb   $0x79,-0x200(%rbp)
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
movsbl -0x200(%rbp),%ecx
mov    $0x1,%al
cmp    $0x79,%ecx
mov    %al,-0x221(%rbp)
je     120c <triangleTest+0x5c>
movsbl -0x200(%rbp),%eax
cmp    $0x59,%eax
sete   %al
mov    %al,-0x221(%rbp)
mov    -0x221(%rbp),%al
test   $0x1,%al
jne    121f <triangleTest+0x6f>
jmp    1355 <triangleTest+0x1a5>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
lea    -0x220(%rbp),%rdi
mov    $0x3,%esi
call   10c0 <inputSides@plt>
lea    -0x220(%rbp),%rdi
call   1040 <triangleSidesCheck@plt>
cmp    $0x3,%eax
jne    12bf <triangleTest+0x10f>
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <printTriangleSides@plt>
lea    0xdce(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rdi
call   1080 <triangleType@plt>
mov    %eax,%edi
call   10b0 <printTriangleType@plt>
lea    0xdbb(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rdi
call   1070 <triangleArea@plt>
mov    %eax,%edi
call   1090 <printTriangleArea@plt>
lea    0xdc3(%rip),%rdi
call   1050 <printf@plt>
jmp    12e3 <triangleTest+0x133>
lea    0xdd8(%rip),%rdi
call   1050 <printf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <printTriangleSides@plt>
lea    0xd9a(%rip),%rdi
call   1050 <printf@plt>
jmp    12e8 <triangleTest+0x138>
mov    $0x0,%al
call   10a0 <getchar@plt>
mov    %al,-0x201(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x222(%rbp)
je     1325 <triangleTest+0x175>
movsbl -0x201(%rbp),%eax
mov    0x2cd1(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x222(%rbp)
mov    -0x222(%rbp),%al
test   $0x1,%al
jne    1338 <triangleTest+0x188>
jmp    133d <triangleTest+0x18d>
jmp    12e8 <triangleTest+0x138>
lea    -0x200(%rbp),%rsi
lea    0xd8f(%rip),%rdi
call   10d0 <scanf@plt>
jmp    11e1 <triangleTest+0x31>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<triangleTest>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x228,%rsp
lea    0x20(%rsp),%r14
mov    $0x200,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
movb   $0x79,0x20(%rsp)
lea    0xea7(%rip),%rdi
call   1050 <puts@plt>
mov    %rsp,%rbx
lea    0xec6(%rip),%rbp
mov    0x2de1(%rip),%r13
lea    0xe87(%rip),%r15
lea    0xe44(%rip),%r12
jmp    1239 <triangleTest+0x79>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   10e0 <scanf@plt>
mov    0x20(%rsp),%al
and    $0xdf,%al
cmp    $0x59,%al
jne    12ea <triangleTest+0x12a>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x10(%rsp)
mov    %rbx,%rdi
mov    $0x3,%esi
call   10d0 <inputSides@plt>
mov    %rbx,%rdi
call   1040 <triangleSidesCheck@plt>
cmp    $0x3,%eax
jne    12b0 <triangleTest+0xf0>
lea    0xda6(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <printTriangleSides@plt>
lea    0xda8(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1090 <triangleType@plt>
mov    %eax,%edi
call   10c0 <printTriangleType@plt>
lea    0xd99(%rip),%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1080 <triangleArea@plt>
mov    %eax,%edi
call   10a0 <printTriangleArea@plt>
jmp    12c0 <triangleTest+0x100>
nop
mov    %r12,%rdi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <printTriangleSides@plt>
mov    %rbp,%rdi
call   1050 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10b0 <getchar@plt>
cmp    $0xa,%al
je     1220 <triangleTest+0x60>
cmp    0x0(%r13),%al
jne    12d0 <triangleTest+0x110>
jmp    1220 <triangleTest+0x60>
add    $0x228,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Welcome. Let's test some triangles, shall we?\0A\00"
@.str.1 = [22 x i8] c"Success! The lengths \00"
@.str.2 = [12 x i8] c" can make a\00"
@.str.3 = [39 x i8] c" triangle with an approximate area of \00"
@.str.4 = [38 x i8] c".\0AWould you like to try again (Y/N)?\0A\00"
@.str.5 = [60 x i8] c"It is NOT possible to make a triangle with sides of length \00"
@EOF = global i8 0
@.str.6 = [3 x i8] c"%s\00"
define void @triangleTest() {
%1 = alloca [512 x i8]
%2 = alloca i8
%3 = alloca [3 x double]
%4 = bitcast [512 x i8]* %1 to i8*
%5 = bitcast i8* %4 to <{ i8, [511 x i8] }>*
%6 = getelementptr inbounds <{ i8, [511 x i8] }>, <{ i8, [511 x i8] }>* %5, i32 0, i32 0
store i8 121, i8* %6
%7 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %59, %0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 121
br i1 %12, label %18, label %13
13: ; preds = %8
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 89
br label %18
18: ; preds = %13, %8
%19 = phi i1 [ true, %8 ], [ %17, %13 ]
br i1 %19, label %20, label %62
20: ; preds = %18
%21 = bitcast [3 x double]* %3 to i8*
%22 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%23 = call i32 @inputSides(double* %22, i32 3)
%24 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%25 = call i32 @triangleSidesCheck(double* %24)
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %40
27: ; preds = %20
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%29 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%30 = call i32 @printTriangleSides(double* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%33 = call i32 @triangleType(double* %32)
%34 = call i32 @printTriangleType(i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%36 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%37 = call i32 @triangleArea(double* %36)
%38 = call i32 @printTriangleArea(i32 %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %45
40: ; preds = %20
%41 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%42 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
%43 = call i32 @printTriangleSides(double* %42)
%44 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %40, %27
br label %46
46: ; preds = %58, %45
%47 = call signext i8 (...) @getchar()
store i8 %47, i8* %2
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 10
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i8, i8* %2
%52 = sext i8 %51 to i32
%53 = load i8, i8* @EOF
%54 = sext i8 %53 to i32
%55 = icmp ne i32 %52, %54
br label %56
56: ; preds = %50, %46
%57 = phi i1 [ false, %46 ], [ %55, %50 ]
br i1 %57, label %58, label %59
58: ; preds = %56
br label %46
59: ; preds = %56
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %60)
br label %8
62: ; preds = %18
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Success! The lengths \00"
@.str.2 = [12 x i8] c" can make a\00"
@.str.3 = [39 x i8] c" triangle with an approximate area of \00"
@.str.5 = [60 x i8] c"It is NOT possible to make a triangle with sides of length \00"
@EOF = global i8 0
@.str.6 = [3 x i8] c"%s\00"
@str = [46 x i8] c"Welcome. Let's test some triangles, shall we?\00"
@str.8 = [37 x i8] c".\0AWould you like to try again (Y/N)?\00"
define void @triangleTest() {
%1 = alloca [512 x i8]
%2 = alloca [3 x double]
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
store i8 121, i8* %3
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%5 = bitcast [3 x double]* %2 to i8*
%6 = getelementptr inbounds [3 x double], [3 x double]* %2, i64 0, i64 0
br label %7
7: ; preds = %0, %32
%8 = call i32 @inputSides(double* %6, i32 3)
%9 = call i32 @triangleSidesCheck(double* %6)
%10 = icmp eq i32 %9, 3
br i1 %10, label %11, label %20
11: ; preds = %7
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printTriangleSides(double* %6)
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @triangleType(double* %6)
%16 = call i32 @printTriangleType(i32 %15)
%17 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @triangleArea(double* %6)
%19 = call i32 @printTriangleArea(i32 %18)
br label %23
20: ; preds = %7
%21 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @printTriangleSides(double* %6)
br label %23
23: ; preds = %20, %11
%24 = phi i8* [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0), %20 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0), %11 ]
%25 = call i32 @puts(i8* dereferenceable(1) %24)
br label %26
26: ; preds = %26, %23
%27 = call signext i8 (...) @getchar()
%28 = icmp ne i8 %27, 10
%29 = load i8, i8* @EOF
%30 = icmp ne i8 %27, %29
%31 = select i1 %28, i1 %30, i1 false
br i1 %31, label %26, label %32
32: ; preds = %26
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%34 = load i8, i8* %3
%35 = and i8 %34, -33
%36 = icmp eq i8 %35, 89
br i1 %36, label %7, label %37
37: ; preds = %32
ret void
}