#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 CLONE_NEWIPC;
int CLONE_NEWNET;
int CLONE_NEWPID;
int SIGCHLD;
int /*<<< orphan*/ __NR_clone;
int /*<<< orphan*/ perror(char *);
int syscall(int /*<<< orphan*/, int, int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int i, ret;
  for (i = 0; i < 10000; i++) {
    if (0 == (ret = syscall(
                  __NR_clone,
                  CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNET | SIGCHLD, NULL)))
      return 0;
    if (-1 == ret) {
      perror("clone");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11cd <main+0xad>
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
mov    0x2e65(%rip),%rax
or     (%rax),%esi
mov    0x2e74(%rip),%rax
or     (%rax),%esi
mov    0x2e63(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <syscall@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jne    119b <main+0x7b>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <main+0xb4>
mov    $0xffffffff,%eax
cmp    -0x18(%rbp),%eax
jne    11ba <main+0x9a>
lea    0xe50(%rip),%rdi
call   1040 <perror@plt>
jmp    11cd <main+0xad>
jmp    11bf <main+0x9f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113d <main+0x1d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x2710,%ebx
mov    0x2eb9(%rip),%r14
mov    0x2e82(%rip),%r15
mov    0x2e83(%rip),%r12
mov    0x2e94(%rip),%r13
mov    0x2e85(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%edi
mov    (%r12),%esi
or     (%r15),%esi
or     0x0(%r13),%esi
or     0x0(%rbp),%esi
xor    %edx,%edx
call   1030 <syscall@plt>
test   %eax,%eax
je     1186 <main+0x66>
cmp    $0xffffffff,%eax
je     1197 <main+0x77>
add    $0xffffffff,%ebx
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe62(%rip),%rdi
call   1040 <perror@plt>
jmp    1186 <main+0x66>

LLVM IR (-O0):
@__NR_clone = global i32 0
@CLONE_NEWPID = global i32 0
@CLONE_NEWIPC = global i32 0
@CLONE_NEWNET = global i32 0
@SIGCHLD = global i32 0
@.str = [6 x i8] c"clone\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
br label %8
8: ; preds = %29, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 10000
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i32, i32* @__NR_clone
%13 = load i32, i32* @CLONE_NEWPID
%14 = load i32, i32* @CLONE_NEWIPC
%15 = or i32 %13, %14
%16 = load i32, i32* @CLONE_NEWNET
%17 = or i32 %15, %16
%18 = load i32, i32* @SIGCHLD
%19 = or i32 %17, %18
%20 = call i32 @syscall(i32 %12, i32 %19, i32* null)
store i32 %20, i32* %7
%21 = icmp eq i32 0, %20
br i1 %21, label %22, label %23
22: ; preds = %11
store i32 0, i32* %3
br label %33
23: ; preds = %11
%24 = load i32, i32* %7
%25 = icmp eq i32 -1, %24
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %32
28: ; preds = %23
br label %29
29: ; preds = %28
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %8
32: ; preds = %26, %8
store i32 0, i32* %3
br label %33
33: ; preds = %32, %22
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@__NR_clone = global i32 0
@CLONE_NEWPID = global i32 0
@CLONE_NEWIPC = global i32 0
@CLONE_NEWNET = global i32 0
@SIGCHLD = global i32 0
@.str = [6 x i8] c"clone\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %16
%4 = phi i32 [ 0, %2 ], [ %17, %16 ]
%5 = load i32, i32* @__NR_clone
%6 = load i32, i32* @CLONE_NEWPID
%7 = load i32, i32* @CLONE_NEWIPC
%8 = or i32 %7, %6
%9 = load i32, i32* @CLONE_NEWNET
%10 = or i32 %8, %9
%11 = load i32, i32* @SIGCHLD
%12 = or i32 %10, %11
%13 = tail call i32 @syscall(i32 %5, i32 %12, i32* null)
switch i32 %13, label %16 [
i32 0, label %19
i32 -1, label %14
]
14: ; preds = %3
%15 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %19
16: ; preds = %3
%17 = add nuw nsw i32 %4, 1
%18 = icmp eq i32 %17, 10000
br i1 %18, label %19, label %3
19: ; preds = %16, %3, %14
ret i32 0
}