#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int dup2(int, int /*<<< orphan*/);
int execl(char *, char *, char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fcntl(int, int /*<<< orphan*/, int);
int floor(double);
scalar_t__ fork();
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int pipe(int *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int spawn_computes(pid_t **pids, int fds[2], int limit, int nprocs) {
  int flags;
  int numbers_per_proc = floor((double)limit / (double)nprocs);
  int end = 0;
  int i;
  assert(pids != NULL);
  assert(fds != NULL);
  *pids = (pid_t *)malloc(limit * sizeof(pid_t));
  if (*pids == NULL) {
    perror("Could not allocate memory");
    exit(EXIT_FAILURE);
  }
  if (pipe(fds) == -1) {
    perror("Unable to open compute pipe");
    return -1;
  }
  for (i = 0; i < nprocs; i++) {
    pid_t pid;
    char start_str[11];
    char end_str[11];
    int start;
    start = end + 1;
    if (i == 0) {
      end = numbers_per_proc + (limit % nprocs);
    } else {
      end = start + numbers_per_proc - 1;
    }
    snprintf(start_str, 11, "%d", start);
    snprintf(end_str, 11, "%d", end);
    pid = fork();
    if (pid > 0) {
      (*pids)[i] = pid;
    } else if (pid == 0) {
      if (dup2(fds[1], STDOUT_FILENO) == -1) {
        perror("Could not duplicate file descriptor");
        return -1;
      }
      close(fds[0]);
      if (execl("./compute", "./compute", "p", start_str, end_str, NULL) ==
          -1) {
        perror("Unable to exec");
        return -1;
      }
    } else {
      perror("Unable to spawn compute");
    }
  }
  close(fds[1]);
  if ((flags = fcntl(fds[0], F_GETFL, 0)) == -1) {
    flags = 0;
  }
  if (fcntl(fds[0], F_SETFL, flags | O_NONBLOCK) == -1) {
    perror("Could not set file control options");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<spawn_computes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   10d0 <floor@plt>
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1258 <spawn_computes+0x98>
lea    0xdbb(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
jne    1282 <spawn_computes+0xc2>
lea    0xda9(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <spawn_computes+0x2a2>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    13e5 <spawn_computes+0x225>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    12c2 <spawn_computes+0x102>
mov    -0x28(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x20(%rbp)
mov    -0x58(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x2c(%rbp)
jmp    12ce <spawn_computes+0x10e>
mov    -0x54(%rbp),%eax
add    -0x28(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
lea    -0x43(%rbp),%rdi
mov    -0x54(%rbp),%ecx
mov    $0xb,%esi
lea    0xd55(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x4e(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    $0xb,%esi
lea    0xd3d(%rip),%rdx
call   1050 <snprintf@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jle    132c <spawn_computes+0x16c>
mov    -0x38(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x30(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
jmp    13d2 <spawn_computes+0x212>
cmpq   $0x0,-0x38(%rbp)
jne    13c1 <spawn_computes+0x201>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
mov    0x2cab(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
jne    136d <spawn_computes+0x1ad>
lea    0xcdd(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <spawn_computes+0x2a2>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1060 <close@plt>
lea    -0x43(%rbp),%rcx
lea    -0x4e(%rbp),%r8
lea    0xcd6(%rip),%rsi
lea    0xcd9(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %rsi,%rdi
call   10c0 <execl@plt>
cmp    $0xffffffff,%eax
jne    13bc <spawn_computes+0x1fc>
lea    0xcbe(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <spawn_computes+0x2a2>
jmp    13cd <spawn_computes+0x20d>
lea    0xcb0(%rip),%rdi
call   10a0 <perror@plt>
jmp    13d2 <spawn_computes+0x212>
jmp    13d7 <spawn_computes+0x217>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1289 <spawn_computes+0xc9>
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2bca(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
jne    141a <spawn_computes+0x25a>
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
mov    0x2ba9(%rip),%rax
mov    (%rax),%esi
mov    -0x24(%rbp),%edx
mov    0x2bad(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
jne    145b <spawn_computes+0x29b>
lea    0xc46(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1462 <spawn_computes+0x2a2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spawn_computes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %edx,%ebx
cvtsi2sd %edx,%xmm0
mov    %rsi,%r14
mov    %rdi,%r15
mov    %ecx,(%rsp)
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
call   10d0 <floor@plt>
mov    %eax,0x4(%rsp)
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1080 <assert@plt>
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1080 <assert@plt>
mov    %rbx,0x10(%rsp)
lea    0x0(,%rbx,8),%edi
call   1090 <malloc@plt>
mov    %r15,0x18(%rsp)
mov    %rax,(%r15)
test   %rax,%rax
je     13ca <spawn_computes+0x20a>
mov    %r14,%rdi
call   1070 <pipe@plt>
cmp    $0xffffffff,%eax
je     139c <spawn_computes+0x1dc>
mov    %r14,0x8(%rsp)
cmpl   $0x0,(%rsp)
mov    0x4(%rsp),%r15d
jle    1342 <spawn_computes+0x182>
mov    (%rsp),%ebx
lea    0xddb(%rip),%r13
lea    0x2d(%rsp),%rbp
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    1289 <spawn_computes+0xc9>
nopl   0x0(%rax,%rax,1)
mov    0x18(%rsp),%rcx
mov    (%rcx),%rcx
mov    %rax,(%rcx,%r14,8)
add    $0x1,%r14
cmp    %r14,%rbx
je     1342 <spawn_computes+0x182>
lea    0x1(%r12),%ecx
test   %r14,%r14
jne    129f <spawn_computes+0xdf>
mov    0x10(%rsp),%rax
cltd
idivl  (%rsp)
mov    %edx,%r12d
add    %r15d,%r12d
mov    %rbp,%rdi
mov    $0xb,%esi
mov    %r13,%rdx
call   1050 <snprintf@plt>
lea    0x22(%rsp),%rdi
mov    $0xb,%esi
mov    %r13,%rdx
mov    %r12d,%ecx
call   1050 <snprintf@plt>
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
jg     1270 <spawn_computes+0xb0>
jne    1331 <spawn_computes+0x171>
mov    0x8(%rsp),%r15
mov    0x4(%r15),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
call   1040 <dup2@plt>
cmp    $0xffffffff,%eax
je     13b8 <spawn_computes+0x1f8>
mov    (%r15),%edi
call   1060 <close@plt>
lea    0xd59(%rip),%rdi
mov    %rdi,%rsi
lea    0xd59(%rip),%rdx
mov    %rbp,%rcx
lea    0x22(%rsp),%r8
xor    %r9d,%r9d
call   10c0 <execl@plt>
cmp    $0xffffffff,%eax
mov    0x4(%rsp),%r15d
jne    127c <spawn_computes+0xbc>
jmp    13c1 <spawn_computes+0x201>
lea    0xd40(%rip),%rdi
call   10a0 <perror@plt>
jmp    127c <spawn_computes+0xbc>
mov    0x8(%rsp),%rbp
mov    0x4(%rbp),%edi
call   1060 <close@plt>
mov    0x0(%rbp),%edi
mov    0x2c6f(%rip),%rax
mov    (%rax),%esi
xor    %ebx,%ebx
xor    %edx,%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
cmove  %ebx,%eax
mov    0x0(%rbp),%edi
mov    0x2c5c(%rip),%rcx
mov    (%rcx),%esi
mov    0x2c63(%rip),%rcx
or     (%rcx),%eax
mov    %eax,%edx
call   1030 <fcntl@plt>
cmp    $0xffffffff,%eax
je     13a5 <spawn_computes+0x1e5>
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc77(%rip),%rdi
jmp    13ac <spawn_computes+0x1ec>
lea    0xce4(%rip),%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    138b <spawn_computes+0x1cb>
lea    0xc7a(%rip),%rdi
jmp    13ac <spawn_computes+0x1ec>
lea    0xca1(%rip),%rdi
jmp    13ac <spawn_computes+0x1ec>
lea    0xc2f(%rip),%rdi
call   10a0 <perror@plt>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Could not allocate memory\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"Unable to open compute pipe\00"
@.str.2 = [3 x i8] c"%d\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [36 x i8] c"Could not duplicate file descriptor\00"
@.str.4 = [10 x i8] c"./compute\00"
@.str.5 = [2 x i8] c"p\00"
@.str.6 = [15 x i8] c"Unable to exec\00"
@.str.7 = [24 x i8] c"Unable to spawn compute\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [35 x i8] c"Could not set file control options\00"
define i32 @spawn_computes(i64** %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i64**
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca [11 x i8]
%16 = alloca [11 x i8]
%17 = alloca i32
store i64** %0, i64*** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%18 = load i32, i32* %8
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %9
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
%23 = call i32 @floor(double %22)
store i32 %23, i32* %11
store i32 0, i32* %12
%24 = load i64**, i64*** %6
%25 = icmp ne i64** %24, null
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32*, i32** %7
%29 = icmp ne i32* %28, null
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 8
%35 = trunc i64 %34 to i32
%36 = call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i64*
%38 = load i64**, i64*** %6
store i64* %37, i64** %38
%39 = load i64**, i64*** %6
%40 = load i64*, i64** %39
%41 = icmp eq i64* %40, null
br i1 %41, label %42, label %46
42: ; preds = %4
%43 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%44 = load i32, i32* @EXIT_FAILURE
%45 = call i32 @exit(i32 %44)
unreachable
46: ; preds = %4
%47 = load i32*, i32** %7
%48 = call i32 @pipe(i32* %47)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %146
52: ; preds = %46
store i32 0, i32* %13
br label %53
53: ; preds = %118, %52
%54 = load i32, i32* %13
%55 = load i32, i32* %9
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %121
57: ; preds = %53
%58 = load i32, i32* %12
%59 = add nsw i32 %58, 1
store i32 %59, i32* %17
%60 = load i32, i32* %13
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %57
%63 = load i32, i32* %11
%64 = load i32, i32* %8
%65 = load i32, i32* %9
%66 = srem i32 %64, %65
%67 = add nsw i32 %63, %66
store i32 %67, i32* %12
br label %73
68: ; preds = %57
%69 = load i32, i32* %17
%70 = load i32, i32* %11
%71 = add nsw i32 %69, %70
%72 = sub nsw i32 %71, 1
store i32 %72, i32* %12
br label %73
73: ; preds = %68, %62
%74 = getelementptr inbounds [11 x i8], [11 x i8]* %15, i64 0, i64 0
%75 = load i32, i32* %17
%76 = call i32 @snprintf(i8* %74, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = getelementptr inbounds [11 x i8], [11 x i8]* %16, i64 0, i64 0
%78 = load i32, i32* %12
%79 = call i32 @snprintf(i8* %77, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %78)
%80 = call i64 (...) @fork()
store i64 %80, i64* %14
%81 = load i64, i64* %14
%82 = icmp sgt i64 %81, 0
br i1 %82, label %83, label %90
83: ; preds = %73
%84 = load i64, i64* %14
%85 = load i64**, i64*** %6
%86 = load i64*, i64** %85
%87 = load i32, i32* %13
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i64, i64* %86, i64 %88
store i64 %84, i64* %89
br label %117
90: ; preds = %73
%91 = load i64, i64* %14
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %114
93: ; preds = %90
%94 = load i32*, i32** %7
%95 = getelementptr inbounds i32, i32* %94, i64 1
%96 = load i32, i32* %95
%97 = load i32, i32* @STDOUT_FILENO
%98 = call i32 @dup2(i32 %96, i32 %97)
%99 = icmp eq i32 %98, -1
br i1 %99, label %100, label %102
100: ; preds = %93
%101 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %5
br label %146
102: ; preds = %93
%103 = load i32*, i32** %7
%104 = getelementptr inbounds i32, i32* %103, i64 0
%105 = load i32, i32* %104
%106 = call i32 @close(i32 %105)
%107 = getelementptr inbounds [11 x i8], [11 x i8]* %15, i64 0, i64 0
%108 = getelementptr inbounds [11 x i8], [11 x i8]* %16, i64 0, i64 0
%109 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %107, i8* %108, i32* null)
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %113
111: ; preds = %102
%112 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %5
br label %146
113: ; preds = %102
br label %116
114: ; preds = %90
%115 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %116
116: ; preds = %114, %113
br label %117
117: ; preds = %116, %83
br label %118
118: ; preds = %117
%119 = load i32, i32* %13
%120 = add nsw i32 %119, 1
store i32 %120, i32* %13
br label %53
121: ; preds = %53
%122 = load i32*, i32** %7
%123 = getelementptr inbounds i32, i32* %122, i64 1
%124 = load i32, i32* %123
%125 = call i32 @close(i32 %124)
%126 = load i32*, i32** %7
%127 = getelementptr inbounds i32, i32* %126, i64 0
%128 = load i32, i32* %127
%129 = load i32, i32* @F_GETFL
%130 = call i32 @fcntl(i32 %128, i32 %129, i32 0)
store i32 %130, i32* %10
%131 = icmp eq i32 %130, -1
br i1 %131, label %132, label %133
132: ; preds = %121
store i32 0, i32* %10
br label %133
133: ; preds = %132, %121
%134 = load i32*, i32** %7
%135 = getelementptr inbounds i32, i32* %134, i64 0
%136 = load i32, i32* %135
%137 = load i32, i32* @F_SETFL
%138 = load i32, i32* %10
%139 = load i32, i32* @O_NONBLOCK
%140 = or i32 %138, %139
%141 = call i32 @fcntl(i32 %136, i32 %137, i32 %140)
%142 = icmp eq i32 %141, -1
br i1 %142, label %143, label %145
143: ; preds = %133
%144 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
store i32 -1, i32* %5
br label %146
145: ; preds = %133
store i32 0, i32* %5
br label %146
146: ; preds = %145, %143, %111, %100, %50
%147 = load i32, i32* %5
ret i32 %147
}

LLVM IR (-O2):
@.str = [26 x i8] c"Could not allocate memory\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [28 x i8] c"Unable to open compute pipe\00"
@.str.2 = [3 x i8] c"%d\00"
@STDOUT_FILENO = global i32 0
@.str.3 = [36 x i8] c"Could not duplicate file descriptor\00"
@.str.4 = [10 x i8] c"./compute\00"
@.str.5 = [2 x i8] c"p\00"
@.str.6 = [15 x i8] c"Unable to exec\00"
@.str.7 = [24 x i8] c"Unable to spawn compute\00"
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.8 = [35 x i8] c"Could not set file control options\00"
define i32 @spawn_computes(i64** %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca [11 x i8]
%6 = alloca [11 x i8]
%7 = sitofp i32 %2 to double
%8 = sitofp i32 %3 to double
%9 = fdiv double %7, %8
%10 = tail call i32 @floor(double %9)
%11 = icmp ne i64** %0, null
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = icmp ne i32* %1, null
%15 = zext i1 %14 to i32
%16 = tail call i32 @assert(i32 %15)
%17 = shl i32 %2, 3
%18 = tail call i64 @malloc(i32 %17)
%19 = inttoptr i64 %18 to i64*
store i64* %19, i64** %0
%20 = icmp eq i64 %18, 0
br i1 %20, label %21, label %25
21: ; preds = %4
%22 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %4
%26 = tail call i32 @pipe(i32* %1)
%27 = icmp eq i32 %26, -1
br i1 %27, label %35, label %28
28: ; preds = %25
%29 = icmp sgt i32 %3, 0
br i1 %29, label %30, label %75
30: ; preds = %28
%31 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%32 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%33 = getelementptr inbounds i32, i32* %1, i64 1
%34 = zext i32 %3 to i64
br label %37
35: ; preds = %25
%36 = tail call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %92
37: ; preds = %30, %72
%38 = phi i64 [ 0, %30 ], [ %73, %72 ]
%39 = phi i32 [ 0, %30 ], [ %46, %72 ]
%40 = add nsw i32 %39, 1
%41 = icmp eq i64 %38, 0
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = srem i32 %2, %3
br label %44
44: ; preds = %37, %42
%45 = phi i32 [ %43, %42 ], [ %39, %37 ]
%46 = add i32 %45, %10
%47 = call i32 @snprintf(i8* %31, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%48 = call i32 @snprintf(i8* %32, i32 11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %46)
%49 = call i64 (...) @fork()
%50 = icmp sgt i64 %49, 0
br i1 %50, label %51, label %54
51: ; preds = %44
%52 = load i64*, i64** %0
%53 = getelementptr inbounds i64, i64* %52, i64 %38
store i64 %49, i64* %53
br label %72
54: ; preds = %44
%55 = icmp eq i64 %49, 0
br i1 %55, label %56, label %70
56: ; preds = %54
%57 = load i32, i32* %33
%58 = load i32, i32* @STDOUT_FILENO
%59 = call i32 @dup2(i32 %57, i32 %58)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %56
%62 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %92
63: ; preds = %56
%64 = load i32, i32* %1
%65 = call i32 @close(i32 %64)
%66 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* %31, i8* %32, i32* null)
%67 = icmp eq i32 %66, -1
br i1 %67, label %68, label %72
68: ; preds = %63
%69 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %92
70: ; preds = %54
%71 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %72
72: ; preds = %51, %63, %70
%73 = add nuw nsw i64 %38, 1
%74 = icmp eq i64 %73, %34
br i1 %74, label %75, label %37
75: ; preds = %72, %28
%76 = getelementptr inbounds i32, i32* %1, i64 1
%77 = load i32, i32* %76
%78 = call i32 @close(i32 %77)
%79 = load i32, i32* %1
%80 = load i32, i32* @F_GETFL
%81 = call i32 @fcntl(i32 %79, i32 %80, i32 0)
%82 = icmp eq i32 %81, -1
%83 = select i1 %82, i32 0, i32 %81
%84 = load i32, i32* %1
%85 = load i32, i32* @F_SETFL
%86 = load i32, i32* @O_NONBLOCK
%87 = or i32 %86, %83
%88 = call i32 @fcntl(i32 %84, i32 %85, i32 %87)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %92
90: ; preds = %75
%91 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
br label %92
92: ; preds = %75, %61, %68, %90, %35
%93 = phi i32 [ -1, %35 ], [ -1, %90 ], [ -1, %68 ], [ -1, %61 ], [ 0, %75 ]
ret i32 %93
}