#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 */
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int read(int, double *, int);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
double readPipe(int *pDescr, double *time) {
  double data = 0, seq = 0;
  errno = 0;
  if (read(pDescr[0], &data, sizeof(double)) == -1) {
    fprintf(stderr, "Error reading from pipe: %s\n", strerror(errno));
    data = 0;
  }
  seq += data;
  if (read(pDescr[0], &data, sizeof(double)) == -1) {
    fprintf(stderr, "Error reading from pipe: %s\n", strerror(errno));
    data = 0;
  }
  if (*time < data)
    *time = data;
  return seq;
}


x86 assembly (clang, -O0):
<readPipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e81(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
cmp    $0xffffffff,%eax
jne    11b0 <readPipe+0x80>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e4a(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe5d(%rip),%rsi
call   1040 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
cmp    $0xffffffff,%eax
jne    1211 <readPipe+0xe1>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%rdi
call   1050 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xdfc(%rip),%rsi
call   1040 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1235 <readPipe+0x105>
movsd  -0x18(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readPipe>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
mov    0x2e88(%rip),%r15
movq   $0x0,(%r15)
mov    (%rdi),%edi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
cmp    $0xffffffff,%eax
je     1179 <readPipe+0x49>
xorpd  %xmm0,%xmm0
addsd  0x8(%rsp),%xmm0
jmp    11a8 <readPipe+0x78>
mov    0x2e60(%rip),%rax
mov    (%rax),%ebp
mov    (%r15),%rdi
call   1050 <strerror@plt>
lea    0xe6f(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
movq   $0x0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
cmp    $0xffffffff,%eax
je     11e7 <readPipe+0xb7>
movsd  0x8(%rsp),%xmm0
ucomisd (%r14),%xmm0
jbe    11d6 <readPipe+0xa6>
movsd  %xmm0,(%r14)
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df2(%rip),%rax
mov    (%rax),%ebx
mov    (%r15),%rdi
call   1050 <strerror@plt>
lea    0xe01(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
xorpd  %xmm0,%xmm0
ucomisd (%r14),%xmm0
ja     11d1 <readPipe+0xa1>
jmp    11d6 <readPipe+0xa6>

LLVM IR (-O0):
@errno = global i64 0
@stderr = global i32 0
@.str = [29 x i8] c"Error reading from pipe: %s\0A\00"
define double @readPipe(i32* %0, double* %1) {
%3 = alloca i32*
%4 = alloca double*
%5 = alloca double
%6 = alloca double
store i32* %0, i32** %3
store double* %1, double** %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store i64 0, i64* @errno
%7 = load i32*, i32** %3
%8 = getelementptr inbounds i32, i32* %7, i64 0
%9 = load i32, i32* %8
%10 = call i32 @read(i32 %9, double* %5, i32 8)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i64, i64* @errno
%15 = call i8* @strerror(i64 %14)
%16 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %15)
store double 0.000000e+00, double* %5
br label %17
17: ; preds = %12, %2
%18 = load double, double* %5
%19 = load double, double* %6
%20 = fadd double %19, %18
store double %20, double* %6
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 0
%23 = load i32, i32* %22
%24 = call i32 @read(i32 %23, double* %5, i32 8)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %31
26: ; preds = %17
%27 = load i32, i32* @stderr
%28 = load i64, i64* @errno
%29 = call i8* @strerror(i64 %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %29)
store double 0.000000e+00, double* %5
br label %31
31: ; preds = %26, %17
%32 = load double*, double** %4
%33 = load double, double* %32
%34 = load double, double* %5
%35 = fcmp olt double %33, %34
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load double, double* %5
%38 = load double*, double** %4
store double %37, double* %38
br label %39
39: ; preds = %36, %31
%40 = load double, double* %6
ret double %40
}

LLVM IR (-O2):
@errno = global i64 0
@stderr = global i32 0
@.str = [29 x i8] c"Error reading from pipe: %s\0A\00"
define double @readPipe(i32* nocapture %0, double* nocapture %1) {
%3 = alloca double
%4 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
store i64 0, i64* @errno
%5 = load i32, i32* %0
%6 = call i32 @read(i32 %5, double* %3, i32 8)
%7 = icmp eq i32 %6, -1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load double, double* %3
%10 = fadd double %9, 0.000000e+00
br label %16
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i64, i64* @errno
%14 = tail call i8* @strerror(i64 %13)
%15 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %14)
store double 0.000000e+00, double* %3
br label %16
16: ; preds = %8, %11
%17 = phi double [ %10, %8 ], [ 0.000000e+00, %11 ]
%18 = load i32, i32* %0
%19 = call i32 @read(i32 %18, double* %3, i32 8)
%20 = icmp eq i32 %19, -1
br i1 %20, label %23, label %21
21: ; preds = %16
%22 = load double, double* %3
br label %28
23: ; preds = %16
%24 = load i32, i32* @stderr
%25 = load i64, i64* @errno
%26 = tail call i8* @strerror(i64 %25)
%27 = tail call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %26)
br label %28
28: ; preds = %21, %23
%29 = phi double [ %22, %21 ], [ 0.000000e+00, %23 ]
%30 = load double, double* %1
%31 = fcmp olt double %30, %29
br i1 %31, label %32, label %33
32: ; preds = %28
store double %29, double* %1
br label %33
33: ; preds = %32, %28
ret double %17
}