#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 int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ fork();
int getNUM(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  pid_t pid;
  int count;
  int i;
  int date[100] = {0};
  if (!(pid = fork())) {
    count = getNUM(date, 100);
    printf("in child 100 num:");
    for (i = 0; i < count; i++) {
      printf(" %d ", date[i]);
      sleep(1);
    }
    printf("\n");
    return 0;
  }
  count = getNUM(date, 50);
  printf("in parent 50 num:");
  for (i = 0; i < count; i++) {
    printf(" %d ", date[i]);
    sleep(1);
  }
  printf("\n");
  wait(&pid);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x1a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1218 <main+0xb8>
lea    -0x1a0(%rbp),%rdi
mov    $0x64,%esi
call   1080 <getNUM@plt>
mov    %eax,-0xc(%rbp)
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11fe <main+0x9e>
movslq -0x10(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c1 <main+0x61>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <main+0x13c>
lea    -0x1a0(%rbp),%rdi
mov    $0x32,%esi
call   1080 <getNUM@plt>
mov    %eax,-0xc(%rbp)
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    127e <main+0x11e>
movslq -0x10(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <sleep@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1241 <main+0xe1>
lea    0xd92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1060 <wait@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x1a0,%rsp
lea    0x10(%rsp),%rdi
mov    $0x190,%edx
xor    %esi,%esi
call   1050 <memset@plt>
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,0xc(%rsp)
lea    0x10(%rsp),%rdi
test   %eax,%eax
je     1207 <main+0x97>
mov    $0x32,%esi
call   1090 <getNUM@plt>
mov    %eax,%ebx
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    11f1 <main+0x81>
mov    %ebx,%r15d
lea    0xe49(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11d0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xc(%rsp),%rdi
call   1070 <wait@plt>
jmp    126b <main+0xfb>
mov    $0x64,%esi
call   1090 <getNUM@plt>
mov    %eax,%ebx
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
jle    1261 <main+0xf1>
mov    %ebx,%r15d
lea    0xde3(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1240 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x1a0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"in child 100 num:\00"
@.str.1 = [5 x i8] c" %d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [18 x i8] c"in parent 50 num:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x i32]
store i32 0, i32* %1
%6 = bitcast [100 x i32]* %5 to i8*
%7 = call i32 (...) @fork()
store i32 %7, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %29, label %9
9: ; preds = %0
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%11 = call i32 @getNUM(i32* %10, i32 100)
store i32 %11, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %13
13: ; preds = %24, %9
%14 = load i32, i32* %4
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = call i32 @sleep(i32 1)
br label %24
24: ; preds = %17
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %13
27: ; preds = %13
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %50
29: ; preds = %0
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 0
%31 = call i32 @getNUM(i32* %30, i32 50)
store i32 %31, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %33
33: ; preds = %44, %29
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %47
37: ; preds = %33
%38 = load i32, i32* %4
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [100 x i32], [100 x i32]* %5, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = call i32 @sleep(i32 1)
br label %44
44: ; preds = %37
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %33
47: ; preds = %33
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%49 = call i32 @wait(i32* %2)
store i32 0, i32* %1
br label %50
50: ; preds = %47, %27
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [18 x i8] c"in child 100 num:\00"
@.str.1 = [5 x i8] c" %d \00"
@.str.3 = [18 x i8] c"in parent 50 num:\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x i32]* %2 to i8*
%5 = tail call i32 (...) @fork()
store i32 %5, i32* %1
%6 = icmp eq i32 %5, 0
%7 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
br i1 %6, label %8, label %24
8: ; preds = %0
%9 = call i32 @getNUM(i32* %7, i32 100)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %22
12: ; preds = %8
%13 = zext i32 %9 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %20, %14 ]
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = call i32 @sleep(i32 1)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %8
%23 = call i32 @putchar(i32 10)
br label %41
24: ; preds = %0
%25 = call i32 @getNUM(i32* %7, i32 50)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp sgt i32 %25, 0
br i1 %27, label %28, label %38
28: ; preds = %24
%29 = zext i32 %25 to i64
br label %30
30: ; preds = %28, %30
%31 = phi i64 [ 0, %28 ], [ %36, %30 ]
%32 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %31
%33 = load i32, i32* %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = call i32 @sleep(i32 1)
%36 = add nuw nsw i64 %31, 1
%37 = icmp eq i64 %36, %29
br i1 %37, label %38, label %30
38: ; preds = %30, %24
%39 = call i32 @putchar(i32 10)
%40 = call i32 @wait(i32* %1)
br label %41
41: ; preds = %38, %22
ret i32 0
}