#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*/ app_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ sys_exit(int);
int /*<<< orphan*/ sys_getpid();
int /*<<< orphan*/ sys_yield();
void run_child(void) {
  int i;
  volatile int checker = 1;
  app_printf("Child process %d!\n", sys_getpid());
  for (i = 0; i < 20; i++)
    sys_yield();
  sys_exit(1000);
}


x86 assembly (clang, -O0):
<run_child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1050 <sys_getpid@plt>
mov    %eax,%esi
lea    0xea1(%rip),%rdi
call   1030 <app_printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x14,-0x4(%rbp)
jge    118a <run_child+0x4a>
mov    $0x0,%al
call   1060 <sys_yield@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116b <run_child+0x2b>
mov    $0x3e8,%edi
call   1040 <sys_exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_child>:
push   %rax
movl   $0x1,0x4(%rsp)
xor    %eax,%eax
call   1050 <sys_getpid@plt>
lea    0xea9(%rip),%rdi
mov    %eax,%esi
call   1030 <app_printf@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
xor    %eax,%eax
call   1060 <sys_yield@plt>
mov    $0x3e8,%edi
pop    %rax
jmp    1040 <sys_exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"Child process %d!\0A\00"
define void @run_child() {
%1 = alloca i32
%2 = alloca i32
store volatile i32 1, i32* %2
%3 = call i32 (...) @sys_getpid()
%4 = call i32 @app_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 0, i32* %1
br label %5
5: ; preds = %10, %0
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 20
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = call i32 (...) @sys_yield()
br label %10
10: ; preds = %8
%11 = load i32, i32* %1
%12 = add nsw i32 %11, 1
store i32 %12, i32* %1
br label %5
13: ; preds = %5
%14 = call i32 @sys_exit(i32 1000)
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Child process %d!\0A\00"
define void @run_child() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store volatile i32 1, i32* %1
%3 = tail call i32 (...) @sys_getpid()
%4 = tail call i32 @app_printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (...) @sys_yield()
%6 = tail call i32 (...) @sys_yield()
%7 = tail call i32 (...) @sys_yield()
%8 = tail call i32 (...) @sys_yield()
%9 = tail call i32 (...) @sys_yield()
%10 = tail call i32 (...) @sys_yield()
%11 = tail call i32 (...) @sys_yield()
%12 = tail call i32 (...) @sys_yield()
%13 = tail call i32 (...) @sys_yield()
%14 = tail call i32 (...) @sys_yield()
%15 = tail call i32 (...) @sys_yield()
%16 = tail call i32 (...) @sys_yield()
%17 = tail call i32 (...) @sys_yield()
%18 = tail call i32 (...) @sys_yield()
%19 = tail call i32 (...) @sys_yield()
%20 = tail call i32 (...) @sys_yield()
%21 = tail call i32 (...) @sys_yield()
%22 = tail call i32 (...) @sys_yield()
%23 = tail call i32 (...) @sys_yield()
%24 = tail call i32 (...) @sys_yield()
%25 = tail call i32 @sys_exit(i32 1000)
ret void
}