#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*/ printf(char *);
int scanf(char *, double *);
void inputSides(double sidesArr[], int arrLength) {
  int i = 0;
  double input = 0.0;
  for (i = 0; i < arrLength;) {
    int returnSuccessful = 0;
    char c;
    printf("Please enter a numeric length.\n");
    if (i > 0) {
      while ((c = getchar()) != '\n' && c != EOF) {
      }
    }
    returnSuccessful = scanf("%lf", &input);
    if (returnSuccessful == 1) {
      if (input > 0) {
        sidesArr[i] = input;
        i++;
      }
      if (input <= 0) {
        printf("Oops! A length must be positive. ");
      }
    }
    if (returnSuccessful < 1) {
      while ((c = getchar()) != '\n' && c != EOF) {
      }
      printf("Invalid input. ");
    }
  }
}


x86 assembly (clang, -O0):
<inputSides>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    129d <inputSides+0x16d>
movl   $0x0,-0x1c(%rbp)
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jle    11ce <inputSides+0x9e>
jmp    1183 <inputSides+0x53>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1e(%rbp)
je     11b4 <inputSides+0x84>
movsbl -0x1d(%rbp),%eax
mov    0x2e3f(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%al
test   $0x1,%al
jne    11c4 <inputSides+0x94>
jmp    11c9 <inputSides+0x99>
jmp    1183 <inputSides+0x53>
jmp    11ce <inputSides+0x9e>
lea    0xe4b(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1237 <inputSides+0x107>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1218 <inputSides+0xe8>
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     1232 <inputSides+0x102>
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
jmp    1237 <inputSides+0x107>
cmpl   $0x1,-0x1c(%rbp)
jge    1298 <inputSides+0x168>
jmp    1246 <inputSides+0x116>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x1f(%rbp)
je     1277 <inputSides+0x147>
movsbl -0x1d(%rbp),%eax
mov    0x2d7c(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x1f(%rbp)
mov    -0x1f(%rbp),%al
test   $0x1,%al
jne    1287 <inputSides+0x157>
jmp    128c <inputSides+0x15c>
jmp    1246 <inputSides+0x116>
lea    0xdb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1155 <inputSides+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputSides>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x10(%rsp)
movq   $0x0,0x8(%rsp)
test   %esi,%esi
jle    1239 <inputSides+0xf9>
mov    %esi,%ebx
lea    0xed1(%rip),%r15
mov    0x2e74(%rip),%rbp
lea    0xe8d(%rip),%r12
lea    0x8(%rsp),%r13
xor    %r14d,%r14d
jmp    119a <inputSides+0x5a>
lea    0xea2(%rip),%rdi
call   1040 <printf@plt>
cmp    %ebx,%r14d
jge    1239 <inputSides+0xf9>
mov    %r15,%rdi
call   1030 <puts@plt>
test   %r14d,%r14d
jle    11c0 <inputSides+0x80>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     11c0 <inputSides+0x80>
cmp    0x0(%rbp),%al
jne    11b0 <inputSides+0x70>
mov    %r12,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1210 <inputSides+0xd0>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe22(%rip),%xmm0
jbe    11f1 <inputSides+0xb1>
movslq %r14d,%rax
mov    0x10(%rsp),%rcx
movsd  %xmm0,(%rcx,%rax,8)
add    $0x1,%r14d
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
lea    0xe0c(%rip),%rdi
jae    118c <inputSides+0x4c>
jmp    1191 <inputSides+0x51>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
jge    1191 <inputSides+0x51>
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
je     1185 <inputSides+0x45>
cmp    0x0(%rbp),%al
jne    1220 <inputSides+0xe0>
jmp    1185 <inputSides+0x45>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Please enter a numeric length.\0A\00"
@EOF = global i8 0
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [34 x i8] c"Oops! A length must be positive. \00"
@.str.3 = [16 x i8] c"Invalid input. \00"
define void @inputSides(double* %0, i32 %1) {
%3 = alloca double*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca i32
%8 = alloca i8
store double* %0, double** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store double 0.000000e+00, double* %6
store i32 0, i32* %5
br label %9
9: ; preds = %72, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %73
13: ; preds = %9
store i32 0, i32* %7
%14 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %32
17: ; preds = %13
br label %18
18: ; preds = %30, %17
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %8
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i8, i8* %8
%24 = sext i8 %23 to i32
%25 = load i8, i8* @EOF
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %24, %26
br label %28
28: ; preds = %22, %18
%29 = phi i1 [ false, %18 ], [ %27, %22 ]
br i1 %29, label %30, label %31
30: ; preds = %28
br label %18
31: ; preds = %28
br label %32
32: ; preds = %31, %13
%33 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %6)
store i32 %33, i32* %7
%34 = load i32, i32* %7
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %53
36: ; preds = %32
%37 = load double, double* %6
%38 = fcmp ogt double %37, 0.000000e+00
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load double, double* %6
%41 = load double*, double** %3
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %40, double* %44
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %47
47: ; preds = %39, %36
%48 = load double, double* %6
%49 = fcmp ole double %48, 0.000000e+00
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %47
br label %53
53: ; preds = %52, %32
%54 = load i32, i32* %7
%55 = icmp slt i32 %54, 1
br i1 %55, label %56, label %72
56: ; preds = %53
br label %57
57: ; preds = %69, %56
%58 = call signext i8 (...) @getchar()
store i8 %58, i8* %8
%59 = sext i8 %58 to i32
%60 = icmp ne i32 %59, 10
br i1 %60, label %61, label %67
61: ; preds = %57
%62 = load i8, i8* %8
%63 = sext i8 %62 to i32
%64 = load i8, i8* @EOF
%65 = sext i8 %64 to i32
%66 = icmp ne i32 %63, %65
br label %67
67: ; preds = %61, %57
%68 = phi i1 [ false, %57 ], [ %66, %61 ]
br i1 %68, label %69, label %70
69: ; preds = %67
br label %57
70: ; preds = %67
%71 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %72
72: ; preds = %70, %53
br label %9
73: ; preds = %9
ret void
}

LLVM IR (-O2):
@EOF = global i8 0
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [34 x i8] c"Oops! A length must be positive. \00"
@.str.3 = [16 x i8] c"Invalid input. \00"
@str = [31 x i8] c"Please enter a numeric length.\00"
define void @inputSides(double* nocapture writeonly %0, i32 %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %44
6: ; preds = %2, %41
%7 = phi i32 [ %42, %41 ], [ 0, %2 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %16
10: ; preds = %6, %10
%11 = call signext i8 (...) @getchar()
%12 = icmp ne i8 %11, 10
%13 = load i8, i8* @EOF
%14 = icmp ne i8 %11, %13
%15 = select i1 %12, i1 %14, i1 false
br i1 %15, label %10, label %16
16: ; preds = %10, %6
%17 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %29
19: ; preds = %16
%20 = load double, double* %3
%21 = fcmp ogt double %20, 0.000000e+00
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = sext i32 %7 to i64
%24 = getelementptr inbounds double, double* %0, i64 %23
store double %20, double* %24
%25 = add nsw i32 %7, 1
br label %26
26: ; preds = %22, %19
%27 = phi i32 [ %25, %22 ], [ %7, %19 ]
%28 = fcmp ugt double %20, 0.000000e+00
br i1 %28, label %41, label %37
29: ; preds = %16
%30 = icmp slt i32 %17, 1
br i1 %30, label %31, label %41
31: ; preds = %29, %31
%32 = call signext i8 (...) @getchar()
%33 = icmp ne i8 %32, 10
%34 = load i8, i8* @EOF
%35 = icmp ne i8 %32, %34
%36 = select i1 %33, i1 %35, i1 false
br i1 %36, label %31, label %37
37: ; preds = %31, %26
%38 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), %26 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), %31 ]
%39 = phi i32 [ %27, %26 ], [ %7, %31 ]
%40 = call i32 @printf(i8* dereferenceable(1) %38)
br label %41
41: ; preds = %37, %26, %29
%42 = phi i32 [ %7, %29 ], [ %27, %26 ], [ %39, %37 ]
%43 = icmp slt i32 %42, %1
br i1 %43, label %6, label %44
44: ; preds = %41, %2
ret void
}