#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 */
scalar_t__ EINTR;
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ lemon_main(int, char **);
char *mybasename(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int wait(int *);
int main(int argc, char **argv) {
  int j, i = 0;
  for (j = 0; j < 20; j++) {
    for (i = 1; i < argc; i++) {
      int status;
      pid_t p = fork();
      if (p == 0) {
        char *argv_child[] = {"lemon-child", "-s", argv[i], NULL};
        fprintf(stdout, "Processing %s\n", mybasename(argv[i]));
        exit(lemon_main(3, argv_child));
      }
      while (wait(&status) == -1 && errno == EINTR) {
      }
      if (status) {
        fflush(stdout);
        fprintf(stderr, "Error while running on: %s\n", mybasename(argv[i]));
      }
    }
  }
  return 0;
}


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)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    12f3 <main+0x183>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e0 <main+0x170>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1239 <main+0xc9>
lea    0xe32(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe33(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <mybasename@plt>
mov    -0x54(%rbp),%edi
mov    %rax,%rdx
lea    0xdf0(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x50(%rbp),%rsi
mov    $0x3,%edi
call   1040 <lemon_main@plt>
mov    %eax,%edi
call   1070 <exit@plt>
jmp    123e <main+0xce>
lea    -0x1c(%rbp),%rdi
call   1080 <wait@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
mov    %al,-0x55(%rbp)
jne    1271 <main+0x101>
mov    0x2d7a(%rip),%rax
mov    (%rax),%rax
mov    0x2d68(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    1281 <main+0x111>
jmp    1286 <main+0x116>
jmp    123e <main+0xce>
cmpl   $0x0,-0x1c(%rbp)
je     12cd <main+0x15d>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <mybasename@plt>
mov    -0x5c(%rbp),%edi
mov    %rax,%rdx
lea    0xd56(%rip),%rsi
call   1050 <fprintf@plt>
jmp    12d2 <main+0x162>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a5 <main+0x35>
jmp    12e5 <main+0x175>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1194 <main+0x24>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,0x8(%rsp)
mov    %edi,(%rsp)
mov    %edi,%r14d
lea    0x10(%rsp),%rbp
mov    0x2e43(%rip),%r13
mov    0x2e34(%rip),%r15
xor    %eax,%eax
jmp    11b0 <main+0x40>
mov    0x4(%rsp),%eax
add    $0x1,%eax
cmp    $0x14,%eax
je     1245 <main+0xd5>
mov    %eax,0x4(%rsp)
cmpl   $0x2,(%rsp)
jl     11a0 <main+0x30>
mov    $0x1,%r12d
jmp    11d9 <main+0x69>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r14,%r12
je     11a0 <main+0x30>
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
je     1256 <main+0xe6>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
call   1080 <wait@plt>
cmp    $0xffffffff,%eax
jne    1206 <main+0x96>
mov    (%r15),%rax
cmp    %rax,0x0(%r13)
je     11f0 <main+0x80>
cmpl   $0x0,0x10(%rsp)
je     11d0 <main+0x60>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%ebx
mov    0x8(%rsp),%rax
mov    (%rax,%r12,8),%rdi
call   1030 <mybasename@plt>
mov    %ebx,%edi
lea    0xde3(%rip),%rsi
mov    %rax,%rdx
call   1050 <fprintf@plt>
jmp    11d0 <main+0x60>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xda3(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xda3(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %r12d,%eax
mov    0x8(%rsp),%rcx
mov    (%rcx,%rax,8),%rdi
mov    %rdi,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    0x2d39(%rip),%rax
mov    (%rax),%ebx
call   1030 <mybasename@plt>
lea    0xd72(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
lea    0x10(%rsp),%rsi
mov    $0x3,%edi
call   1040 <lemon_main@plt>
mov    %eax,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"lemon-child\00"
@.str.1 = [3 x i8] c"-s\00"
@stdout = global i32 0
@.str.2 = [15 x i8] c"Processing %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.3 = [28 x i8] c"Error while running on: %s\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 i64
%10 = alloca [4 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 0, i32* %6
br label %11
11: ; preds = %74, %2
%12 = load i32, i32* %6
%13 = icmp slt i32 %12, 20
br i1 %13, label %14, label %77
14: ; preds = %11
store i32 1, i32* %7
br label %15
15: ; preds = %70, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %73
19: ; preds = %15
%20 = call i64 (...) @fork()
store i64 %20, i64* %9
%21 = load i64, i64* %9
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %44
23: ; preds = %19
%24 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds i8*, i8** %24, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8**, i8*** %5
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
store i8* %31, i8** %26
%32 = getelementptr inbounds i8*, i8** %26, i64 1
store i8* null, i8** %32
%33 = load i32, i32* @stdout
%34 = load i8**, i8*** %5
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i8* @mybasename(i8* %38)
%40 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [4 x i8*], [4 x i8*]* %10, i64 0, i64 0
%42 = call i32 @lemon_main(i32 3, i8** %41)
%43 = call i32 @exit(i32 %42)
unreachable
44: ; preds = %19
br label %45
45: ; preds = %54, %44
%46 = call i32 @wait(i32* %8)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = load i64, i64* @errno
%50 = load i64, i64* @EINTR
%51 = icmp eq i64 %49, %50
br label %52
52: ; preds = %48, %45
%53 = phi i1 [ false, %45 ], [ %51, %48 ]
br i1 %53, label %54, label %55
54: ; preds = %52
br label %45
55: ; preds = %52
%56 = load i32, i32* %8
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %69
58: ; preds = %55
%59 = load i32, i32* @stdout
%60 = call i32 @fflush(i32 %59)
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %5
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i8* @mybasename(i8* %66)
%68 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %58, %55
br label %70
70: ; preds = %69
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %15
73: ; preds = %15
br label %74
74: ; preds = %73
%75 = load i32, i32* %6
%76 = add nsw i32 %75, 1
store i32 %76, i32* %6
br label %11
77: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"lemon-child\00"
@.str.1 = [3 x i8] c"-s\00"
@stdout = global i32 0
@.str.2 = [15 x i8] c"Processing %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@stderr = global i32 0
@.str.3 = [28 x i8] c"Error while running on: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [4 x i8*]
%5 = icmp sgt i32 %0, 1
%6 = bitcast i32* %3 to i8*
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %2, %49
%9 = phi i32 [ 0, %2 ], [ %50, %49 ]
br i1 %5, label %10, label %49
10: ; preds = %8, %46
%11 = phi i64 [ %47, %46 ], [ 1, %8 ]
%12 = call i64 (...) @fork()
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = bitcast [4 x i8*]* %4 to i8*
%16 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 2
%19 = and i64 %11, 4294967295
%20 = getelementptr inbounds i8*, i8** %1, i64 %19
%21 = load i8*, i8** %20
store i8* %21, i8** %18
%22 = getelementptr inbounds [4 x i8*], [4 x i8*]* %4, i64 0, i64 3
store i8* null, i8** %22
%23 = load i32, i32* @stdout
%24 = call i8* @mybasename(i8* %21)
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = call i32 @lemon_main(i32 3, i8** %16)
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %10, %28
%29 = call i32 @wait(i32* %3)
%30 = icmp eq i32 %29, -1
%31 = load i64, i64* @errno
%32 = load i64, i64* @EINTR
%33 = icmp eq i64 %31, %32
%34 = select i1 %30, i1 %33, i1 false
br i1 %34, label %28, label %35
35: ; preds = %28
%36 = load i32, i32* %3
%37 = icmp eq i32 %36, 0
br i1 %37, label %46, label %38
38: ; preds = %35
%39 = load i32, i32* @stdout
%40 = call i32 @fflush(i32 %39)
%41 = load i32, i32* @stderr
%42 = getelementptr inbounds i8*, i8** %1, i64 %11
%43 = load i8*, i8** %42
%44 = call i8* @mybasename(i8* %43)
%45 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %38, %35
%47 = add nuw nsw i64 %11, 1
%48 = icmp eq i64 %47, %7
br i1 %48, label %49, label %10
49: ; preds = %46, %8
%50 = add nuw nsw i32 %9, 1
%51 = icmp eq i32 %50, 20
br i1 %51, label %52, label %8
52: ; preds = %49
ret i32 0
}