#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*/ echo();
int /*<<< orphan*/ fork();
int /*<<< orphan*/ pathserver();
int /*<<< orphan*/ serialin(unsigned int volatile *, int);
int /*<<< orphan*/ serialout(unsigned int volatile *, int);
void first(void) {
  if (!fork())
    pathserver();
  if (!fork())
    serialout(((volatile unsigned int *)0x101f1000), 0x1000);
  if (!fork())
    serialin(((volatile unsigned int *)0x101f1000), 0x1000);
  if (!fork())
    echo();
  while (1)
    ;
}


x86 assembly (clang, -O0):
<first>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    116b <first+0x1b>
mov    $0x0,%al
call   1040 <pathserver@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    118a <first+0x3a>
mov    $0x101f1000,%edi
mov    $0x1000,%esi
call   1050 <serialout@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    11a9 <first+0x59>
mov    $0x101f1000,%edi
mov    $0x1000,%esi
call   1060 <serialin@plt>
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%eax
jne    11c0 <first+0x70>
mov    $0x0,%al
call   1030 <echo@plt>
jmp    11c5 <first+0x75>
jmp    11c5 <first+0x75>

x86 assembly (clang, -O2):
<first>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    1163 <first+0x13>
xor    %eax,%eax
call   1040 <pathserver@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    117d <first+0x2d>
mov    $0x101f1000,%edi
mov    $0x1000,%esi
call   1050 <serialout@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    1197 <first+0x47>
mov    $0x101f1000,%edi
mov    $0x1000,%esi
call   1060 <serialin@plt>
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
jne    11b0 <first+0x60>
xor    %eax,%eax
call   1030 <echo@plt>
nopl   0x0(%rax)
jmp    11b0 <first+0x60>

LLVM IR (-O0):
define void @first() {
%1 = call i32 (...) @fork()
%2 = icmp ne i32 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = call i32 (...) @pathserver()
br label %5
5: ; preds = %3, %0
%6 = call i32 (...) @fork()
%7 = icmp ne i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = call i32 @serialout(i32* inttoptr (i64 270471168 to i32*), i32 4096)
br label %10
10: ; preds = %8, %5
%11 = call i32 (...) @fork()
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @serialin(i32* inttoptr (i64 270471168 to i32*), i32 4096)
br label %15
15: ; preds = %13, %10
%16 = call i32 (...) @fork()
%17 = icmp ne i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 (...) @echo()
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20, %21
br label %21
}

LLVM IR (-O2):
define void @first() {
%1 = tail call i32 (...) @fork()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (...) @pathserver()
br label %5
5: ; preds = %3, %0
%6 = tail call i32 (...) @fork()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @serialout(i32* inttoptr (i64 270471168 to i32*), i32 4096)
br label %10
10: ; preds = %8, %5
%11 = tail call i32 (...) @fork()
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @serialin(i32* inttoptr (i64 270471168 to i32*), i32 4096)
br label %15
15: ; preds = %13, %10
%16 = tail call i32 (...) @fork()
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 (...) @echo()
br label %20
20: ; preds = %18, %15
br label %21
21: ; preds = %20, %21
br label %21
}