#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getMode(int, char **);
int getpid();
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ regsr();
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ wait(int *);
scalar_t__ xfer();
int main(int argc, char **argv) {
  int rc;
  int i, status;
  pid_t wpid, cpid;
  rc = getMode(argc, argv);
  printf("getmode : %d\n", rc);
  if (rc < 1) {
    fprintf(stderr, "getMode() error\n");
    return -1;
  }
  if (rc == 1) {
    if (regsr() < 0) {
      fprintf(stderr, "regsr() error\n");
      return -1;
    }
  }
  if (rc == 2) {
    if (xfer() < 0) {
      fprintf(stderr, "regsr() error\n");
      return -1;
    }
  }
  if (rc == 3) {
    printf("\n\ninto mode 3\n\n\n\n");
    printf("parent_pid = %d\n", getpid());
    for (i = 0; i < 2; i++) {
      printf("i = %d\n", i);
      if ((cpid = fork()) == 0) {
        printf("Child_pid = %d\n", getpid());
        if (i == 0) {
          printf("do work with reg\n");
          if (regsr() < 0) {
            fprintf(stderr, "regsr() error\n");
            exit(EXIT_FAILURE);
          } else {
            exit(EXIT_SUCCESS);
          }
        } else {
          printf("file xfer \n");
          if (xfer() < 0) {
            fprintf(stderr, "regsr() error\n");
            exit(EXIT_FAILURE);
          } else {
            exit(EXIT_SUCCESS);
          }
        }
      }
      if (cpid < 0) {
        fprintf(stderr, "Fork() error: %s\n", strerror(errno));
        exit(EXIT_FAILURE);
      }
    }
    while ((wpid = wait(&status)) > 0) {
      printf("Exit status of %d was %d (%s)\n", (int)wpid, status,
             (status > 0) ? "accept" : "reject");
    }
  }
  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)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <getMode@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
jge    1203 <main+0x63>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    146a <main+0x2ca>
cmpl   $0x1,-0x14(%rbp)
jne    1246 <main+0xa6>
mov    $0x0,%al
call   1080 <regsr@plt>
cmp    $0x0,%rax
jge    1241 <main+0xa1>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    146a <main+0x2ca>
jmp    1246 <main+0xa6>
cmpl   $0x2,-0x14(%rbp)
jne    1289 <main+0xe9>
mov    $0x0,%al
call   1040 <xfer@plt>
cmp    $0x0,%rax
jge    1284 <main+0xe4>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
lea    0xdae(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    146a <main+0x2ca>
jmp    1289 <main+0xe9>
cmpl   $0x3,-0x14(%rbp)
jne    1463 <main+0x2c3>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xd8f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    140e <main+0x26e>
mov    -0x18(%rbp),%esi
lea    0xd7e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   10c0 <fork@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    13b4 <main+0x214>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xd5a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jne    1362 <main+0x1c2>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <regsr@plt>
cmp    $0x0,%rax
jge    1354 <main+0x1b4>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c83(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2c6d(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <xfer@plt>
cmp    $0x0,%rax
jge    13a6 <main+0x206>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
lea    0xc8e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2c1b(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpq   $0x0,-0x30(%rbp)
jge    13fb <main+0x25b>
mov    0x2c1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xca1(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2bdc(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
jmp    1400 <main+0x260>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12bf <main+0x11f>
jmp    1413 <main+0x273>
lea    -0x1c(%rbp),%rdi
call   10b0 <wait@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jle    145e <main+0x2be>
mov    -0x28(%rbp),%rax
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
mov    -0x1c(%rbp),%edi
lea    0xc82(%rip),%rcx
lea    0xc74(%rip),%rax
cmp    $0x0,%edi
cmovg  %rax,%rcx
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1413 <main+0x273>
jmp    1463 <main+0x2c3>
movl   $0x0,-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
call   1060 <getMode@plt>
mov    %eax,%ebp
lea    0xe36(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %ebp,%ebp
jle    1207 <main+0x57>
cmp    $0x3,%ebp
je     1213 <main+0x63>
cmp    $0x2,%ebp
je     12e8 <main+0x138>
cmp    $0x1,%ebp
jne    1312 <main+0x162>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <regsr@plt>
test   %rax,%rax
jns    1312 <main+0x162>
jmp    12f6 <main+0x146>
lea    0xe00(%rip),%rsi
jmp    12fd <main+0x14d>
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe01(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe02(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %rax,%rax
je     1351 <main+0x1a1>
js     1325 <main+0x175>
mov    %rax,%rbx
lea    0xdd9(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10d0 <fork@plt>
test   %rax,%rax
je     136a <main+0x1ba>
js     1325 <main+0x175>
lea    0xc(%rsp),%rdi
call   10c0 <wait@plt>
test   %rax,%rax
jle    1321 <main+0x171>
lea    0xde6(%rip),%r12
lea    0xde6(%rip),%rbp
lea    0xdb9(%rip),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
test   %edx,%edx
mov    %rbp,%rcx
cmovg  %r12,%rcx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   10c0 <wait@plt>
test   %rax,%rax
jg     12c0 <main+0x110>
jmp    1312 <main+0x162>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <xfer@plt>
test   %rax,%rax
jns    1312 <main+0x162>
lea    0xd22(%rip),%rsi
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
jmp    1312 <main+0x162>
mov    0x2cb4(%rip),%rax
mov    (%rax),%ebx
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
call   10b0 <strerror@plt>
lea    0xd14(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    13ca <main+0x21a>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xce8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1386 <main+0x1d6>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xccf(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
test   %rbx,%rbx
jne    139b <main+0x1eb>
lea    0xd25(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1090 <regsr@plt>
jmp    13ae <main+0x1fe>
lea    0xd05(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <xfer@plt>
test   %rax,%rax
jns    13d8 <main+0x228>
mov    0x2c26(%rip),%rax
mov    (%rax),%edi
lea    0xc5c(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"getmode : %d\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"getMode() error\0A\00"
@.str.2 = [15 x i8] c"regsr() error\0A\00"
@.str.3 = [18 x i8] c"\0A\0Ainto mode 3\0A\0A\0A\0A\00"
@.str.4 = [17 x i8] c"parent_pid = %d\0A\00"
@.str.5 = [8 x i8] c"i = %d\0A\00"
@.str.6 = [16 x i8] c"Child_pid = %d\0A\00"
@.str.7 = [18 x i8] c"do work with reg\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.8 = [12 x i8] c"file xfer \0A\00"
@.str.9 = [18 x i8] c"Fork() error: %s\0A\00"
@errno = global i32 0
@.str.10 = [31 x i8] c"Exit status of %d was %d (%s)\0A\00"
@.str.11 = [7 x i8] c"accept\00"
@.str.12 = [7 x i8] c"reject\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 i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getMode(i32 %11, i8** %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %114
21: ; preds = %2
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, 1
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = call i64 (...) @regsr()
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %114
30: ; preds = %24
br label %31
31: ; preds = %30, %21
%32 = load i32, i32* %6
%33 = icmp eq i32 %32, 2
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = call i64 (...) @xfer()
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %114
40: ; preds = %34
br label %41
41: ; preds = %40, %31
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 3
br i1 %43, label %44, label %113
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 (...) @getpid()
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %46)
store i32 0, i32* %7
br label %48
48: ; preds = %96, %44
%49 = load i32, i32* %7
%50 = icmp slt i32 %49, 2
br i1 %50, label %51, label %99
51: ; preds = %48
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %52)
%54 = call i64 (...) @fork()
store i64 %54, i64* %10
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %85
56: ; preds = %51
%57 = call i32 (...) @getpid()
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %7
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %73
61: ; preds = %56
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%63 = call i64 (...) @regsr()
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %61
%71 = load i32, i32* @EXIT_SUCCESS
%72 = call i32 @exit(i32 %71)
unreachable
73: ; preds = %56
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0))
%75 = call i64 (...) @xfer()
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %73
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%80 = load i32, i32* @EXIT_FAILURE
%81 = call i32 @exit(i32 %80)
unreachable
82: ; preds = %73
%83 = load i32, i32* @EXIT_SUCCESS
%84 = call i32 @exit(i32 %83)
unreachable
85: ; preds = %51
%86 = load i64, i64* %10
%87 = icmp slt i64 %86, 0
br i1 %87, label %88, label %95
88: ; preds = %85
%89 = load i32, i32* @stderr
%90 = load i32, i32* @errno
%91 = call i8* @strerror(i32 %90)
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %91)
%93 = load i32, i32* @EXIT_FAILURE
%94 = call i32 @exit(i32 %93)
unreachable
95: ; preds = %85
br label %96
96: ; preds = %95
%97 = load i32, i32* %7
%98 = add nsw i32 %97, 1
store i32 %98, i32* %7
br label %48
99: ; preds = %48
br label %100
100: ; preds = %103, %99
%101 = call i64 @wait(i32* %8)
store i64 %101, i64* %9
%102 = icmp sgt i64 %101, 0
br i1 %102, label %103, label %112
103: ; preds = %100
%104 = load i64, i64* %9
%105 = trunc i64 %104 to i32
%106 = load i32, i32* %8
%107 = load i32, i32* %8
%108 = icmp sgt i32 %107, 0
%109 = zext i1 %108 to i64
%110 = select i1 %108, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0)
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %105, i32 %106, i8* %110)
br label %100
112: ; preds = %100
br label %113
113: ; preds = %112, %41
store i32 0, i32* %3
br label %114
114: ; preds = %113, %37, %27, %18
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@.str = [14 x i8] c"getmode : %d\0A\00"
@stderr = global i32 0
@.str.1 = [17 x i8] c"getMode() error\0A\00"
@.str.2 = [15 x i8] c"regsr() error\0A\00"
@.str.4 = [17 x i8] c"parent_pid = %d\0A\00"
@.str.5 = [8 x i8] c"i = %d\0A\00"
@.str.6 = [16 x i8] c"Child_pid = %d\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.9 = [18 x i8] c"Fork() error: %s\0A\00"
@errno = global i32 0
@.str.10 = [31 x i8] c"Exit status of %d was %d (%s)\0A\00"
@.str.11 = [7 x i8] c"accept\00"
@.str.12 = [7 x i8] c"reject\00"
@str = [17 x i8] c"\0A\0Ainto mode 3\0A\0A\0A\00"
@str.13 = [11 x i8] c"file xfer \00"
@str.14 = [17 x i8] c"do work with reg\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 @getMode(i32 %0, i8** %1)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp slt i32 %5, 1
br i1 %7, label %79, label %8
8: ; preds = %2
switch i32 %5, label %83 [
i32 1, label %9
i32 2, label %12
i32 3, label %15
]
9: ; preds = %8
%10 = tail call i64 (...) @regsr()
%11 = icmp slt i64 %10, 0
br i1 %11, label %79, label %83
12: ; preds = %8
%13 = tail call i64 (...) @xfer()
%14 = icmp slt i64 %13, 0
br i1 %14, label %79, label %83
15: ; preds = %8
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%17 = tail call i32 (...) @getpid()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 0)
%20 = tail call i64 (...) @fork()
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %52
22: ; preds = %61
%23 = tail call i32 (...) @getpid()
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br i1 %21, label %28, label %40
25: ; preds = %15
%26 = tail call i32 (...) @getpid()
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %22
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
%30 = tail call i64 (...) @regsr()
%31 = icmp slt i64 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @EXIT_FAILURE
%36 = tail call i32 @exit(i32 %35)
unreachable
37: ; preds = %28
%38 = load i32, i32* @EXIT_SUCCESS
%39 = tail call i32 @exit(i32 %38)
unreachable
40: ; preds = %22
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.13, i64 0, i64 0))
%42 = tail call i64 (...) @xfer()
%43 = icmp slt i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%47 = load i32, i32* @EXIT_FAILURE
%48 = tail call i32 @exit(i32 %47)
unreachable
49: ; preds = %40
%50 = load i32, i32* @EXIT_SUCCESS
%51 = tail call i32 @exit(i32 %50)
unreachable
52: ; preds = %15
%53 = icmp slt i64 %20, 0
br i1 %53, label %54, label %61
54: ; preds = %65, %52
%55 = load i32, i32* @stderr
%56 = load i32, i32* @errno
%57 = tail call i8* @strerror(i32 %56)
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8* %57)
%59 = load i32, i32* @EXIT_FAILURE
%60 = tail call i32 @exit(i32 %59)
unreachable
61: ; preds = %52
%62 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 1)
%63 = tail call i64 (...) @fork()
%64 = icmp eq i64 %63, 0
br i1 %64, label %22, label %65
65: ; preds = %61
%66 = icmp slt i64 %63, 0
br i1 %66, label %54, label %67
67: ; preds = %65
%68 = call i64 @wait(i32* %3)
%69 = icmp sgt i64 %68, 0
br i1 %69, label %70, label %83
70: ; preds = %67, %70
%71 = phi i64 [ %77, %70 ], [ %68, %67 ]
%72 = trunc i64 %71 to i32
%73 = load i32, i32* %3
%74 = icmp sgt i32 %73, 0
%75 = select i1 %74, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i32 %72, i32 %73, i8* %75)
%77 = call i64 @wait(i32* %3)
%78 = icmp sgt i64 %77, 0
br i1 %78, label %70, label %83
79: ; preds = %12, %9, %2
%80 = phi i8* [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), %12 ]
%81 = load i32, i32* @stderr
%82 = tail call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* %80)
br label %83
83: ; preds = %70, %79, %67, %12, %9, %8
%84 = phi i32 [ 0, %8 ], [ 0, %9 ], [ 0, %12 ], [ 0, %67 ], [ -1, %79 ], [ 0, %70 ]
ret i32 %84
}