#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*/ execl(char *, char *, char *, char *, int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  while (1) {
    pid_t chi = fork();
    if (chi == 0) {
      execl("/bin/bash", "bash", "-c", "ls", NULL);
    }
    sleep(2);
  }
}


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)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1182 <main+0x52>
lea    0xe9d(%rip),%rdi
lea    0xe9b(%rip),%rsi
lea    0xe99(%rip),%rdx
lea    0xe95(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1030 <execl@plt>
mov    $0x2,%edi
call   1040 <sleep@plt>
jmp    1146 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%r14
lea    0xebf(%rip),%r15
lea    0xebd(%rip),%r12
lea    0xeb9(%rip),%rbx
jmp    116a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
mov    $0x2,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
jne    1160 <main+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %rbx,%rcx
xor    %r8d,%r8d
call   1030 <execl@plt>
jmp    1160 <main+0x30>

LLVM IR (-O0):
@.str = [10 x i8] c"/bin/bash\00"
@.str.1 = [5 x i8] c"bash\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [3 x i8] c"ls\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2, %13
%8 = call i64 (...) @fork()
store i64 %8, i64* %6
%9 = load i64, i64* %6
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %13
13: ; preds = %11, %7
%14 = call i32 @sleep(i32 2)
br label %7
}

LLVM IR (-O2):
@.str = [10 x i8] c"/bin/bash\00"
@.str.1 = [5 x i8] c"bash\00"
@.str.2 = [3 x i8] c"-c\00"
@.str.3 = [3 x i8] c"ls\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %8
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @execl(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @sleep(i32 2)
br label %3
}