#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 pid_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fdopen(int, char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ pipe(int *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, const char *argv[]) {
  int fd_to_child[2];
  int fd_to_parent[2];
  pid_t child_pid;
  pipe(fd_to_child);
  pipe(fd_to_parent);
  child_pid = fork();
  if (child_pid == -1) {
    perror("fork");
    exit(1);
  }
  if (child_pid == 0) {
    close(fd_to_child[1]);
    close(fd_to_parent[0]);
    FILE *input = fdopen(fd_to_child[0], "r");
    FILE *output = fdopen(fd_to_parent[1], "w");
    int n;
    fscanf(input, "%d", &n);
    int i;
    int sum;
    for (i = 1; i < n; i++) {
      if (n % i == 0)
        sum += i;
    }
    if (sum == n)
      fprintf(output, "True\n");
    else
      fprintf(output, "False\n");
    exit(0);
  } else {
    close(fd_to_child[0]);
    close(fd_to_parent[1]);
    int n;
    scanf("%d", &n);
    FILE *output = fdopen(fd_to_child[1], "w");
    FILE *input = fdopen(fd_to_parent[0], "r");
    fprintf(output, "%d\n", n);
    fflush(output);
    char answer[200];
    fscanf(input, "%s", answer);
    printf("%s\n", answer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <pipe@plt>
lea    -0x20(%rbp),%rdi
call   1060 <pipe@plt>
mov    $0x0,%al
call   10d0 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1205 <main+0x55>
lea    0xe0a(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
jne    12d6 <main+0x126>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    -0x18(%rbp),%edi
lea    0xddc(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
lea    0xdcb(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdb9(%rip),%rsi
lea    -0x3c(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x1,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    129a <main+0xea>
mov    -0x3c(%rbp),%eax
cltd
idivl  -0x40(%rbp)
cmp    $0x0,%edx
jne    1287 <main+0xd7>
mov    -0x40(%rbp),%eax
add    -0x44(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    128c <main+0xdc>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1262 <main+0xb2>
mov    -0x44(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    12bd <main+0x10d>
mov    -0x38(%rbp),%rdi
lea    0xd5b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    12cf <main+0x11f>
mov    -0x38(%rbp),%rdi
lea    0xd4a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
lea    0xd1c(%rip),%rdi
lea    -0x48(%rbp),%rsi
call   10a0 <scanf@plt>
mov    -0x14(%rbp),%edi
lea    0xd07(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%edi
lea    0xcf2(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%edx
lea    0xcef(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x50(%rbp),%rdi
call   1080 <fflush@plt>
mov    -0x58(%rbp),%rdi
lea    -0x120(%rbp),%rdx
lea    0xcd1(%rip),%rsi
mov    $0x0,%al
call   1040 <fscanf@plt>
lea    -0x120(%rbp),%rsi
lea    0xcbf(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
lea    0x14(%rsp),%rdi
call   1060 <pipe@plt>
lea    0xc(%rsp),%rdi
call   1060 <pipe@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %eax,%eax
je     1291 <main+0xd1>
cmp    $0xffffffff,%eax
je     132d <main+0x16d>
mov    0x14(%rsp),%edi
call   1050 <close@plt>
mov    0x10(%rsp),%edi
call   1050 <close@plt>
lea    0xdfa(%rip),%rdi
lea    0x1c(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0x18(%rsp),%edi
lea    0xde3(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
lea    0xdce(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,%r14
mov    0x1c(%rsp),%edx
lea    0xdcf(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1080 <fflush@plt>
lea    0xdba(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <fscanf@plt>
lea    0xda4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x18(%rsp),%edi
call   1050 <close@plt>
mov    0xc(%rsp),%edi
call   1050 <close@plt>
mov    0x14(%rsp),%edi
lea    0xd57(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,%rbx
mov    0x10(%rsp),%edi
lea    0xd46(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,%r14
lea    0xd39(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <fscanf@plt>
mov    0x20(%rsp),%ecx
cmp    $0x2,%ecx
jl     1343 <main+0x183>
lea    -0x1(%rcx),%r8d
cmp    $0x2,%ecx
jne    1363 <main+0x1a3>
mov    $0x1,%edi
test   $0x1,%r8b
je     130a <main+0x14a>
mov    %ecx,%eax
cltd
idiv   %edi
xor    %eax,%eax
test   %edx,%edx
cmove  %edi,%eax
add    %eax,%esi
xor    %eax,%eax
cmp    %ecx,%esi
sete   %al
lea    0xcf4(%rip),%rcx
lea    0xcf3(%rip),%rdi
cmove  %rcx,%rdi
mov    $0x6,%esi
sub    %rax,%rsi
jmp    134f <main+0x18f>
lea    0xccc(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    0xcc2(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    %r8d,%r9d
and    $0xfffffffe,%r9d
mov    $0x1,%edi
jmp    138e <main+0x1ce>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    %eax,%esi
add    $0x2,%edi
cmp    %r9d,%ebx
je     12f6 <main+0x136>
mov    %ecx,%eax
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
je     139b <main+0x1db>
xor    %eax,%eax
add    %eax,%esi
lea    0x1(%rdi),%ebx
mov    %ecx,%eax
cltd
idiv   %ebx
mov    %ebx,%eax
test   %edx,%edx
je     1380 <main+0x1c0>
xor    %eax,%eax
jmp    1380 <main+0x1c0>

LLVM IR (-O0):
@.str = [5 x i8] c"fork\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"True\0A\00"
@.str.5 = [7 x i8] c"False\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"%s\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 i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%19 = call i32 @pipe(i32* %18)
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%21 = call i32 @pipe(i32* %20)
%22 = call i32 (...) @fork()
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %28
25: ; preds = %2
%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 = %2
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %75
31: ; preds = %28
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%33 = load i32, i32* %32
%34 = call i32 @close(i32 %33)
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%36 = load i32, i32* %35
%37 = call i32 @close(i32 %36)
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%39 = load i32, i32* %38
%40 = call i32* @fdopen(i32 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %40, i32** %9
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%42 = load i32, i32* %41
%43 = call i32* @fdopen(i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %43, i32** %10
%44 = load i32*, i32** %9
%45 = call i32 (i32*, i8*, ...) @fscanf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %11)
store i32 1, i32* %12
br label %46
46: ; preds = %60, %31
%47 = load i32, i32* %12
%48 = load i32, i32* %11
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %63
50: ; preds = %46
%51 = load i32, i32* %11
%52 = load i32, i32* %12
%53 = srem i32 %51, %52
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %50
%56 = load i32, i32* %12
%57 = load i32, i32* %13
%58 = add nsw i32 %57, %56
store i32 %58, i32* %13
br label %59
59: ; preds = %55, %50
br label %60
60: ; preds = %59
%61 = load i32, i32* %12
%62 = add nsw i32 %61, 1
store i32 %62, i32* %12
br label %46
63: ; preds = %46
%64 = load i32, i32* %13
%65 = load i32, i32* %11
%66 = icmp eq i32 %64, %65
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i32*, i32** %10
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %68, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %73
70: ; preds = %63
%71 = load i32*, i32** %10
%72 = call i32 (i32*, i8*, ...) @fprintf(i32* %71, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %73
73: ; preds = %70, %67
%74 = call i32 @exit(i32 0)
unreachable
75: ; preds = %28
%76 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%77 = load i32, i32* %76
%78 = call i32 @close(i32 %77)
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%80 = load i32, i32* %79
%81 = call i32 @close(i32 %80)
%82 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %14)
%83 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%84 = load i32, i32* %83
%85 = call i32* @fdopen(i32 %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %85, i32** %15
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%87 = load i32, i32* %86
%88 = call i32* @fdopen(i32 %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %88, i32** %16
%89 = load i32*, i32** %15
%90 = load i32, i32* %14
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %89, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %90)
%92 = load i32*, i32** %15
%93 = call i32 @fflush(i32* %92)
%94 = load i32*, i32** %16
%95 = getelementptr inbounds [200 x i8], [200 x i8]* %17, i64 0, i64 0
%96 = call i32 (i32*, i8*, ...) @fscanf(i32* %94, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %95)
%97 = getelementptr inbounds [200 x i8], [200 x i8]* %17, i64 0, i64 0
%98 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %97)
br label %99
99: ; preds = %75
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"fork\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"True\0A\00"
@.str.5 = [7 x i8] c"False\0A\00"
@.str.6 = [4 x i8] c"%d\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [2 x i32]
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca i32
%7 = alloca [200 x i8]
%8 = bitcast [2 x i32]* %3 to i8*
%9 = bitcast [2 x i32]* %4 to i8*
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%11 = call i32 @pipe(i32* %10)
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%13 = call i32 @pipe(i32* %12)
%14 = call i32 (...) @fork()
switch i32 %14, label %74 [
i32 -1, label %15
i32 0, label %18
]
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%20 = load i32, i32* %19
%21 = call i32 @close(i32 %20)
%22 = load i32, i32* %12
%23 = call i32 @close(i32 %22)
%24 = load i32, i32* %10
%25 = call i32* @fdopen(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%27 = load i32, i32* %26
%28 = call i32* @fdopen(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = bitcast i32* %5 to i8*
%30 = call i32 (i32*, i8*, ...) @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%31 = load i32, i32* %5
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %69
33: ; preds = %18
%34 = add i32 %31, -1
%35 = and i32 %34, 1
%36 = icmp eq i32 %31, 2
br i1 %36, label %55, label %37
37: ; preds = %33
%38 = and i32 %34, -2
br label %39
39: ; preds = %39, %37
%40 = phi i32 [ 1, %37 ], [ %52, %39 ]
%41 = phi i32 [ undef, %37 ], [ %51, %39 ]
%42 = phi i32 [ 0, %37 ], [ %53, %39 ]
%43 = srem i32 %31, %40
%44 = icmp eq i32 %43, 0
%45 = select i1 %44, i32 %40, i32 0
%46 = add nsw i32 %45, %41
%47 = add nuw nsw i32 %40, 1
%48 = srem i32 %31, %47
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i32 %47, i32 0
%51 = add nsw i32 %50, %46
%52 = add nuw nsw i32 %40, 2
%53 = add i32 %42, 2
%54 = icmp eq i32 %53, %38
br i1 %54, label %55, label %39
55: ; preds = %39, %33
%56 = phi i32 [ 1, %33 ], [ %52, %39 ]
%57 = phi i32 [ undef, %33 ], [ %51, %39 ]
%58 = icmp eq i32 %35, 0
br i1 %58, label %64, label %59
59: ; preds = %55
%60 = srem i32 %31, %56
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i32 %56, i32 0
%63 = add nsw i32 %62, %57
br label %64
64: ; preds = %55, %59
%65 = phi i32 [ %57, %55 ], [ %63, %59 ]
%66 = icmp eq i32 %65, %31
%67 = select i1 %66, i64 5, i64 6
%68 = select i1 %66, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0)
br label %69
69: ; preds = %64, %18
%70 = phi i64 [ 5, %18 ], [ %67, %64 ]
%71 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %18 ], [ %68, %64 ]
%72 = call i64 @fwrite(i8* %71, i64 %70, i64 1, i32* %28)
%73 = call i32 @exit(i32 0)
unreachable
74: ; preds = %2
%75 = load i32, i32* %10
%76 = call i32 @close(i32 %75)
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%78 = load i32, i32* %77
%79 = call i32 @close(i32 %78)
%80 = bitcast i32* %6 to i8*
%81 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%82 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%83 = load i32, i32* %82
%84 = call i32* @fdopen(i32 %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%85 = load i32, i32* %12
%86 = call i32* @fdopen(i32 %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%87 = load i32, i32* %6
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %87)
%89 = call i32 @fflush(i32* %84)
%90 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%91 = call i32 (i32*, i8*, ...) @fscanf(i32* %86, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %90)
%92 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %90)
ret i32 0
}