#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
double DBL_MAX;
double DBL_MIN;
int EOF;
int fscanf(int /*<<< orphan*/ *, char *, double *);
int /*<<< orphan*/ skipWord(int /*<<< orphan*/ *);
double bound(FILE *stream, bool upper_bound_p) {
  double lowerBound = DBL_MAX;
  double upperBound = DBL_MIN;
  double number = 0.;
  int test;
  while ((test = fscanf(stream, "%lf", &number)) != EOF) {
    if (!test)
      skipWord(stream);
    if (number > upperBound)
      upperBound = number;
    if (number < lowerBound)
      lowerBound = number;
  }
  return upper_bound_p ? upperBound : lowerBound;
}


x86 assembly (clang, -O0):
<bound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    0x2e8a(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9e(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1030 <fscanf@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2e73(%rip),%rcx
cmp    (%rcx),%eax
je     11cd <bound+0xad>
cmpl   $0x0,-0x2c(%rbp)
jne    1190 <bound+0x70>
mov    -0x8(%rbp),%rdi
call   1040 <skipWord@plt>
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11aa <bound+0x8a>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c8 <bound+0xa8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    1157 <bound+0x37>
cmpl   $0x0,-0xc(%rbp)
je     11e6 <bound+0xc6>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11f0 <bound+0xd0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bound>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e9f(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x2e86(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,0x8(%rsp)
movq   $0x0,0x18(%rsp)
lea    0xe9c(%rip),%rsi
lea    0x18(%rsp),%rdx
call   1030 <fscanf@plt>
mov    0x2e73(%rip),%r12
cmp    (%r12),%eax
jne    119d <bound+0x7d>
movsd  0x8(%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
test   %r14d,%r14d
je     1190 <bound+0x70>
movapd %xmm3,%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5c(%rip),%r15
lea    0x18(%rsp),%rbp
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
jmp    1206 <bound+0xe6>
nopw   0x0(%rax,%rax,1)
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm3
maxsd  %xmm1,%xmm3
movsd  %xmm3,0x10(%rsp)
minsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1030 <fscanf@plt>
movsd  0x10(%rsp),%xmm3
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
movapd %xmm3,%xmm1
cmp    (%r12),%eax
je     1187 <bound+0x67>
test   %eax,%eax
jne    11c0 <bound+0xa0>
mov    %rbx,%rdi
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1040 <skipWord@plt>
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
jmp    11c0 <bound+0xa0>

LLVM IR (-O0):
@DBL_MAX = global double 0.000000e+00
@DBL_MIN = global double 0.000000e+00
@.str = [4 x i8] c"%lf\00"
@EOF = global i32 0
define double @bound(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%9 = load double, double* @DBL_MAX
store double %9, double* %5
%10 = load double, double* @DBL_MIN
store double %10, double* %6
store double 0.000000e+00, double* %7
br label %11
11: ; preds = %34, %2
%12 = load i32*, i32** %3
%13 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %7)
store i32 %13, i32* %8
%14 = load i32, i32* @EOF
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %35
16: ; preds = %11
%17 = load i32, i32* %8
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32*, i32** %3
%21 = call i32 @skipWord(i32* %20)
br label %22
22: ; preds = %19, %16
%23 = load double, double* %7
%24 = load double, double* %6
%25 = fcmp ogt double %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = load double, double* %7
store double %27, double* %6
br label %28
28: ; preds = %26, %22
%29 = load double, double* %7
%30 = load double, double* %5
%31 = fcmp olt double %29, %30
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = load double, double* %7
store double %33, double* %5
br label %34
34: ; preds = %32, %28
br label %11
35: ; preds = %11
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load double, double* %6
br label %42
40: ; preds = %35
%41 = load double, double* %5
br label %42
42: ; preds = %40, %38
%43 = phi double [ %39, %38 ], [ %41, %40 ]
ret double %43
}

LLVM IR (-O2):
@DBL_MAX = global double 0.000000e+00
@DBL_MIN = global double 0.000000e+00
@.str = [4 x i8] c"%lf\00"
@EOF = global i32 0
define double @bound(i32* %0, i32 %1) {
%3 = alloca double
%4 = load double, double* @DBL_MAX
%5 = load double, double* @DBL_MIN
%6 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%7 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%8 = load i32, i32* @EOF
%9 = icmp eq i32 %7, %8
br i1 %9, label %26, label %10
10: ; preds = %2, %17
%11 = phi i32 [ %23, %17 ], [ %7, %2 ]
%12 = phi double [ %22, %17 ], [ %4, %2 ]
%13 = phi double [ %20, %17 ], [ %5, %2 ]
%14 = icmp eq i32 %11, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 @skipWord(i32* %0)
br label %17
17: ; preds = %15, %10
%18 = load double, double* %3
%19 = fcmp ogt double %18, %13
%20 = select i1 %19, double %18, double %13
%21 = fcmp olt double %18, %12
%22 = select i1 %21, double %18, double %12
%23 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %3)
%24 = load i32, i32* @EOF
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %10
26: ; preds = %17, %2
%27 = phi double [ %5, %2 ], [ %20, %17 ]
%28 = phi double [ %4, %2 ], [ %22, %17 ]
%29 = icmp eq i32 %1, 0
%30 = select i1 %29, double %28, double %27
ret double %30
}