#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ printf(char *, int, char);
int /*<<< orphan*/ sleep(int);
void child(char c, int l) {
  int i;
  if (fork())
    return;
  for (i = 0; i < l; i++) {
    printf("%d::%c\n", getpid(), c);
    sleep(2);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
je     1178 <child+0x28>
add    $0x10,%rsp
pop    %rbp
ret
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11bc <child+0x6c>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
lea    0xe65(%rip),%rdi
movsbl -0x1(%rbp),%edx
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    117f <child+0x2f>
xor    %edi,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<child>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1169 <child+0x19>
pop    %rbx
pop    %r14
pop    %rbp
ret
test   %ebx,%ebx
jle    11a2 <child+0x52>
movsbl %bpl,%ebp
lea    0xe88(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <sleep@plt>
add    $0xffffffff,%ebx
jne    1180 <child+0x30>
xor    %edi,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%d::%c\0A\00"
define void @child(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
%6 = call i64 (...) @fork()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %2
ret void
9: ; preds = %2
store i32 0, i32* %5
br label %10
10: ; preds = %19, %9
%11 = load i32, i32* %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = call i32 (...) @getpid()
%16 = load i8, i8* %3
%17 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i8 signext %16)
%18 = call i32 @sleep(i32 2)
br label %19
19: ; preds = %14
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %10
22: ; preds = %10
%23 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"%d::%c\0A\00"
define void @child(i8 signext %0, i32 %1) {
%3 = tail call i64 (...) @fork()
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = icmp sgt i32 %1, 0
br i1 %6, label %8, label %15
7: ; preds = %2
ret void
8: ; preds = %5, %8
%9 = phi i32 [ %13, %8 ], [ 0, %5 ]
%10 = tail call i32 (...) @getpid()
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %10, i8 signext %0)
%12 = tail call i32 @sleep(i32 2)
%13 = add nuw nsw i32 %9, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %8
15: ; preds = %8, %5
%16 = tail call i32 @exit(i32 0)
unreachable
}