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

/* Variables and functions */
scalar_t__ EINTR;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
scalar_t__ errno;
int /*<<< orphan*/ escape_from_scary_killers();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, int **, int);
ssize_t Pipe_fatherRead(int pipeSF[2], int *res) {
  int tmp;
  int *r;
  ssize_t size = 0;
  assert(pipeSF != NULL);
  if (res == NULL) {
    r = &tmp;
  } else {
    r = res;
  }
  while (size == 0) {
    size = read(pipeSF[0], &r, sizeof(r));
    if (size < 1) {
      if (errno == EINTR) {
        size = 0;
      } else {
        escape_from_scary_killers();
        perror("Father: Error when reading from pipeSF[0]");
        exit(EXIT_FAILURE);
      }
    }
  }
  return size;
}


x86 assembly (clang, -O0):
<Pipe_fatherRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    1191 <Pipe_fatherRead+0x41>
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1199 <Pipe_fatherRead+0x49>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    119e <Pipe_fatherRead+0x4e>
cmpl   $0x0,-0x24(%rbp)
jne    121a <Pipe_fatherRead+0xca>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jge    1215 <Pipe_fatherRead+0xc5>
mov    0x2e10(%rip),%rax
mov    (%rax),%rax
mov    0x2df6(%rip),%rcx
cmp    (%rcx),%rax
jne    11ef <Pipe_fatherRead+0x9f>
movl   $0x0,-0x24(%rbp)
jmp    1210 <Pipe_fatherRead+0xc0>
mov    $0x0,%al
call   1070 <escape_from_scary_killers@plt>
lea    0xe03(%rip),%rdi
call   1050 <perror@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
jmp    1215 <Pipe_fatherRead+0xc5>
jmp    119e <Pipe_fatherRead+0x4e>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pipe_fatherRead>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
test   %r14,%r14
lea    0x14(%rsp),%rax
cmovne %r14,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%r14
mov    0x2e54(%rip),%r15
mov    0x2e3d(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%edi
mov    %r14,%rsi
mov    $0x8,%edx
call   1030 <read@plt>
test   %eax,%eax
jg     11dd <Pipe_fatherRead+0x8d>
mov    (%r15),%rax
cmp    (%r12),%rax
je     11a0 <Pipe_fatherRead+0x50>
xor    %eax,%eax
call   1070 <escape_from_scary_killers@plt>
lea    0xe36(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@EINTR = global i64 0
@.str = [42 x i8] c"Father: Error when reading from pipeSF[0]\00"
@EXIT_FAILURE = global i32 0
define i32 @Pipe_fatherRead(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %7
%8 = load i32*, i32** %3
%9 = icmp ne i32* %8, null
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %2
store i32* %5, i32** %6
br label %17
15: ; preds = %2
%16 = load i32*, i32** %4
store i32* %16, i32** %6
br label %17
17: ; preds = %15, %14
br label %18
18: ; preds = %39, %17
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %40
21: ; preds = %18
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 0
%24 = load i32, i32* %23
%25 = call i32 @read(i32 %24, i32** %6, i32 8)
store i32 %25, i32* %7
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 1
br i1 %27, label %28, label %39
28: ; preds = %21
%29 = load i64, i64* @errno
%30 = load i64, i64* @EINTR
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 0, i32* %7
br label %38
33: ; preds = %28
%34 = call i32 (...) @escape_from_scary_killers()
%35 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %32
br label %39
39: ; preds = %38, %21
br label %18
40: ; preds = %18
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
@errno = global i64 0
@EINTR = global i64 0
@.str = [42 x i8] c"Father: Error when reading from pipeSF[0]\00"
@EXIT_FAILURE = global i32 0
define i32 @Pipe_fatherRead(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32** %4 to i8*
%7 = icmp ne i32* %0, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = icmp eq i32* %1, null
%11 = select i1 %10, i32* %3, i32* %1
store i32* %11, i32** %4
br label %12
12: ; preds = %16, %2
%13 = load i32, i32* %0
%14 = call i32 @read(i32 %13, i32** %4, i32 8)
%15 = icmp slt i32 %14, 1
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = load i64, i64* @errno
%18 = load i64, i64* @EINTR
%19 = icmp eq i64 %17, %18
br i1 %19, label %12, label %20
20: ; preds = %16
%21 = call i32 (...) @escape_from_scary_killers()
%22 = call i32 @perror(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %12
ret i32 %14
}