#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 MAP_ANONYMOUS;
int MAP_PRIVATE;
int PROT_READ;
int PROT_WRITE;
unsigned long atol(char *);
int /*<<< orphan*/ exit(int);
int fork();
unsigned long getpagesize();
int getpid();
scalar_t__ mmap(void *, unsigned long, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ wait(int *);
main(int argc, char *argv[]) {
  unsigned long size, psize, procs, itterations;
  char *ptr;
  char *i;
  int pid, j, k, status;
  if ((argc <= 1) || (argc > 4)) {
    printf("bad args, usage: forkoff <memsize MB> #children #itterations\n");
    exit(-1);
  }
  size = ((long)atol(argv[1]) * 1024 * 1024);
  psize = getpagesize();
  procs = atol(argv[2]);
  itterations = atol(argv[3]);
  printf("mmaping %ld anonymous bytes\n", size);
  ptr = (char *)mmap((void *)0, size, PROT_READ | PROT_WRITE,
                     MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
  if (ptr == (char *)-1) {
    printf("address = %lx\n", ptr);
    perror("");
  }
  k = procs;
  do {
    pid = fork();
    if (pid == -1) {
      printf("fork failure\n");
      exit(-1);
    } else if (!pid) {
      printf("PID %d touching %d pages\n", getpid(), size / psize);
      for (j = 0; j < itterations; j++) {
        for (i = ptr; i < ptr + size - 1; i += psize) {
          *i = (char)'i';
        }
      }
      exit(0);
    }
  } while (--k);
  while (procs-- && wait(&status))
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11ba <main+0x2a>
cmpl   $0x4,-0x8(%rbp)
jle    11d2 <main+0x42>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
shl    $0xa,%rax
shl    $0xa,%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <getpagesize@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    0x2dc3(%rip),%rax
mov    (%rax),%edx
mov    0x2d92(%rip),%rax
or     (%rax),%edx
mov    0x2d99(%rip),%rax
mov    (%rax),%ecx
mov    0x2d78(%rip),%rax
or     (%rax),%ecx
xor    %eax,%eax
mov    %eax,%edi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x38(%rbp)
jne    1297 <main+0x107>
mov    -0x38(%rbp),%rsi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xde5(%rip),%rdi
call   1070 <perror@plt>
mov    -0x28(%rbp),%rax
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    12ca <main+0x13a>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
cmpl   $0x0,-0x44(%rbp)
jne    1362 <main+0x1d2>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
mov    %rax,%rdx
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x48(%rbp)
movslq -0x48(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    135b <main+0x1cb>
mov    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
add    -0x18(%rbp),%rcx
add    $0xffffffffffffffff,%rcx
cmp    %rcx,%rax
jae    1348 <main+0x1b8>
mov    -0x40(%rbp),%rax
movb   $0x69,(%rax)
mov    -0x20(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    1317 <main+0x187>
jmp    134d <main+0x1bd>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1301 <main+0x171>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    1367 <main+0x1d7>
jmp    136c <main+0x1dc>
mov    -0x4c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4c(%rbp)
cmp    $0x0,%eax
jne    129e <main+0x10e>
jmp    1383 <main+0x1f3>
mov    -0x28(%rbp),%rcx
mov    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x51(%rbp)
je     13b4 <main+0x224>
lea    -0x50(%rbp),%rdi
call   10a0 <wait@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x51(%rbp)
mov    -0x51(%rbp),%al
test   $0x1,%al
jne    13c4 <main+0x234>
jmp    13c9 <main+0x239>
jmp    1383 <main+0x1f3>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
add    $0xfffffffb,%edi
cmp    $0xfffffffc,%edi
jbe    138d <main+0x1ed>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   1070 <atol@plt>
mov    %rax,%r12
shl    $0x14,%r12
xor    %eax,%eax
call   1090 <getpagesize@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
call   1070 <atol@plt>
mov    %rax,%r13
mov    0x18(%r14),%rdi
call   1070 <atol@plt>
mov    %rax,%r14
lea    0xe0d(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2df4(%rip),%rax
mov    0x2dc5(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2dca(%rip),%rax
mov    0x2dab(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
xor    %edi,%edi
mov    %r12,%rsi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <mmap@plt>
mov    %rax,%r15
cmp    $0xffffffffffffffff,%rax
je     1284 <main+0xe4>
mov    %r13d,%ebp
xor    %eax,%eax
call   10c0 <fork@plt>
test   %eax,%eax
je     12a7 <main+0x107>
cmp    $0xffffffff,%eax
je     12c7 <main+0x127>
add    $0xffffffff,%ebp
jne    1240 <main+0xa0>
add    $0x1,%r13
lea    0x4(%rsp),%rbx
xchg   %ax,%ax
add    $0xffffffffffffffff,%r13
je     1273 <main+0xd3>
mov    %rbx,%rdi
call   10b0 <wait@plt>
test   %rax,%rax
jne    1260 <main+0xc0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd92(%rip),%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xda5(%rip),%rdi
call   1080 <perror@plt>
jmp    123d <main+0x9d>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%esi
mov    %r12,%rax
or     %rbx,%rax
shr    $0x20,%rax
jne    12dd <main+0x13d>
mov    %r12d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%edx
jmp    12e8 <main+0x148>
lea    0xd78(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
mov    %r12,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%rdx
lea    0xd3d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
test   %r14,%r14
je     132c <main+0x18c>
lea    (%r15,%r12,1),%rax
add    $0xffffffffffffffff,%rax
cmp    $0x1,%r14
jne    1333 <main+0x193>
test   $0x1,%r14b
je     132c <main+0x18c>
cmp    %r15,%rax
jbe    132c <main+0x18c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x69,(%r15)
add    %rbx,%r15
cmp    %rax,%r15
jb     1320 <main+0x180>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    %r14,%rcx
and    $0xfffffffffffffffe,%rcx
xor    %edx,%edx
jmp    1349 <main+0x1a9>
xchg   %ax,%ax
add    $0x2,%rdx
cmp    %rcx,%rdx
je     1309 <main+0x169>
cmp    %r15,%rax
jbe    1340 <main+0x1a0>
mov    %r15,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movb   $0x69,(%rsi)
add    %rbx,%rsi
cmp    %rax,%rsi
jb     1360 <main+0x1c0>
cmp    %r15,%rax
jbe    1340 <main+0x1a0>
mov    %r15,%rsi
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movb   $0x69,(%rsi)
add    %rbx,%rsi
cmp    %rax,%rsi
jb     1380 <main+0x1e0>
jmp    1340 <main+0x1a0>
lea    0xcbf(%rip),%rdi
jmp    12ce <main+0x12e>

LLVM IR (-O0):
@.str = [62 x i8] c"bad args, usage: forkoff <memsize MB> #children #itterations\0A\00"
@.str.1 = [29 x i8] c"mmaping %ld anonymous bytes\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@.str.2 = [15 x i8] c"address = %lx\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [14 x i8] c"fork failure\0A\00"
@.str.5 = [26 x i8] c"PID %d touching %d pages\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 i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp sgt i32 %19, 4
br i1 %20, label %21, label %24
21: ; preds = %18, %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @exit(i32 -1)
unreachable
24: ; preds = %18
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @atol(i8* %27)
%29 = mul nsw i64 %28, 1024
%30 = mul nsw i64 %29, 1024
store i64 %30, i64* %6
%31 = call i64 (...) @getpagesize()
store i64 %31, i64* %7
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i64 @atol(i8* %34)
store i64 %35, i64* %8
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
%39 = call i64 @atol(i8* %38)
store i64 %39, i64* %9
%40 = load i64, i64* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %40)
%42 = load i64, i64* %6
%43 = load i32, i32* @PROT_READ
%44 = load i32, i32* @PROT_WRITE
%45 = or i32 %43, %44
%46 = load i32, i32* @MAP_ANONYMOUS
%47 = load i32, i32* @MAP_PRIVATE
%48 = or i32 %46, %47
%49 = call i64 @mmap(i8* null, i64 %42, i32 %45, i32 %48, i32 -1, i32 0)
%50 = inttoptr i64 %49 to i8*
store i8* %50, i8** %10
%51 = load i8*, i8** %10
%52 = icmp eq i8* %51, inttoptr (i64 -1 to i8*)
br i1 %52, label %53, label %57
53: ; preds = %24
%54 = load i8*, i8** %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %54)
%56 = call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %57
57: ; preds = %53, %24
%58 = load i64, i64* %8
%59 = trunc i64 %58 to i32
store i32 %59, i32* %14
br label %60
60: ; preds = %104, %57
%61 = call i32 (...) @fork()
store i32 %61, i32* %12
%62 = load i32, i32* %12
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%66 = call i32 @exit(i32 -1)
unreachable
67: ; preds = %60
%68 = load i32, i32* %12
%69 = icmp ne i32 %68, 0
br i1 %69, label %102, label %70
70: ; preds = %67
%71 = call i32 (...) @getpid()
%72 = load i64, i64* %6
%73 = load i64, i64* %7
%74 = udiv i64 %72, %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %71, i64 %74)
store i32 0, i32* %13
br label %76
76: ; preds = %97, %70
%77 = load i32, i32* %13
%78 = sext i32 %77 to i64
%79 = load i64, i64* %9
%80 = icmp ult i64 %78, %79
br i1 %80, label %81, label %100
81: ; preds = %76
%82 = load i8*, i8** %10
store i8* %82, i8** %11
br label %83
83: ; preds = %92, %81
%84 = load i8*, i8** %11
%85 = load i8*, i8** %10
%86 = load i64, i64* %6
%87 = getelementptr inbounds i8, i8* %85, i64 %86
%88 = getelementptr inbounds i8, i8* %87, i64 -1
%89 = icmp ult i8* %84, %88
br i1 %89, label %90, label %96
90: ; preds = %83
%91 = load i8*, i8** %11
store i8 105, i8* %91
br label %92
92: ; preds = %90
%93 = load i64, i64* %7
%94 = load i8*, i8** %11
%95 = getelementptr inbounds i8, i8* %94, i64 %93
store i8* %95, i8** %11
br label %83
96: ; preds = %83
br label %97
97: ; preds = %96
%98 = load i32, i32* %13
%99 = add nsw i32 %98, 1
store i32 %99, i32* %13
br label %76
100: ; preds = %76
%101 = call i32 @exit(i32 0)
unreachable
102: ; preds = %67
br label %103
103: ; preds = %102
br label %104
104: ; preds = %103
%105 = load i32, i32* %14
%106 = add nsw i32 %105, -1
store i32 %106, i32* %14
%107 = icmp ne i32 %106, 0
br i1 %107, label %60, label %108
108: ; preds = %104
br label %109
109: ; preds = %118, %108
%110 = load i64, i64* %8
%111 = add i64 %110, -1
store i64 %111, i64* %8
%112 = icmp ne i64 %110, 0
br i1 %112, label %113, label %116
113: ; preds = %109
%114 = call i64 @wait(i32* %15)
%115 = icmp ne i64 %114, 0
br label %116
116: ; preds = %113, %109
%117 = phi i1 [ false, %109 ], [ %115, %113 ]
br i1 %117, label %118, label %119
118: ; preds = %116
br label %109
119: ; preds = %116
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"mmaping %ld anonymous bytes\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_ANONYMOUS = global i32 0
@MAP_PRIVATE = global i32 0
@.str.2 = [15 x i8] c"address = %lx\0A\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.5 = [26 x i8] c"PID %d touching %d pages\0A\00"
@str = [13 x i8] c"fork failure\00"
@str.6 = [61 x i8] c"bad args, usage: forkoff <memsize MB> #children #itterations\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = add i32 %0, -5
%6 = icmp ult i32 %5, -3
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.6, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @atol(i8* %12)
%14 = shl nsw i64 %13, 20
%15 = tail call i64 (...) @getpagesize()
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i64 @atol(i8* %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 3
%20 = load i8*, i8** %19
%21 = tail call i64 @atol(i8* %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%23 = load i32, i32* @PROT_READ
%24 = load i32, i32* @PROT_WRITE
%25 = or i32 %24, %23
%26 = load i32, i32* @MAP_ANONYMOUS
%27 = load i32, i32* @MAP_PRIVATE
%28 = or i32 %27, %26
%29 = tail call i64 @mmap(i8* null, i64 %14, i32 %25, i32 %28, i32 -1, i32 0)
%30 = inttoptr i64 %29 to i8*
%31 = icmp eq i8* %30, inttoptr (i64 -1 to i8*)
br i1 %31, label %32, label %35
32: ; preds = %10
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* inttoptr (i64 -1 to i8*))
%34 = tail call i32 @perror(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %32, %10
%36 = trunc i64 %18 to i32
br label %37
37: ; preds = %80, %35
%38 = phi i32 [ %36, %35 ], [ %81, %80 ]
%39 = tail call i32 (...) @fork()
switch i32 %39, label %80 [
i32 -1, label %40
i32 0, label %43
]
40: ; preds = %37
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%42 = tail call i32 @exit(i32 -1)
unreachable
43: ; preds = %37
%44 = tail call i32 (...) @getpid()
%45 = udiv i64 %14, %15
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %44, i64 %45)
%47 = icmp eq i64 %21, 0
br i1 %47, label %78, label %48
48: ; preds = %43
%49 = getelementptr inbounds i8, i8* %30, i64 %14
%50 = getelementptr inbounds i8, i8* %49, i64 -1
%51 = icmp ugt i8* %50, %30
%52 = and i64 %21, 1
%53 = icmp eq i64 %21, 1
br i1 %53, label %70, label %54
54: ; preds = %48
%55 = and i64 %21, -2
br label %56
56: ; preds = %67, %54
%57 = phi i64 [ 0, %54 ], [ %68, %67 ]
br i1 %51, label %58, label %67
58: ; preds = %56, %58
%59 = phi i8* [ %60, %58 ], [ %30, %56 ]
store i8 105, i8* %59
%60 = getelementptr inbounds i8, i8* %59, i64 %15
%61 = icmp ult i8* %60, %50
br i1 %61, label %58, label %62
62: ; preds = %58
br i1 %51, label %63, label %67
63: ; preds = %62, %63
%64 = phi i8* [ %65, %63 ], [ %30, %62 ]
store i8 105, i8* %64
%65 = getelementptr inbounds i8, i8* %64, i64 %15
%66 = icmp ult i8* %65, %50
br i1 %66, label %63, label %67
67: ; preds = %56, %63, %62
%68 = add i64 %57, 2
%69 = icmp eq i64 %68, %55
br i1 %69, label %70, label %56
70: ; preds = %67, %48
%71 = icmp eq i64 %52, 0
%72 = xor i1 %51, true
%73 = select i1 %71, i1 true, i1 %72
br i1 %73, label %78, label %74
74: ; preds = %70, %74
%75 = phi i8* [ %76, %74 ], [ %30, %70 ]
store i8 105, i8* %75
%76 = getelementptr inbounds i8, i8* %75, i64 %15
%77 = icmp ult i8* %76, %50
br i1 %77, label %74, label %78
78: ; preds = %70, %74, %43
%79 = tail call i32 @exit(i32 0)
unreachable
80: ; preds = %37
%81 = add nsw i32 %38, -1
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %37
83: ; preds = %80, %86
%84 = phi i64 [ %87, %86 ], [ %18, %80 ]
%85 = icmp eq i64 %84, 0
br i1 %85, label %90, label %86
86: ; preds = %83
%87 = add i64 %84, -1
%88 = call i64 @wait(i32* %3)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %83
90: ; preds = %83, %86
ret i32 0
}