#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*/ result;
typedef scalar_t__ pid_t;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ perror(char *);
scalar_t__ pipe(int *);
float powf(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, float *, int);
int /*<<< orphan*/ scanf(char *, float *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, float *, int);
int main(int argc, char *argv[]) {
  int a2b[2], b2a[2];
  if (pipe(a2b) < 0) {
    perror("pipe");
    exit(1);
  }
  if (pipe(b2a) < 0) {
    perror("pipe");
    exit(1);
  }
  pid_t pid_a = fork();
  if (pid_a < 0) {
    perror("fork");
    exit(1);
  }
  if (pid_a == 0) {
    float a, b;
    printf("Process A\n");
    close(a2b[0]);
    close(b2a[1]);
    printf("a = ");
    scanf("%f", &a);
    printf("b = ");
    scanf("%f", &b);
    write(a2b[1], &a, sizeof(a));
    write(a2b[1], &b, sizeof(b));
    float result;
    read(b2a[0], &result, sizeof(result));
    printf("A: %f ^ %f = %f\n", a, b, result);
    exit(0);
  }
  printf("Process B\n");
  float a, b;
  read(a2b[0], &a, sizeof(a));
  read(a2b[0], &b, sizeof(b));
  float result = powf(a, b);
  write(b2a[1], &result, sizeof(result));
  wait(0);
  close(a2b[1]);
  close(a2b[0]);
  close(b2a[0]);
  close(b2a[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    11ef <main+0x3f>
lea    0xe20(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x20(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0x0,%rax
jge    1218 <main+0x68>
lea    0xdf7(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    1244 <main+0x94>
lea    0xdd0(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpq   $0x0,-0x28(%rbp)
jne    130c <main+0x15c>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd98(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xd8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd7a(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x14(%rbp),%edi
lea    -0x2c(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x30(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x34(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd24(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
mov    -0x18(%rbp),%edi
lea    -0x3c(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
movss  -0x38(%rbp),%xmm0
movss  -0x3c(%rbp),%xmm1
call   1030 <powf@plt>
movss  %xmm0,-0x40(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
xor    %edi,%edi
call   10c0 <wait@plt>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
mov    -0x20(%rbp),%edi
call   1060 <close@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rdi
call   1080 <pipe@plt>
test   %rax,%rax
js     1298 <main+0xd8>
lea    0x18(%rsp),%rdi
call   1080 <pipe@plt>
test   %rax,%rax
js     1298 <main+0xd8>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
js     12a1 <main+0xe1>
je     12b7 <main+0xf7>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%edi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1090 <read@plt>
mov    0x10(%rsp),%edi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
call   1090 <read@plt>
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
call   1040 <powf@plt>
movss  %xmm0,0x4(%rsp)
mov    0x1c(%rsp),%edi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1050 <write@plt>
xor    %edi,%edi
call   10d0 <wait@plt>
mov    0x14(%rsp),%edi
call   1070 <close@plt>
mov    0x10(%rsp),%edi
call   1070 <close@plt>
mov    0x18(%rsp),%edi
call   1070 <close@plt>
mov    0x1c(%rsp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd61(%rip),%rdi
jmp    12a8 <main+0xe8>
lea    0xd5d(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xd74(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%edi
call   1070 <close@plt>
mov    0x1c(%rsp),%edi
call   1070 <close@plt>
lea    0xd2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd25(%rip),%rbx
lea    0xc(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <scanf@plt>
lea    0xd11(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <scanf@plt>
mov    0x14(%rsp),%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <write@plt>
mov    0x14(%rsp),%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <write@plt>
mov    0x18(%rsp),%edi
lea    0x4(%rsp),%rsi
mov    $0x4,%edx
call   1090 <read@plt>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  0x4(%rsp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xca5(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.2 = [11 x i8] c"Process A\0A\00"
@.str.3 = [5 x i8] c"a = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [5 x i8] c"b = \00"
@.str.6 = [17 x i8] c"A: %f ^ %f = %f\0A\00"
@.str.7 = [11 x i8] c"Process B\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i32]
%7 = alloca [2 x i32]
%8 = alloca i64
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%16 = call i64 @pipe(i32* %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%23 = call i64 @pipe(i32* %22)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %21
%29 = call i64 (...) @fork()
store i64 %29, i64* %8
%30 = load i64, i64* %8
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %28
%33 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @exit(i32 1)
unreachable
35: ; preds = %28
%36 = load i64, i64* %8
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %67
38: ; preds = %35
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%44 = load i32, i32* %43
%45 = call i32 @close(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %9)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %10)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%51 = load i32, i32* %50
%52 = call i32 @write(i32 %51, float* %9, i32 4)
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%54 = load i32, i32* %53
%55 = call i32 @write(i32 %54, float* %10, i32 4)
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%57 = load i32, i32* %56
%58 = call i32 @read(i32 %57, float* %11, i32 4)
%59 = load float, float* %9
%60 = fpext float %59 to double
%61 = load float, float* %10
%62 = fpext float %61 to double
%63 = load float, float* %11
%64 = fpext float %63 to double
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %60, double %62, double %64)
%66 = call i32 @exit(i32 0)
unreachable
67: ; preds = %35
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%69 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%70 = load i32, i32* %69
%71 = call i32 @read(i32 %70, float* %12, i32 4)
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%73 = load i32, i32* %72
%74 = call i32 @read(i32 %73, float* %13, i32 4)
%75 = load float, float* %12
%76 = load float, float* %13
%77 = call float @powf(float %75, float %76)
store float %77, float* %14
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32 @write(i32 %79, float* %14, i32 4)
%81 = call i32 @wait(i32 0)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%83 = load i32, i32* %82
%84 = call i32 @close(i32 %83)
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%86 = load i32, i32* %85
%87 = call i32 @close(i32 %86)
%88 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%89 = load i32, i32* %88
%90 = call i32 @close(i32 %89)
%91 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%92 = load i32, i32* %91
%93 = call i32 @close(i32 %92)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"pipe\00"
@.str.1 = [5 x i8] c"fork\00"
@.str.3 = [5 x i8] c"a = \00"
@.str.4 = [3 x i8] c"%f\00"
@.str.5 = [5 x i8] c"b = \00"
@.str.6 = [17 x i8] c"A: %f ^ %f = %f\0A\00"
@str = [10 x i8] c"Process B\00"
@str.8 = [10 x i8] c"Process A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = bitcast [2 x i32]* %3 to i8*
%12 = bitcast [2 x i32]* %4 to i8*
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%14 = call i64 @pipe(i32* %13)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%21 = call i64 @pipe(i32* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
%27 = call i64 (...) @fork()
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %26
%33 = icmp eq i64 %27, 0
br i1 %33, label %34, label %63
34: ; preds = %32
%35 = bitcast float* %5 to i8*
%36 = bitcast float* %6 to i8*
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%38 = load i32, i32* %13
%39 = call i32 @close(i32 %38)
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%41 = load i32, i32* %40
%42 = call i32 @close(i32 %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %5)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), float* %6)
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%48 = load i32, i32* %47
%49 = call i32 @write(i32 %48, float* %5, i32 4)
%50 = load i32, i32* %47
%51 = call i32 @write(i32 %50, float* %6, i32 4)
%52 = bitcast float* %7 to i8*
%53 = load i32, i32* %20
%54 = call i32 @read(i32 %53, float* %7, i32 4)
%55 = load float, float* %5
%56 = fpext float %55 to double
%57 = load float, float* %6
%58 = fpext float %57 to double
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %56, double %58, double %60)
%62 = call i32 @exit(i32 0)
unreachable
63: ; preds = %32
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%65 = bitcast float* %8 to i8*
%66 = bitcast float* %9 to i8*
%67 = load i32, i32* %13
%68 = call i32 @read(i32 %67, float* %8, i32 4)
%69 = load i32, i32* %13
%70 = call i32 @read(i32 %69, float* %9, i32 4)
%71 = bitcast float* %10 to i8*
%72 = load float, float* %8
%73 = load float, float* %9
%74 = call float @powf(float %72, float %73)
store float %74, float* %10
%75 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%76 = load i32, i32* %75
%77 = call i32 @write(i32 %76, float* %10, i32 4)
%78 = call i32 @wait(i32 0)
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* %13
%83 = call i32 @close(i32 %82)
%84 = load i32, i32* %20
%85 = call i32 @close(i32 %84)
%86 = load i32, i32* %75
%87 = call i32 @close(i32 %86)
ret i32 0
}