#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*/ close(int);
int fork();
int /*<<< orphan*/ pdie(char *);
int /*<<< orphan*/ process_udp_child(int, char const *, char const *, int, int);
void fork_udp_reader(int sfd, const char *node, const char *port, int *pid,
                     int cpu, int pagesize) {
  *pid = fork();
  if (*pid < 0)
    pdie("creating udp reader");
  if (!*pid)
    process_udp_child(sfd, node, port, cpu, pagesize);
  close(sfd);
}


x86 assembly (clang, -O0):
<fork_udp_reader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1187 <fork_udp_reader+0x47>
lea    0xe7e(%rip),%rdi
call   1030 <pdie@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ab <fork_udp_reader+0x6b>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
call   1060 <process_udp_child@plt>
mov    -0x4(%rbp),%edi
call   1040 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fork_udp_reader>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%ebp
xor    %eax,%eax
call   1050 <fork@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     1182 <fork_udp_reader+0x42>
test   %eax,%eax
je     1194 <fork_udp_reader+0x54>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <close@plt>
lea    0xe77(%rip),%rdi
call   1030 <pdie@plt>
mov    (%rbx),%eax
test   %eax,%eax
jne    116d <fork_udp_reader+0x2d>
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1060 <process_udp_child@plt>
jmp    116d <fork_udp_reader+0x2d>

LLVM IR (-O0):
@.str = [20 x i8] c"creating udp reader\00"
define void @fork_udp_reader(i32 %0, i8* %1, i8* %2, i32* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%13 = call i32 (...) @fork()
%14 = load i32*, i32** %10
store i32 %13, i32* %14
%15 = load i32*, i32** %10
%16 = load i32, i32* %15
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %6
%19 = call i32 @pdie(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %6
%21 = load i32*, i32** %10
%22 = load i32, i32* %21
%23 = icmp ne i32 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %20
%25 = load i32, i32* %7
%26 = load i8*, i8** %8
%27 = load i8*, i8** %9
%28 = load i32, i32* %11
%29 = load i32, i32* %12
%30 = call i32 @process_udp_child(i32 %25, i8* %26, i8* %27, i32 %28, i32 %29)
br label %31
31: ; preds = %24, %20
%32 = load i32, i32* %7
%33 = call i32 @close(i32 %32)
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"creating udp reader\00"
define void @fork_udp_reader(i32 %0, i8* %1, i8* %2, i32* nocapture %3, i32 %4, i32 %5) {
%7 = tail call i32 (...) @fork()
store i32 %7, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @pdie(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* %3
br label %12
12: ; preds = %9, %6
%13 = phi i32 [ %11, %9 ], [ %7, %6 ]
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @process_udp_child(i32 %0, i8* %1, i8* %2, i32 %4, i32 %5)
br label %17
17: ; preds = %15, %12
%18 = tail call i32 @close(i32 %0)
ret void
}