#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 */
struct timespec {
  int tv_sec;
  unsigned long tv_nsec;
};
typedef int pid_t;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
unsigned int Readn(int, char *, unsigned int);
int /*<<< orphan*/ Writen(int, char *, unsigned int);
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, ...);
unsigned int read(int, char *, int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
unsigned int write(int, char *, int);
long unsigned pipe_throughput(unsigned expected_size, bool debug) {
  int pipe_go[2], pipe_come[2];
  pid_t child_pid;
  char buf[(512 * 1024 + 1)];
  unsigned transferred;
  struct timespec start;
  struct timespec end;
  memset(buf, 0, (512 * 1024 + 1));
  pipe(pipe_go);
  pipe(pipe_come);
  child_pid = fork();
  if (child_pid == -1) {
    perror("fork");
    exit(EXIT_FAILURE);
  } else if (child_pid == 0) {
    close(pipe_go[1]);
    close(pipe_come[0]);
    if (debug)
      printf("child is reading %u...\n", expected_size);
    if ((transferred = Readn(pipe_go[0], buf, expected_size)) < expected_size) {
      perror("read less than expected");
    }
    if (debug)
      printf("child is sending %u...\n", expected_size);
    transferred = write(pipe_come[1], "F", 1);
    close(pipe_go[0]);
    close(pipe_come[1]);
    if (debug)
      printf("child is exiting %u...\n", expected_size);
    _exit(EXIT_SUCCESS);
  } else {
    close(pipe_go[0]);
    close(pipe_come[1]);
    clock_gettime(CLOCK_MONOTONIC, &start);
    if (debug)
      printf("parent is writing %u...\n", expected_size);
    Writen(pipe_go[1], buf, expected_size);
    if (debug)
      printf("parent is reading %u...\n", expected_size);
    transferred = read(pipe_come[0], buf, 1);
    if (buf[0] == 'F') {
      clock_gettime(CLOCK_MONOTONIC, &end);
    } else {
      printf("ERROR: recieved char is %s!\n", buf);
    }
    close(pipe_go[1]);
    close(pipe_come[0]);
    if (debug)
      printf("parent is waiting after %u...\n", expected_size);
    wait(NULL);
    if (debug)
      printf("parent is returning after %u...\n", expected_size);
    return (end.tv_sec - start.tv_sec) * 1000000000 + end.tv_nsec -
           start.tv_nsec;
  }
}


x86 assembly (clang, -O0):
<pipe_throughput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80050,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0x80020(%rbp),%rdi
xor    %esi,%esi
mov    $0x80001,%edx
call   1080 <memset@plt>
lea    -0x10(%rbp),%rdi
call   10a0 <pipe@plt>
lea    -0x18(%rbp),%rdi
call   10a0 <pipe@plt>
mov    $0x0,%al
call   1100 <fork@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1244 <pipe_throughput+0x64>
lea    0xdcf(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    1314 <pipe_throughput+0x134>
mov    -0xc(%rbp),%edi
call   1090 <close@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0x8(%rbp)
je     1279 <pipe_throughput+0x99>
mov    -0x4(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%edi
lea    -0x80020(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   1060 <Readn@plt>
mov    %eax,-0x80024(%rbp)
cmp    -0x4(%rbp),%eax
jae    12a6 <pipe_throughput+0xc6>
lea    0xd7c(%rip),%rdi
call   10c0 <perror@plt>
cmpl   $0x0,-0x8(%rbp)
je     12c1 <pipe_throughput+0xe1>
mov    -0x4(%rbp),%esi
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
lea    0xd82(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    %eax,-0x80024(%rbp)
mov    -0x10(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0x8(%rbp)
je     1306 <pipe_throughput+0x126>
mov    -0x4(%rbp),%esi
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    -0x10(%rbp),%edi
call   1090 <close@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    0x2cbd(%rip),%rax
mov    (%rax),%edi
lea    -0x80038(%rbp),%rsi
call   1040 <clock_gettime@plt>
cmpl   $0x0,-0x8(%rbp)
je     1354 <pipe_throughput+0x174>
mov    -0x4(%rbp),%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc(%rbp),%edi
lea    -0x80020(%rbp),%rsi
mov    -0x4(%rbp),%edx
call   10d0 <Writen@plt>
cmpl   $0x0,-0x8(%rbp)
je     1381 <pipe_throughput+0x1a1>
mov    -0x4(%rbp),%esi
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x80020(%rbp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
mov    %eax,-0x80024(%rbp)
movsbl -0x80020(%rbp),%eax
cmp    $0x46,%eax
jne    13c5 <pipe_throughput+0x1e5>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
lea    -0x80048(%rbp),%rsi
call   1040 <clock_gettime@plt>
jmp    13da <pipe_throughput+0x1fa>
lea    -0x80020(%rbp),%rsi
lea    0xcc6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc(%rbp),%edi
call   1090 <close@plt>
mov    -0x18(%rbp),%edi
call   1090 <close@plt>
cmpl   $0x0,-0x8(%rbp)
je     1405 <pipe_throughput+0x225>
mov    -0x4(%rbp),%esi
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <wait@plt>
cmpl   $0x0,-0x8(%rbp)
je     1429 <pipe_throughput+0x249>
mov    -0x4(%rbp),%esi
lea    0xcb3(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x80048(%rbp),%eax
sub    -0x80038(%rbp),%eax
imul   $0x3b9aca00,%eax,%eax
cltq
add    -0x80040(%rbp),%rax
sub    -0x80030(%rbp),%rax
add    $0x80050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_throughput>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80040,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0x80001,%edx
call   1080 <memset@plt>
lea    0x8(%rsp),%rdi
call   10a0 <pipe@plt>
mov    %rsp,%rdi
call   10a0 <pipe@plt>
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
je     1343 <pipe_throughput+0x163>
cmp    $0xffffffff,%eax
je     13b5 <pipe_throughput+0x1d5>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
mov    0x2da5(%rip),%r14
mov    (%r14),%edi
lea    0x20(%rsp),%rsi
call   1040 <clock_gettime@plt>
test   %ebp,%ebp
je     1286 <pipe_throughput+0xa6>
lea    0xe0c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    %ebx,%edx
call   10d0 <Writen@plt>
lea    0xe05(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1296 <pipe_throughput+0xb6>
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    %ebx,%edx
call   10d0 <Writen@plt>
mov    (%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
cmpb   $0x46,0x30(%rsp)
jne    12be <pipe_throughput+0xde>
mov    (%r14),%edi
lea    0x10(%rsp),%rsi
call   1040 <clock_gettime@plt>
jmp    12d1 <pipe_throughput+0xf1>
lea    0xdd4(%rip),%rdi
lea    0x30(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    (%rsp),%edi
call   1090 <close@plt>
test   %ebp,%ebp
je     130f <pipe_throughput+0x12f>
lea    0xdc9(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   10f0 <wait@plt>
lea    0xdd1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1316 <pipe_throughput+0x136>
xor    %edi,%edi
call   10f0 <wait@plt>
movslq 0x10(%rsp),%rax
movslq 0x20(%rsp),%rcx
sub    %rcx,%rax
imul   $0x3b9aca00,%rax,%rcx
mov    0x18(%rsp),%rax
sub    0x28(%rsp),%rax
add    %rcx,%rax
add    $0x80040,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0xc(%rsp),%edi
call   1090 <close@plt>
mov    (%rsp),%edi
call   1090 <close@plt>
test   %ebp,%ebp
je     1368 <pipe_throughput+0x188>
lea    0xca6(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    %ebx,%edx
call   1060 <Readn@plt>
cmp    %ebx,%eax
jae    1388 <pipe_throughput+0x1a8>
lea    0xc9a(%rip),%rdi
call   10c0 <perror@plt>
test   %ebp,%ebp
jne    13cf <pipe_throughput+0x1ef>
mov    0x4(%rsp),%edi
lea    0xcb6(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
jmp    1416 <pipe_throughput+0x236>
lea    0xc44(%rip),%rdi
call   10c0 <perror@plt>
mov    0x2c10(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xc5f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%edi
lea    0xc63(%rip),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
mov    0x8(%rsp),%edi
call   1090 <close@plt>
mov    0x4(%rsp),%edi
call   1090 <close@plt>
lea    0xc42(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2bb3(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@.str = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [24 x i8] c"child is reading %u...\0A\00"
@.str.2 = [24 x i8] c"read less than expected\00"
@.str.3 = [24 x i8] c"child is sending %u...\0A\00"
@.str.4 = [2 x i8] c"F\00"
@.str.5 = [24 x i8] c"child is exiting %u...\0A\00"
@EXIT_SUCCESS = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.6 = [25 x i8] c"parent is writing %u...\0A\00"
@.str.7 = [25 x i8] c"parent is reading %u...\0A\00"
@.str.8 = [29 x i8] c"ERROR: recieved char is %s!\0A\00"
@.str.9 = [31 x i8] c"parent is waiting after %u...\0A\00"
@.str.10 = [33 x i8] c"parent is returning after %u...\0A\00"
define i64 @pipe_throughput(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [2 x i32]
%6 = alloca [2 x i32]
%7 = alloca i32
%8 = alloca [524289 x i8]
%9 = alloca i32
%10 = alloca %struct.timespec
%11 = alloca %struct.timespec
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 524289)
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%15 = call i32 @pipe(i32* %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = call i32 (...) @fork()
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %2
%22 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %2
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %74
28: ; preds = %25
%29 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%30 = load i32, i32* %29
%31 = call i32 @close(i32 %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = load i32, i32* %4
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %28
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %28
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%44 = load i32, i32* %3
%45 = call i32 @Readn(i32 %42, i8* %43, i32 %44)
store i32 %45, i32* %9
%46 = load i32, i32* %3
%47 = icmp ult i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %40
%49 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %48, %40
%51 = load i32, i32* %4
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %3
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %50
%57 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%58 = load i32, i32* %57
%59 = call i32 @write(i32 %58, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
store i32 %59, i32* %9
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%61 = load i32, i32* %60
%62 = call i32 @close(i32 %61)
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%64 = load i32, i32* %63
%65 = call i32 @close(i32 %64)
%66 = load i32, i32* %4
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %56
%69 = load i32, i32* %3
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %68, %56
%72 = load i32, i32* @EXIT_SUCCESS
%73 = call i32 @_exit(i32 %72)
unreachable
74: ; preds = %25
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%76 = load i32, i32* %75
%77 = call i32 @close(i32 %76)
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32 @close(i32 %79)
%81 = load i32, i32* @CLOCK_MONOTONIC
%82 = call i32 @clock_gettime(i32 %81, %struct.timespec* %10)
%83 = load i32, i32* %4
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %74
%86 = load i32, i32* %3
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %86)
br label %88
88: ; preds = %85, %74
%89 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%90 = load i32, i32* %89
%91 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%92 = load i32, i32* %3
%93 = call i32 @Writen(i32 %90, i8* %91, i32 %92)
%94 = load i32, i32* %4
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %88
%97 = load i32, i32* %3
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %97)
br label %99
99: ; preds = %96, %88
%100 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%101 = load i32, i32* %100
%102 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%103 = call i32 @read(i32 %101, i8* %102, i32 1)
store i32 %103, i32* %9
%104 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 70
br i1 %107, label %108, label %111
108: ; preds = %99
%109 = load i32, i32* @CLOCK_MONOTONIC
%110 = call i32 @clock_gettime(i32 %109, %struct.timespec* %11)
br label %114
111: ; preds = %99
%112 = getelementptr inbounds [524289 x i8], [524289 x i8]* %8, i64 0, i64 0
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %112)
br label %114
114: ; preds = %111, %108
%115 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
%116 = load i32, i32* %115
%117 = call i32 @close(i32 %116)
%118 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%119 = load i32, i32* %118
%120 = call i32 @close(i32 %119)
%121 = load i32, i32* %4
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %126
123: ; preds = %114
%124 = load i32, i32* %3
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %124)
br label %126
126: ; preds = %123, %114
%127 = call i32 @wait(i32* null)
%128 = load i32, i32* %4
%129 = icmp ne i32 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %126
%131 = load i32, i32* %3
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %131)
br label %133
133: ; preds = %130, %126
%134 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 0
%135 = load i32, i32* %134
%136 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%137 = load i32, i32* %136
%138 = sub nsw i32 %135, %137
%139 = mul nsw i32 %138, 1000000000
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds %struct.timespec, %struct.timespec* %11, i32 0, i32 1
%142 = load i64, i64* %141
%143 = add i64 %140, %142
%144 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%145 = load i64, i64* %144
%146 = sub i64 %143, %145
ret i64 %146
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@.str = [5 x i8] c"fork\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [24 x i8] c"child is reading %u...\0A\00"
@.str.2 = [24 x i8] c"read less than expected\00"
@.str.3 = [24 x i8] c"child is sending %u...\0A\00"
@.str.4 = [2 x i8] c"F\00"
@.str.5 = [24 x i8] c"child is exiting %u...\0A\00"
@EXIT_SUCCESS = global i32 0
@CLOCK_MONOTONIC = global i32 0
@.str.6 = [25 x i8] c"parent is writing %u...\0A\00"
@.str.7 = [25 x i8] c"parent is reading %u...\0A\00"
@.str.8 = [29 x i8] c"ERROR: recieved char is %s!\0A\00"
@.str.9 = [31 x i8] c"parent is waiting after %u...\0A\00"
@.str.10 = [33 x i8] c"parent is returning after %u...\0A\00"
define i64 @pipe_throughput(i32 %0, i32 %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca [524289 x i8]
%6 = alloca %struct.timespec
%7 = alloca %struct.timespec
%8 = bitcast [2 x i32]* %3 to i8*
%9 = bitcast [2 x i32]* %4 to i8*
%10 = getelementptr inbounds [524289 x i8], [524289 x i8]* %5, i64 0, i64 0
%11 = bitcast %struct.timespec* %6 to i8*
%12 = bitcast %struct.timespec* %7 to i8*
%13 = call i32 @memset(i8* %10, i32 0, i32 524289)
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%15 = call i32 @pipe(i32* %14)
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%17 = call i32 @pipe(i32* %16)
%18 = call i32 (...) @fork()
switch i32 %18, label %60 [
i32 -1, label %19
i32 0, label %23
]
19: ; preds = %2
%20 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%25 = load i32, i32* %24
%26 = call i32 @close(i32 %25)
%27 = load i32, i32* %16
%28 = call i32 @close(i32 %27)
%29 = icmp eq i32 %1, 0
br i1 %29, label %32, label %30
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %32
32: ; preds = %30, %23
%33 = load i32, i32* %14
%34 = call i32 @Readn(i32 %33, i8* %10, i32 %0)
%35 = icmp ult i32 %34, %0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %32
br i1 %29, label %49, label %39
39: ; preds = %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %0)
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32 @write(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%44 = load i32, i32* %14
%45 = call i32 @close(i32 %44)
%46 = load i32, i32* %41
%47 = call i32 @close(i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %0)
br label %57
49: ; preds = %38
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%51 = load i32, i32* %50
%52 = call i32 @write(i32 %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 1)
%53 = load i32, i32* %14
%54 = call i32 @close(i32 %53)
%55 = load i32, i32* %50
%56 = call i32 @close(i32 %55)
br label %57
57: ; preds = %49, %39
%58 = load i32, i32* @EXIT_SUCCESS
%59 = call i32 @_exit(i32 %58)
unreachable
60: ; preds = %2
%61 = load i32, i32* %14
%62 = call i32 @close(i32 %61)
%63 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%64 = load i32, i32* %63
%65 = call i32 @close(i32 %64)
%66 = load i32, i32* @CLOCK_MONOTONIC
%67 = call i32 @clock_gettime(i32 %66, %struct.timespec* %6)
%68 = icmp eq i32 %1, 0
br i1 %68, label %69, label %73
69: ; preds = %60
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%71 = load i32, i32* %70
%72 = call i32 @Writen(i32 %71, i8* %10, i32 %0)
br label %79
73: ; preds = %60
%74 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %0)
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%76 = load i32, i32* %75
%77 = call i32 @Writen(i32 %76, i8* %10, i32 %0)
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i32 %0)
br label %79
79: ; preds = %69, %73
%80 = phi i32* [ %70, %69 ], [ %75, %73 ]
%81 = load i32, i32* %16
%82 = call i32 @read(i32 %81, i8* %10, i32 1)
%83 = load i8, i8* %10
%84 = icmp eq i8 %83, 70
br i1 %84, label %85, label %88
85: ; preds = %79
%86 = load i32, i32* @CLOCK_MONOTONIC
%87 = call i32 @clock_gettime(i32 %86, %struct.timespec* %7)
br label %90
88: ; preds = %79
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %10)
br label %90
90: ; preds = %88, %85
%91 = load i32, i32* %80
%92 = call i32 @close(i32 %91)
%93 = load i32, i32* %16
%94 = call i32 @close(i32 %93)
br i1 %68, label %99, label %95
95: ; preds = %90
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %0)
%97 = call i32 @wait(i32* null)
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %0)
br label %101
99: ; preds = %90
%100 = call i32 @wait(i32* null)
br label %101
101: ; preds = %99, %95
%102 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 0
%103 = load i32, i32* %102
%104 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%105 = load i32, i32* %104
%106 = sub nsw i32 %103, %105
%107 = mul nsw i32 %106, 1000000000
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds %struct.timespec, %struct.timespec* %7, i64 0, i32 1
%110 = load i64, i64* %109
%111 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%112 = load i64, i64* %111
%113 = sub i64 %110, %112
%114 = add i64 %113, %108
ret i64 %114
}