#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 */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ escape_from_scary_killers();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, int **, int);
ssize_t Pipe_childRead(int pipeFS[2], int *res) {
  int tmp;
  int *r;
  ssize_t size;
  assert(pipeFS != NULL);
  if (res == NULL) {
    r = &tmp;
  } else {
    r = res;
  }
  size = read(pipeFS[0], &r, sizeof(r));
  if (size < 1) {
    escape_from_scary_killers();
    perror("Child: Error when reading from pipeFS[0]");
    exit(EXIT_FAILURE);
  }
  return size;
}


x86 assembly (clang, -O0):
<Pipe_childRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
jne    118a <Pipe_childRead+0x3a>
lea    -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1192 <Pipe_childRead+0x42>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
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    11d4 <Pipe_childRead+0x84>
mov    $0x0,%al
call   1070 <escape_from_scary_killers@plt>
lea    0xe3f(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pipe_childRead>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1040 <assert@plt>
test   %rbx,%rbx
lea    0x14(%rsp),%rax
cmovne %rbx,%rax
mov    %rax,0x8(%rsp)
mov    (%r14),%edi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
call   1030 <read@plt>
test   %eax,%eax
jle    119a <Pipe_childRead+0x4a>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
call   1070 <escape_from_scary_killers@plt>
lea    0xe58(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"Child: Error when reading from pipeFS[0]\00"
@EXIT_FAILURE = global i32 0
define i32 @Pipe_childRead(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
%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
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 0
%20 = load i32, i32* %19
%21 = call i32 @read(i32 %20, i32** %6, i32 8)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp slt i32 %22, 1
br i1 %23, label %24, label %29
24: ; preds = %17
%25 = call i32 (...) @escape_from_scary_killers()
%26 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %17
%30 = load i32, i32* %7
ret i32 %30
}

LLVM IR (-O2):
@.str = [41 x i8] c"Child: Error when reading from pipeFS[0]\00"
@EXIT_FAILURE = global i32 0
define i32 @Pipe_childRead(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
%12 = load i32, i32* %0
%13 = call i32 @read(i32 %12, i32** %4, i32 8)
%14 = icmp slt i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = call i32 (...) @escape_from_scary_killers()
%17 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
ret i32 %13
}