#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 */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, long double);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, long double);
unsigned long long rdtsc();
int read(int, char *, int);
int /*<<< orphan*/ runpipe(int *, int *, char *, char *);
int wait(int *);
int main(int argc, char **argv) {
  unsigned long long x;
  unsigned long long y;
  int pid, status;
  int fd1[2];
  int fd2[2];
  char buf[65536];
  int n2;
  FILE *fp;
  char str[65536];
  char string[65536];
  fp = fopen("512KB.txt", "r");
  if (fp == NULL) {
    perror("Error opening file");
    return (-1);
  }
  if (fgets(str, 65536, fp) != NULL) {
    memcpy(string, str, 65536);
    string[65536] = '\0';
  }
  fclose(fp);
  char *data = string;
  FILE *fp2;
  if ((fp2 = fopen("/home/george/Documents/C/results/pipe64K.txt", "wt+")) ==
      NULL) {
    perror("/home/george/Documents/C/results/pipe64K.txt");
    exit(1);
  }
  int i = 0;
  for (i; i < 100; i++) {
    pipe(fd1);
    pipe(fd2);
    x = rdtsc();
    switch (pid = fork()) {
    case 0:
      runpipe(fd1, fd2, data, buf);
      exit(0);
    default:
      while ((pid = wait(&status)) != -1)
        ;
      close(fd2[1]);
      if ((n2 = read(fd2[0], buf, 65536)) >= 0) {
        buf[n2] = 0;
        printf("read %d bytes from the pipe2 \n", n2);
      } else
        perror("read");
      break;
    case -1:
      perror("fork");
      exit(1);
    }
    y = rdtsc();
    printf("total cycles for round trip: %lld\n", y - x);
    long double time = (long double)(y - x) / 5200000000;
    printf("time spend (half of bi-direction): %Lf\n", time);
    fprintf(fp2, "%Lf\n", time);
    fflush(fp2);
  }
  fclose(fp2);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x300c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xdec(%rip),%rdi
lea    0xdef(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x10050(%rbp)
cmpq   $0x0,-0x10050(%rbp)
jne    125b <main+0x5b>
lea    0xdd0(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x300c0,%rsp
pop    %rbp
ret
lea    -0x20050(%rbp),%rdi
mov    -0x10050(%rbp),%rdx
mov    $0x10000,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     129c <main+0x9c>
lea    -0x30050(%rbp),%rdi
lea    -0x20050(%rbp),%rsi
mov    $0x10000,%edx
call   10c0 <memcpy@plt>
movb   $0x0,-0x20050(%rbp)
mov    -0x10050(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x30050(%rbp),%rax
mov    %rax,-0x30058(%rbp)
lea    0xd6e(%rip),%rdi
lea    0xd94(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x30060(%rbp)
cmp    $0x0,%rax
jne    12f0 <main+0xf0>
lea    0xd4a(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
movl   $0x0,-0x30064(%rbp)
cmpl   $0x64,-0x30064(%rbp)
jge    150a <main+0x30a>
lea    -0x30(%rbp),%rdi
call   1080 <pipe@plt>
lea    -0x38(%rbp),%rdi
call   1080 <pipe@plt>
xor    %eax,%eax
mov    %al,-0x3009d(%rbp)
call   1060 <rdtsc@plt>
mov    %rax,%rcx
mov    -0x3009d(%rbp),%al
mov    %rcx,-0x18(%rbp)
call   1120 <fork@plt>
mov    %eax,-0x24(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x3009c(%rbp)
sub    $0xffffffff,%eax
je     1418 <main+0x218>
jmp    1351 <main+0x151>
mov    -0x3009c(%rbp),%eax
test   %eax,%eax
jne    1386 <main+0x186>
jmp    1364 <main+0x164>
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
mov    -0x30058(%rbp),%rdx
lea    -0x10040(%rbp),%rcx
call   1050 <runpipe@plt>
xor    %edi,%edi
call   1100 <exit@plt>
jmp    138b <main+0x18b>
lea    -0x28(%rbp),%rdi
call   1110 <wait@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     13a5 <main+0x1a5>
jmp    138b <main+0x18b>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
mov    -0x38(%rbp),%edi
lea    -0x10040(%rbp),%rsi
mov    $0x10000,%edx
call   1090 <read@plt>
mov    %eax,-0x10044(%rbp)
cmp    $0x0,%eax
jl     1407 <main+0x207>
movslq -0x10044(%rbp),%rax
movb   $0x0,-0x10040(%rbp,%rax,1)
mov    -0x10044(%rbp),%eax
mov    %eax,-0x30084(%rbp)
fildl  -0x30084(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xc5f(%rip),%rdi
call   1040 <printf@plt>
jmp    1413 <main+0x213>
lea    0xc6d(%rip),%rdi
call   10f0 <perror@plt>
jmp    142e <main+0x22e>
lea    0xc61(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
xor    %eax,%eax
call   1060 <rdtsc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x30098(%rbp)
sets   %al
movzbl %al,%eax
mov    %eax,%ecx
fildll -0x30098(%rbp)
lea    0xba0(%rip),%rax
mov    %rax,-0x300a8(%rbp)
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xc0d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x300a8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
mov    %rcx,-0x30090(%rbp)
sets   %cl
movzbl %cl,%ecx
fildll -0x30090(%rbp)
flds   (%rax,%rcx,4)
faddp  %st,%st(1)
flds   0xb5b(%rip)
fdivrp %st,%st(1)
fstpt  -0x30080(%rbp)
fldt   -0x30080(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xbe1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30060(%rbp),%rdi
fldt   -0x30080(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xbe6(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x30060(%rbp),%rdi
call   10d0 <fflush@plt>
mov    -0x30064(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30064(%rbp)
jmp    12fa <main+0xfa>
mov    -0x30060(%rbp),%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1100 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30048,%rsp
lea    0xdf4(%rip),%rdi
lea    0xdf7(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    124c <main+0x4c>
lea    0xde8(%rip),%rdi
call   10f0 <perror@plt>
mov    $0xffffffff,%eax
add    $0x30048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rax,%rbx
lea    0x20040(%rsp),%rdi
mov    $0x10000,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1288 <main+0x88>
lea    0x40(%rsp),%rdi
lea    0x20040(%rsp),%rsi
mov    $0x10000,%edx
call   10c0 <memcpy@plt>
movb   $0x0,0x10040(%rsp)
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xd94(%rip),%rdi
lea    0xdba(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
jne    12b4 <main+0xb4>
lea    0xd7c(%rip),%rdi
jmp    140b <main+0x20b>
mov    %rax,%r12
lea    0x3c(%rsp),%rbx
lea    0xde5(%rip),%r14
lea    0xe01(%rip),%r15
xor    %ebp,%ebp
jmp    1379 <main+0x179>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
movb   $0x0,0x10040(%rsp,%rcx,1)
mov    %eax,0x10(%rsp)
fildl  0x10(%rsp)
fstpt  (%rsp)
lea    0xd60(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <rdtsc@plt>
xor    %ecx,%ecx
sub    %r13,%rax
mov    %rax,0x28(%rsp)
sets   %cl
fildll 0x28(%rsp)
lea    0xce0(%rip),%rax
fadds  (%rax,%rcx,4)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
lea    0xd52(%rip),%rdi
call   1040 <printf@plt>
fldt   0x1c(%rsp)
fdivs  0xcc6(%rip)
fld    %st(0)
fstpt  0x1c(%rsp)
fstpt  (%rsp)
mov    %r14,%rdi
call   1040 <printf@plt>
fldt   0x1c(%rsp)
fstpt  (%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   10b0 <fprintf@plt>
mov    %r12,%rdi
call   10d0 <fflush@plt>
add    $0x1,%ebp
cmp    $0x64,%ebp
je     13f5 <main+0x1f5>
lea    0x34(%rsp),%rdi
call   1080 <pipe@plt>
lea    0x14(%rsp),%rdi
call   1080 <pipe@plt>
xor    %eax,%eax
call   1060 <rdtsc@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1120 <fork@plt>
cmp    $0xffffffff,%eax
je     1404 <main+0x204>
test   %eax,%eax
je     141a <main+0x21a>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1110 <wait@plt>
cmp    $0xffffffff,%eax
jne    13b0 <main+0x1b0>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
mov    0x14(%rsp),%edi
lea    0x10040(%rsp),%rsi
mov    $0x10000,%edx
call   1090 <read@plt>
test   %eax,%eax
jns    12e0 <main+0xe0>
lea    0xc90(%rip),%rdi
call   10f0 <perror@plt>
jmp    1301 <main+0x101>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1100 <exit@plt>
lea    0xc75(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0x34(%rsp),%rdi
lea    0x14(%rsp),%rsi
lea    0x40(%rsp),%rdx
lea    0x10040(%rsp),%rcx
call   1050 <runpipe@plt>
xor    %edi,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"512KB.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error opening file\00"
@.str.3 = [45 x i8] c"/home/george/Documents/C/results/pipe64K.txt\00"
@.str.4 = [4 x i8] c"wt+\00"
@.str.5 = [31 x i8] c"read %d bytes from the pipe2 \0A\00"
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [5 x i8] c"fork\00"
@.str.8 = [35 x i8] c"total cycles for round trip: %lld\0A\00"
@.str.9 = [40 x i8] c"time spend (half of bi-direction): %Lf\0A\00"
@.str.10 = [5 x i8] c"%Lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2 x i32]
%11 = alloca [2 x i32]
%12 = alloca [65536 x i8]
%13 = alloca i32
%14 = alloca i32*
%15 = alloca [65536 x i8]
%16 = alloca [65536 x i8]
%17 = alloca i8*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %14
%22 = load i32*, i32** %14
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
ret i32 -1
26: ; preds = %2
%27 = getelementptr inbounds [65536 x i8], [65536 x i8]* %15, i64 0, i64 0
%28 = load i32*, i32** %14
%29 = call i32* @fgets(i8* %27, i32 65536, i32* %28)
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = getelementptr inbounds [65536 x i8], [65536 x i8]* %16, i64 0, i64 0
%33 = getelementptr inbounds [65536 x i8], [65536 x i8]* %15, i64 0, i64 0
%34 = call i32 @memcpy(i8* %32, i8* %33, i32 65536)
%35 = getelementptr inbounds [65536 x i8], [65536 x i8]* %16, i64 0, i64 65536
store i8 0, i8* %35
br label %36
36: ; preds = %31, %26
%37 = load i32*, i32** %14
%38 = call i32 @fclose(i32* %37)
%39 = getelementptr inbounds [65536 x i8], [65536 x i8]* %16, i64 0, i64 0
store i8* %39, i8** %17
%40 = call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32* %40, i32** %18
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %36
store i32 0, i32* %19
%46 = load i32, i32* %19
br label %47
47: ; preds = %110, %45
%48 = load i32, i32* %19
%49 = icmp slt i32 %48, 100
br i1 %49, label %50, label %113
50: ; preds = %47
%51 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%52 = call i32 @pipe(i32* %51)
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%54 = call i32 @pipe(i32* %53)
%55 = call i64 (...) @rdtsc()
store i64 %55, i64* %6
%56 = call i32 (...) @fork()
store i32 %56, i32* %8
switch i32 %56, label %64 [
i32 0, label %57
i32 -1, label %88
]
57: ; preds = %50
%58 = getelementptr inbounds [2 x i32], [2 x i32]* %10, i64 0, i64 0
%59 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%60 = load i8*, i8** %17
%61 = getelementptr inbounds [65536 x i8], [65536 x i8]* %12, i64 0, i64 0
%62 = call i32 @runpipe(i32* %58, i32* %59, i8* %60, i8* %61)
%63 = call i32 @exit(i32 0)
unreachable
64: ; preds = %50
br label %65
65: ; preds = %68, %64
%66 = call i32 @wait(i32* %9)
store i32 %66, i32* %8
%67 = icmp ne i32 %66, -1
br i1 %67, label %68, label %69
68: ; preds = %65
br label %65
69: ; preds = %65
%70 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 1
%71 = load i32, i32* %70
%72 = call i32 @close(i32 %71)
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%74 = load i32, i32* %73
%75 = getelementptr inbounds [65536 x i8], [65536 x i8]* %12, i64 0, i64 0
%76 = call i32 @read(i32 %74, i8* %75, i32 65536)
store i32 %76, i32* %13
%77 = icmp sge i32 %76, 0
br i1 %77, label %78, label %85
78: ; preds = %69
%79 = load i32, i32* %13
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [65536 x i8], [65536 x i8]* %12, i64 0, i64 %80
store i8 0, i8* %81
%82 = load i32, i32* %13
%83 = sitofp i32 %82 to x86_fp80
%84 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), x86_fp80 %83)
br label %87
85: ; preds = %69
%86 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %87
87: ; preds = %85, %78
br label %91
88: ; preds = %50
%89 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%90 = call i32 @exit(i32 1)
unreachable
91: ; preds = %87
%92 = call i64 (...) @rdtsc()
store i64 %92, i64* %7
%93 = load i64, i64* %7
%94 = load i64, i64* %6
%95 = sub i64 %93, %94
%96 = uitofp i64 %95 to x86_fp80
%97 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %96)
%98 = load i64, i64* %7
%99 = load i64, i64* %6
%100 = sub i64 %98, %99
%101 = uitofp i64 %100 to x86_fp80
%102 = fdiv x86_fp80 %101, 0xK401F9AF8DA0000000000
store x86_fp80 %102, x86_fp80* %20
%103 = load x86_fp80, x86_fp80* %20
%104 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %103)
%105 = load i32*, i32** %18
%106 = load x86_fp80, x86_fp80* %20
%107 = call i32 @fprintf(i32* %105, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), x86_fp80 %106)
%108 = load i32*, i32** %18
%109 = call i32 @fflush(i32* %108)
br label %110
110: ; preds = %91
%111 = load i32, i32* %19
%112 = add nsw i32 %111, 1
store i32 %112, i32* %19
br label %47
113: ; preds = %47
%114 = load i32*, i32** %18
%115 = call i32 @fclose(i32* %114)
%116 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [10 x i8] c"512KB.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [19 x i8] c"Error opening file\00"
@.str.3 = [45 x i8] c"/home/george/Documents/C/results/pipe64K.txt\00"
@.str.4 = [4 x i8] c"wt+\00"
@.str.5 = [31 x i8] c"read %d bytes from the pipe2 \0A\00"
@.str.6 = [5 x i8] c"read\00"
@.str.7 = [5 x i8] c"fork\00"
@.str.8 = [35 x i8] c"total cycles for round trip: %lld\0A\00"
@.str.9 = [40 x i8] c"time spend (half of bi-direction): %Lf\0A\00"
@.str.10 = [5 x i8] c"%Lf\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [2 x i32]
%5 = alloca [2 x i32]
%6 = alloca [65536 x i8]
%7 = alloca [65536 x i8]
%8 = alloca [65536 x i8]
%9 = bitcast i32* %3 to i8*
%10 = bitcast [2 x i32]* %4 to i8*
%11 = bitcast [2 x i32]* %5 to i8*
%12 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
%14 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 0
%15 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
ret i32 -1
19: ; preds = %2
%20 = call i32* @fgets(i8* %13, i32 65536, i32* %15)
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %19
%23 = call i32 @memcpy(i8* %14, i8* %13, i32 65536)
%24 = getelementptr inbounds [65536 x i8], [65536 x i8]* %8, i64 0, i64 65536
store i8 0, i8* %24
br label %25
25: ; preds = %22, %19
%26 = call i32 @fclose(i32* %15)
%27 = call i32* @fopen(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 0
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %5, i64 0, i64 1
br label %36
33: ; preds = %25
%34 = call i32 @perror(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29, %64
%37 = phi i32 [ 0, %29 ], [ %73, %64 ]
%38 = call i32 @pipe(i32* %30)
%39 = call i32 @pipe(i32* %31)
%40 = call i64 (...) @rdtsc()
%41 = call i32 (...) @fork()
switch i32 %41, label %45 [
i32 0, label %42
i32 -1, label %61
]
42: ; preds = %36
%43 = call i32 @runpipe(i32* %30, i32* %31, i8* %14, i8* %12)
%44 = call i32 @exit(i32 0)
unreachable
45: ; preds = %36, %45
%46 = call i32 @wait(i32* %3)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %45
48: ; preds = %45
%49 = load i32, i32* %32
%50 = call i32 @close(i32 %49)
%51 = load i32, i32* %31
%52 = call i32 @read(i32 %51, i8* %12, i32 65536)
%53 = icmp sgt i32 %52, -1
br i1 %53, label %54, label %59
54: ; preds = %48
%55 = zext i32 %52 to i64
%56 = getelementptr inbounds [65536 x i8], [65536 x i8]* %6, i64 0, i64 %55
store i8 0, i8* %56
%57 = sitofp i32 %52 to x86_fp80
%58 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), x86_fp80 %57)
br label %64
59: ; preds = %48
%60 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
br label %64
61: ; preds = %36
%62 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %54, %59
%65 = call i64 (...) @rdtsc()
%66 = sub i64 %65, %40
%67 = uitofp i64 %66 to x86_fp80
%68 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), x86_fp80 %67)
%69 = fdiv x86_fp80 %67, 0xK401F9AF8DA0000000000
%70 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), x86_fp80 %69)
%71 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0), x86_fp80 %69)
%72 = call i32 @fflush(i32* %27)
%73 = add nuw nsw i32 %37, 1
%74 = icmp eq i32 %73, 100
br i1 %74, label %75, label %36
75: ; preds = %64
%76 = call i32 @fclose(i32* %27)
%77 = call i32 @exit(i32 0)
unreachable
}