#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 */

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int O_CREAT;
int O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int O_TRUNC;
int RAND_MAX;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ close(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getpid();
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ rand();
int /*<<< orphan*/ read(int, void *, int);
int /*<<< orphan*/ srand(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int time(int /*<<< orphan*/ *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, void *, int);
int main(int argc, char **argv) {
  int i, nb_proc, total;
  if (argc != 2 || !strcmp(argv[1], "-h")) {
    fprintf(stderr, "usage: %s NB_THREADS\n", argv[0]);
    return EXIT_FAILURE;
  }
  nb_proc = atoi(argv[1]);
  total = 0;
  char *path = "random.ipc";
  int fd;
  if ((fd = open(path, O_RDONLY | O_CREAT | O_TRUNC, 0644)) == -1) {
    perror("unable to open IPC file");
    return EXIT_FAILURE;
  }
  for (i = 0; i < nb_proc; ++i) {
    if (fork() == 0) {
      srand(time(NULL) ^ (getpid() << 16));
      int rand_val = (int)(10 * (float)rand() / RAND_MAX);
      if ((fd = open(path, O_RDWR)) == -1) {
        perror("[%d] unable to reopen IPC file");
        return EXIT_FAILURE;
      }
      lseek(fd, i * sizeof(int), SEEK_SET);
      write(fd, (void *)&rand_val, sizeof(int));
      close(fd);
      return EXIT_SUCCESS;
    }
  }
  for (i = 0; i < nb_proc; ++i)
    wait(NULL);
  for (i = 0; i < nb_proc; ++i) {
    int buf;
    read(fd, (void *)&buf, sizeof(int));
    total += buf;
  }
  printf("total = %d\n", total);
  close(fd);
  return EXIT_SUCCESS;
}


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)
cmpl   $0x2,-0x8(%rbp)
jne    123d <main+0x3d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd5(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    126a <main+0x6a>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb3(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146f <main+0x26f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xd95(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
mov    0x2d58(%rip),%rax
or     (%rax),%esi
mov    0x2d47(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    12e0 <main+0xe0>
lea    0xd5e(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146f <main+0x26f>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13e7 <main+0x1e7>
mov    $0x0,%al
call   1110 <fork@plt>
cmp    $0x0,%rax
jne    13d4 <main+0x1d4>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <time@plt>
mov    %eax,-0x38(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x38(%rbp),%edi
shl    $0x10,%eax
xor    %eax,%edi
call   1090 <srand@plt>
mov    $0x0,%al
call   1120 <rand@plt>
cvtsi2ss %rax,%xmm1
movss  0xcc8(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    0x2c85(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2c7b(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    138f <main+0x18f>
lea    0xcc7(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146f <main+0x26f>
mov    -0x2c(%rbp),%edi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
mov    0x2c0d(%rip),%rax
mov    (%rax),%edx
call   1060 <lseek@plt>
mov    -0x2c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
mov    0x2bd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    146f <main+0x26f>
jmp    13d9 <main+0x1d9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12e7 <main+0xe7>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1411 <main+0x211>
xor    %eax,%eax
mov    %eax,%edi
call   1100 <wait@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    13ee <main+0x1ee>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    144c <main+0x24c>
mov    -0x2c(%rbp),%edi
lea    -0x34(%rbp),%rsi
mov    $0x4,%edx
call   1080 <read@plt>
mov    -0x34(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1418 <main+0x218>
mov    -0x1c(%rbp),%esi
lea    0xc09(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1070 <close@plt>
mov    0x2b36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    12ef <main+0xef>
mov    0x8(%rbx),%rbp
lea    0xde1(%rip),%rsi
mov    %rbp,%rdi
call   10a0 <strcmp@plt>
test   %eax,%eax
je     12ef <main+0xef>
mov    %rbp,%rdi
call   10f0 <atoi@plt>
mov    0x2d8e(%rip),%rcx
mov    0x2daf(%rip),%rdx
mov    (%rdx),%esi
or     (%rcx),%esi
mov    %eax,%r12d
mov    0x2d99(%rip),%rax
or     (%rax),%esi
lea    0xdbd(%rip),%rdi
xor    %ebx,%ebx
mov    $0x1a4,%edx
xor    %eax,%eax
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     13cd <main+0x1cd>
mov    %eax,%r14d
test   %r12d,%r12d
jle    13a1 <main+0x1a1>
mov    %r12d,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1110 <fork@plt>
test   %rax,%rax
je     1313 <main+0x113>
add    $0x4,%ebx
add    $0xffffffff,%ebp
jne    1290 <main+0x90>
test   %r12d,%r12d
jle    139f <main+0x19f>
mov    %r12d,%ebx
xor    %edi,%edi
call   1100 <wait@plt>
add    $0xffffffff,%ebx
jne    12b0 <main+0xb0>
xor    %ebx,%ebx
test   %r12d,%r12d
jle    13a1 <main+0x1a1>
lea    0x8(%rsp),%r15
nopl   0x0(%rax)
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1080 <read@plt>
add    0x8(%rsp),%ebx
add    $0xffffffff,%r12d
jne    12d0 <main+0xd0>
jmp    13a1 <main+0x1a1>
mov    0x2cc2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd05(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2c9a(%rip),%rax
jmp    13be <main+0x1be>
xor    %edi,%edi
call   10c0 <time@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1040 <getpid@plt>
shl    $0x10,%eax
xor    %eax,%ebp
mov    %ebp,%edi
call   1090 <srand@plt>
xor    %eax,%eax
call   1120 <rand@plt>
cvtsi2ss %rax,%xmm0
mulss  0xcbd(%rip),%xmm0
mov    0x2c7e(%rip),%rax
cvtsi2ssl (%rax),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,0xc(%rsp)
mov    0x2c77(%rip),%rax
mov    (%rax),%esi
lea    0xcb3(%rip),%rdi
xor    %eax,%eax
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     13d6 <main+0x1d6>
mov    %eax,%ebp
mov    0x2c31(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <lseek@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <write@plt>
mov    %ebp,%edi
jmp    13b2 <main+0x1b2>
xor    %ebx,%ebx
lea    0xcb7(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    0x2be2(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc54(%rip),%rdi
jmp    13dd <main+0x1dd>
lea    0xc63(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bbf(%rip),%rax
jmp    13be <main+0x1be>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"usage: %s NB_THREADS\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"random.ipc\00"
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [24 x i8] c"unable to open IPC file\00"
@RAND_MAX = global i32 0
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"[%d] unable to reopen IPC file\00"
@SEEK_SET = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [12 x i8] c"total = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %15, %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
store i32 %27, i32* %3
br label %121
28: ; preds = %15
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %7
store i32 0, i32* %8
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %9
%33 = load i8*, i8** %9
%34 = load i32, i32* @O_RDONLY
%35 = load i32, i32* @O_CREAT
%36 = or i32 %34, %35
%37 = load i32, i32* @O_TRUNC
%38 = or i32 %36, %37
%39 = call i32 (i8*, i32, ...) @open(i8* %33, i32 %38, i32 420)
store i32 %39, i32* %10
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %28
%42 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* @EXIT_FAILURE
store i32 %43, i32* %3
br label %121
44: ; preds = %28
store i32 0, i32* %6
br label %45
45: ; preds = %87, %44
%46 = load i32, i32* %6
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %90
49: ; preds = %45
%50 = call i64 (...) @fork()
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %86
52: ; preds = %49
%53 = call i32 @time(i32* null)
%54 = call i32 (...) @getpid()
%55 = shl i32 %54, 16
%56 = xor i32 %53, %55
%57 = call i32 @srand(i32 %56)
%58 = call i64 (...) @rand()
%59 = sitofp i64 %58 to float
%60 = fmul float 1.000000e+01, %59
%61 = load i32, i32* @RAND_MAX
%62 = sitofp i32 %61 to float
%63 = fdiv float %60, %62
%64 = fptosi float %63 to i32
store i32 %64, i32* %11
%65 = load i8*, i8** %9
%66 = load i32, i32* @O_RDWR
%67 = call i32 (i8*, i32, ...) @open(i8* %65, i32 %66)
store i32 %67, i32* %10
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %72
69: ; preds = %52
%70 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%71 = load i32, i32* @EXIT_FAILURE
store i32 %71, i32* %3
br label %121
72: ; preds = %52
%73 = load i32, i32* %10
%74 = load i32, i32* %6
%75 = sext i32 %74 to i64
%76 = mul i64 %75, 4
%77 = trunc i64 %76 to i32
%78 = load i32, i32* @SEEK_SET
%79 = call i32 @lseek(i32 %73, i32 %77, i32 %78)
%80 = load i32, i32* %10
%81 = bitcast i32* %11 to i8*
%82 = call i32 @write(i32 %80, i8* %81, i32 4)
%83 = load i32, i32* %10
%84 = call i32 @close(i32 %83)
%85 = load i32, i32* @EXIT_SUCCESS
store i32 %85, i32* %3
br label %121
86: ; preds = %49
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %45
90: ; preds = %45
store i32 0, i32* %6
br label %91
91: ; preds = %97, %90
%92 = load i32, i32* %6
%93 = load i32, i32* %7
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %100
95: ; preds = %91
%96 = call i32 @wait(i32* null)
br label %97
97: ; preds = %95
%98 = load i32, i32* %6
%99 = add nsw i32 %98, 1
store i32 %99, i32* %6
br label %91
100: ; preds = %91
store i32 0, i32* %6
br label %101
101: ; preds = %112, %100
%102 = load i32, i32* %6
%103 = load i32, i32* %7
%104 = icmp slt i32 %102, %103
br i1 %104, label %105, label %115
105: ; preds = %101
%106 = load i32, i32* %10
%107 = bitcast i32* %12 to i8*
%108 = call i32 @read(i32 %106, i8* %107, i32 4)
%109 = load i32, i32* %12
%110 = load i32, i32* %8
%111 = add nsw i32 %110, %109
store i32 %111, i32* %8
br label %112
112: ; preds = %105
%113 = load i32, i32* %6
%114 = add nsw i32 %113, 1
store i32 %114, i32* %6
br label %101
115: ; preds = %101
%116 = load i32, i32* %8
%117 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %116)
%118 = load i32, i32* %10
%119 = call i32 @close(i32 %118)
%120 = load i32, i32* @EXIT_SUCCESS
store i32 %120, i32* %3
br label %121
121: ; preds = %115, %72, %69, %41, %21
%122 = load i32, i32* %3
ret i32 %122
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@stderr = global i32 0
@.str.1 = [22 x i8] c"usage: %s NB_THREADS\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [11 x i8] c"random.ipc\00"
@O_RDONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.3 = [24 x i8] c"unable to open IPC file\00"
@RAND_MAX = global i32 0
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"[%d] unable to reopen IPC file\00"
@SEEK_SET = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [12 x i8] c"total = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6, %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
br label %87
16: ; preds = %6
%17 = tail call i32 @atoi(i8* %8)
%18 = load i32, i32* @O_RDONLY
%19 = load i32, i32* @O_CREAT
%20 = or i32 %19, %18
%21 = load i32, i32* @O_TRUNC
%22 = or i32 %20, %21
%23 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 420)
%24 = icmp eq i32 %23, -1
br i1 %24, label %27, label %25
25: ; preds = %16
%26 = icmp sgt i32 %17, 0
br i1 %26, label %31, label %82
27: ; preds = %16
%28 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
br label %87
30: ; preds = %63
br i1 %26, label %69, label %82
31: ; preds = %25, %63
%32 = phi i32 [ %64, %63 ], [ 0, %25 ]
%33 = tail call i64 (...) @fork()
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %63
35: ; preds = %31
%36 = tail call i32 @time(i32* null)
%37 = tail call i32 (...) @getpid()
%38 = shl i32 %37, 16
%39 = xor i32 %38, %36
%40 = tail call i32 @srand(i32 %39)
%41 = bitcast i32* %3 to i8*
%42 = tail call i64 (...) @rand()
%43 = sitofp i64 %42 to float
%44 = fmul float %43, 1.000000e+01
%45 = load i32, i32* @RAND_MAX
%46 = sitofp i32 %45 to float
%47 = fdiv float %44, %46
%48 = fptosi float %47 to i32
store i32 %48, i32* %3
%49 = load i32, i32* @O_RDWR
%50 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %54
52: ; preds = %35
%53 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %60
54: ; preds = %35
%55 = shl i32 %32, 2
%56 = load i32, i32* @SEEK_SET
%57 = tail call i32 @lseek(i32 %50, i32 %55, i32 %56)
%58 = call i32 @write(i32 %50, i8* %41, i32 4)
%59 = tail call i32 @close(i32 %50)
br label %60
60: ; preds = %54, %52
%61 = phi i32* [ @EXIT_FAILURE, %52 ], [ @EXIT_SUCCESS, %54 ]
%62 = load i32, i32* %61
br label %87
63: ; preds = %31
%64 = add nuw nsw i32 %32, 1
%65 = icmp eq i32 %64, %17
br i1 %65, label %30, label %31
66: ; preds = %69
br i1 %26, label %67, label %82
67: ; preds = %66
%68 = bitcast i32* %4 to i8*
br label %74
69: ; preds = %30, %69
%70 = phi i32 [ %72, %69 ], [ 0, %30 ]
%71 = tail call i32 @wait(i32* null)
%72 = add nuw nsw i32 %70, 1
%73 = icmp eq i32 %72, %17
br i1 %73, label %66, label %69
74: ; preds = %67, %74
%75 = phi i32 [ 0, %67 ], [ %79, %74 ]
%76 = phi i32 [ 0, %67 ], [ %80, %74 ]
%77 = call i32 @read(i32 %23, i8* %68, i32 4)
%78 = load i32, i32* %4
%79 = add nsw i32 %78, %75
%80 = add nuw nsw i32 %76, 1
%81 = icmp eq i32 %80, %17
br i1 %81, label %82, label %74
82: ; preds = %74, %25, %30, %66
%83 = phi i32 [ 0, %66 ], [ 0, %30 ], [ 0, %25 ], [ %79, %74 ]
%84 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i32 %83)
%85 = tail call i32 @close(i32 %23)
%86 = load i32, i32* @EXIT_SUCCESS
br label %87
87: ; preds = %27, %60, %82, %11
%88 = phi i32 [ %15, %11 ], [ %29, %27 ], [ %62, %60 ], [ %86, %82 ]
ret i32 %88
}