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

/* Variables and functions */
int O_APPEND;
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ execl(char *, char *, char *, int /*<<< orphan*/ *);
int open(char *, int, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ vfork();
int /*<<< orphan*/ write(int, int /*<<< orphan*/ *, int);
int main() {
  char *exe[] = {"陈", "宗", "权"};
  char *argv[] = {"", NULL};
  int i;
  pid_t cid;
  int fd = open("id", O_WRONLY | O_APPEND | O_CREAT, 0600);
  for (i = 0; i < 3; i++) {
    if ((cid = vfork()) == 0) {
      execl("pp", "pp", exe[i], NULL);
      _exit(1);
    } else {
      write(fd, &cid, sizeof(cid));
    }
  }
  close(fd);
  puts("hello");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2c4a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c47(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2c44(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2c49(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2c46(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
mov    0x2dfa(%rip),%rax
or     (%rax),%esi
mov    0x2e21(%rip),%rax
or     (%rax),%esi
lea    0xe34(%rip),%rdi
mov    $0x180,%edx
call   1070 <open@plt>
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x3,-0x34(%rbp)
jge    1251 <main+0xe1>
call   1080 <vfork@plt>
mov    %eax,-0x38(%rbp)
cmp    $0x0,%eax
jne    122d <main+0xbd>
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdx
lea    0xdf8(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1090 <execl@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x3c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
call   1050 <write@plt>
jmp    1243 <main+0xd3>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ec <main+0x7c>
mov    -0x3c(%rbp),%edi
call   1060 <close@plt>
lea    0xdb2(%rip),%rdi
call   1040 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e54(%rip),%rax
mov    0x2e45(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2e6a(%rip),%rax
mov    %ecx,%esi
or     (%rax),%esi
lea    0xe73(%rip),%rdi
mov    $0x180,%edx
call   1070 <open@plt>
mov    %eax,%ebx
call   1080 <vfork@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     121a <main+0xaa>
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
call   1050 <write@plt>
call   1080 <vfork@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     121e <main+0xae>
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
call   1050 <write@plt>
call   1080 <vfork@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     1225 <main+0xb5>
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
mov    %ebx,%edi
call   1050 <write@plt>
mov    %ebx,%edi
call   1060 <close@plt>
lea    0xe05(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
jmp    122a <main+0xba>
mov    $0x1,%eax
jmp    122a <main+0xba>
mov    $0x2,%eax
lea    0xde7(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rdi,%rsi
call   1090 <execl@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"\E9\99\88\00"
@.str.1 = [4 x i8] c"\E5\AE\97\00"
@.str.2 = [4 x i8] c"\E6\9D\83\00"
@__const.main.exe = [3 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0)]
@.str.3 = [1 x i8] zeroinitializer
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i32 0, i32 0), i8* null]
@.str.4 = [3 x i8] c"id\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@O_CREAT = global i32 0
@.str.5 = [3 x i8] c"pp\00"
@.str.6 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8*]
%3 = alloca [2 x i8*]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [3 x i8*]* %2 to i8*
%8 = bitcast [2 x i8*]* %3 to i8*
%9 = load i32, i32* @O_WRONLY
%10 = load i32, i32* @O_APPEND
%11 = or i32 %9, %10
%12 = load i32, i32* @O_CREAT
%13 = or i32 %11, %12
%14 = call i32 @open(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 384)
store i32 %14, i32* %6
store i32 0, i32* %4
br label %15
15: ; preds = %32, %0
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %35
18: ; preds = %15
%19 = call i32 @vfork()
store i32 %19, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x i8*], [3 x i8*]* %2, i64 0, i64 %23
%25 = load i8*, i8** %24
%26 = call i32 @execl(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %25, i32* null)
%27 = call i32 @_exit(i32 1)
unreachable
28: ; preds = %18
%29 = load i32, i32* %6
%30 = call i32 @write(i32 %29, i32* %5, i32 4)
br label %31
31: ; preds = %28
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %15
35: ; preds = %15
%36 = load i32, i32* %6
%37 = call i32 @close(i32 %36)
%38 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@.str = [4 x i8] c"\E9\99\88\00"
@.str.1 = [4 x i8] c"\E5\AE\97\00"
@.str.2 = [4 x i8] c"\E6\9D\83\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
@.str.4 = [3 x i8] c"id\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@O_CREAT = global i32 0
@.str.5 = [3 x i8] c"pp\00"
@.str.6 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_APPEND
%5 = or i32 %4, %3
%6 = load i32, i32* @O_CREAT
%7 = or i32 %5, %6
%8 = call i32 @open(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %7, i32 384)
%9 = call i32 @vfork()
store i32 %9, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %17
11: ; preds = %21, %17, %0
%12 = phi i64 [ 0, %0 ], [ 1, %17 ], [ 2, %21 ]
%13 = shl i64 %12, 2
%14 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %13)
%15 = call i32 @execl(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %14, i32* null)
%16 = call i32 @_exit(i32 1)
unreachable
17: ; preds = %0
%18 = call i32 @write(i32 %8, i32* %1, i32 4)
%19 = call i32 @vfork()
store i32 %19, i32* %1
%20 = icmp eq i32 %19, 0
br i1 %20, label %11, label %21
21: ; preds = %17
%22 = call i32 @write(i32 %8, i32* %1, i32 4)
%23 = call i32 @vfork()
store i32 %23, i32* %1
%24 = icmp eq i32 %23, 0
br i1 %24, label %11, label %25
25: ; preds = %21
%26 = call i32 @write(i32 %8, i32* %1, i32 4)
%27 = call i32 @close(i32 %8)
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}