#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int sscanf(char *, char *, double *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int get_valerr(double *val, double *dval, char *valdef) {
  int readok = 0;
  int nget = 0;
  char line[100];
  readok = 0;
  printf("\nEnter value and optional error for the %s:  ", valdef);
  while (readok == 0) {
    fgets(line, 100, stdin);
    switch (sscanf(line, "%lf %lf", val, dval)) {
    case 1:
      if (*val < 0.0) {
        fprintf(stderr, "ERROR: improper input.  Enter value(s) again:  ");
        break;
      } else {
        readok = 1;
        nget = 1;
        break;
      }
    case 2:
      if (*val < 0.0 || *dval < 0.0) {
        fprintf(stderr, "ERROR: improper input.  Enter value(s) again:  ");
        break;
      } else {
        readok = 1;
        nget = 2;
        break;
      }
    default:
      fprintf(stderr, "ERROR: improper input.  Enter value(s) again:  ");
    }
  }
  return nget;
}


x86 assembly (clang, -O0):
<get_valerr>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1293 <get_valerr+0x153>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
lea    -0x90(%rbp),%rdi
mov    %rdi,-0xa0(%rbp)
mov    $0x64,%esi
call   1040 <fgets@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe71(%rip),%rsi
call   1060 <sscanf@plt>
mov    %eax,%ecx
mov    %ecx,-0x94(%rbp)
sub    $0x1,%eax
je     11ec <get_valerr+0xac>
jmp    11d8 <get_valerr+0x98>
mov    -0x94(%rbp),%eax
sub    $0x2,%eax
je     122a <get_valerr+0xea>
jmp    1279 <get_valerr+0x139>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1217 <get_valerr+0xd7>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
jmp    128e <get_valerr+0x14e>
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    128e <get_valerr+0x14e>
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
ja     124c <get_valerr+0x10c>
mov    -0x10(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1266 <get_valerr+0x126>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   1050 <fprintf@plt>
jmp    128e <get_valerr+0x14e>
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
jmp    128e <get_valerr+0x14e>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
call   1050 <fprintf@plt>
jmp    117c <get_valerr+0x3c>
mov    -0x20(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_valerr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xead(%rip),%rdi
mov    %rdx,%rsi
call   1030 <printf@plt>
mov    %rsp,%r15
lea    0xec9(%rip),%r12
mov    0x2e64(%rip),%rbp
lea    0xec3(%rip),%r13
jmp    118b <get_valerr+0x4b>
nopl   (%rax)
mov    0x0(%rbp),%edi
mov    %r13,%rsi
call   1050 <fprintf@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    $0x64,%esi
call   1040 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <sscanf@plt>
cmp    $0x2,%eax
je     11d0 <get_valerr+0x90>
cmp    $0x1,%eax
jne    1180 <get_valerr+0x40>
xorpd  %xmm0,%xmm0
ucomisd (%rbx),%xmm0
ja     1180 <get_valerr+0x40>
jmp    11ec <get_valerr+0xac>
nopl   0x0(%rax,%rax,1)
xorpd  %xmm0,%xmm0
ucomisd (%rbx),%xmm0
ja     1180 <get_valerr+0x40>
xorpd  %xmm0,%xmm0
ucomisd (%r14),%xmm0
ja     1180 <get_valerr+0x40>
mov    $0x2,%eax
jmp    11f1 <get_valerr+0xb1>
mov    $0x1,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"\0AEnter value and optional error for the %s: \00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"%lf %lf\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"ERROR: improper input. Enter value(s) again: \00"
define i32 @get_valerr(double* %0, double* %1, i8* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca [100 x i8]
store double* %0, double** %4
store double* %1, double** %5
store i8* %2, i8** %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %7
%10 = load i8*, i8** %6
%11 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %46, %3
%13 = load i32, i32* %7
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %47
15: ; preds = %12
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %16, i32 100, i32 %17)
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%20 = load double*, double** %4
%21 = load double*, double** %5
%22 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %20, double* %21)
switch i32 %22, label %43 [
i32 1, label %23
i32 2, label %31
]
23: ; preds = %15
%24 = load double*, double** %4
%25 = load double, double* %24
%26 = fcmp olt double %25, 0.000000e+00
br i1 %26, label %27, label %30
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %46
30: ; preds = %23
store i32 1, i32* %7
store i32 1, i32* %8
br label %46
31: ; preds = %15
%32 = load double*, double** %4
%33 = load double, double* %32
%34 = fcmp olt double %33, 0.000000e+00
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load double*, double** %5
%37 = load double, double* %36
%38 = fcmp olt double %37, 0.000000e+00
br i1 %38, label %39, label %42
39: ; preds = %35, %31
%40 = load i32, i32* @stderr
%41 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %46
42: ; preds = %35
store i32 1, i32* %7
store i32 2, i32* %8
br label %46
43: ; preds = %15
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %46
46: ; preds = %43, %42, %39, %30, %27
br label %12
47: ; preds = %12
%48 = load i32, i32* %8
ret i32 %48
}

LLVM IR (-O2):
@.str = [46 x i8] c"\0AEnter value and optional error for the %s: \00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"%lf %lf\00"
@stderr = global i32 0
@.str.2 = [48 x i8] c"ERROR: improper input. Enter value(s) again: \00"
define i32 @get_valerr(double* %0, double* %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %7
7: ; preds = %20, %3
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %5, i32 100, i32 %8)
%10 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double* %0, double* %1)
switch i32 %10, label %20 [
i32 1, label %11
i32 2, label %14
]
11: ; preds = %7
%12 = load double, double* %0
%13 = fcmp olt double %12, 0.000000e+00
br i1 %13, label %20, label %23
14: ; preds = %7
%15 = load double, double* %0
%16 = fcmp olt double %15, 0.000000e+00
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load double, double* %1
%19 = fcmp olt double %18, 0.000000e+00
br i1 %19, label %20, label %23
20: ; preds = %7, %14, %17, %11
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.2, i64 0, i64 0))
br label %7
23: ; preds = %17, %11
%24 = phi i32 [ 1, %11 ], [ 2, %17 ]
ret i32 %24
}