#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();
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, float *, char *);
void inputPrice(const char *prompt, float price[], int i) {
  char endInput;
  int result = 0;
  int read;
  do {
    printf("%s", prompt);
    read = scanf("%f%c", &price[i], &endInput);
    if (read != 2) {
      printf("ERROR! Try Again!\n");
      result = 0;
      clear();
    } else if (endInput != '\n') {
      printf("ERROR! Try Again!\n");
      result = 0;
      clear();
    } else if (price[i] <= 0) {
      printf("ERROR! Try Again!\n");
      result = 0;
    } else
      result = 1;
  } while (result == 0);
}


x86 assembly (clang, -O0):
<inputPrice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe91(%rip),%rdi
lea    -0x15(%rbp),%rdx
call   1040 <scanf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
je     11a9 <inputPrice+0x79>
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clear@plt>
jmp    1217 <inputPrice+0xe7>
movsbl -0x15(%rbp),%eax
cmp    $0xa,%eax
je     11d7 <inputPrice+0xa7>
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clear@plt>
jmp    1212 <inputPrice+0xe2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
xorps  %xmm0,%xmm0
ucomiss (%rax,%rcx,4),%xmm0
jb     1206 <inputPrice+0xd6>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    120d <inputPrice+0xdd>
movl   $0x1,-0x1c(%rbp)
jmp    1212 <inputPrice+0xe2>
jmp    1217 <inputPrice+0xe7>
jmp    121c <inputPrice+0xec>
cmpl   $0x0,-0x1c(%rbp)
je     114a <inputPrice+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputPrice>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
movslq %edx,%rax
lea    (%rsi,%rax,4),%rbx
lea    0xea8(%rip),%r15
lea    0xea4(%rip),%r12
lea    0x7(%rsp),%r13
lea    0xe9d(%rip),%rbp
jmp    118f <inputPrice+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <clear@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1050 <scanf@plt>
cmp    $0x2,%eax
jne    1180 <inputPrice+0x40>
cmpb   $0xa,0x7(%rsp)
jne    1180 <inputPrice+0x40>
xorps  %xmm0,%xmm0
ucomiss (%rbx),%xmm0
jb     11c8 <inputPrice+0x88>
mov    %rbp,%rdi
call   1030 <puts@plt>
jmp    118f <inputPrice+0x4f>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%f%c\00"
@.str.2 = [19 x i8] c"ERROR! Try Again!\0A\00"
define void @inputPrice(i8* %0, float* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca float*
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store float* %1, float** %5
store i32 %2, i32* %6
store i32 0, i32* %8
br label %10
10: ; preds = %43, %3
%11 = load i8*, i8** %4
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load float*, float** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds float, float* %13, i64 %15
%17 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %16, i8* %7)
store i32 %17, i32* %9
%18 = load i32, i32* %9
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
%22 = call i32 (...) @clear()
br label %42
23: ; preds = %10
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 10
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
%29 = call i32 (...) @clear()
br label %41
30: ; preds = %23
%31 = load float*, float** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds float, float* %31, i64 %33
%35 = load float, float* %34
%36 = fcmp ole float %35, 0.000000e+00
br i1 %36, label %37, label %39
37: ; preds = %30
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %8
br label %40
39: ; preds = %30
store i32 1, i32* %8
br label %40
40: ; preds = %39, %37
br label %41
41: ; preds = %40, %27
br label %42
42: ; preds = %41, %20
br label %43
43: ; preds = %42
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, 0
br i1 %45, label %10, label %46
46: ; preds = %43
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%f%c\00"
@str.4 = [18 x i8] c"ERROR! Try Again!\00"
define void @inputPrice(i8* %0, float* %1, i32 %2) {
%4 = alloca i8
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds float, float* %1, i64 %5
br label %7
7: ; preds = %14, %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float* %6, i8* %4)
%10 = icmp eq i32 %9, 2
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%13 = call i32 (...) @clear()
br label %14
14: ; preds = %11, %24, %18
br label %7
15: ; preds = %7
%16 = load i8, i8* %4
%17 = icmp eq i8 %16, 10
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
%20 = call i32 (...) @clear()
br label %14
21: ; preds = %15
%22 = load float, float* %6
%23 = fcmp ugt float %22, 0.000000e+00
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.4, i64 0, i64 0))
br label %14
26: ; preds = %21
ret void
}