#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ _exit(int /*<<< orphan*/);
int /*<<< orphan*/ execlp(char *, char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
scalar_t__ vfork();
pid_t net_start_dhcpcd(char *ifname) {
  pid_t pid;
  if ((pid = vfork()) == 0) {
    execlp("/opt/ipnc/dhcpcd/"
           "dhcpcd",
           "/opt/ipnc/dhcpcd/"
           "dhcpcd",
           ifname, NULL);
    perror("exec dhcpcd failed");
    _exit(0);
  } else if (pid < 0) {
    perror("fork dhcpcd failed");
    return -1;
  }
  return pid;
}


x86 assembly (clang, -O0):
<net_start_dhcpcd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <vfork@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    118b <net_start_dhcpcd+0x4b>
mov    -0x10(%rbp),%rdx
lea    0xe94(%rip),%rsi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rsi,%rdi
call   1060 <execlp@plt>
lea    0xe99(%rip),%rdi
call   1040 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
cmpq   $0x0,-0x18(%rbp)
jge    11af <net_start_dhcpcd+0x6f>
lea    0xe8e(%rip),%rdi
call   1040 <perror@plt>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11bc <net_start_dhcpcd+0x7c>
jmp    11b4 <net_start_dhcpcd+0x74>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<net_start_dhcpcd>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1050 <vfork@plt>
test   %rax,%rax
je     1169 <net_start_dhcpcd+0x29>
js     1154 <net_start_dhcpcd+0x14>
pop    %rbx
ret
lea    0xed0(%rip),%rdi
call   1040 <perror@plt>
mov    $0xffffffffffffffff,%rax
pop    %rbx
ret
lea    0xe90(%rip),%rdi
mov    %rdi,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1060 <execlp@plt>
lea    0xe94(%rip),%rdi
call   1040 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"/opt/ipnc/dhcpcd/dhcpcd\00"
@.str.1 = [19 x i8] c"exec dhcpcd failed\00"
@.str.2 = [19 x i8] c"fork dhcpcd failed\00"
define i64 @net_start_dhcpcd(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = call i64 (...) @vfork()
store i64 %5, i64* %4
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @execlp(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8, i32* null)
%10 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @_exit(i32 0)
unreachable
12: ; preds = %1
%13 = load i64, i64* %4
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
store i64 -1, i64* %2
br label %20
17: ; preds = %12
br label %18
18: ; preds = %17
%19 = load i64, i64* %4
store i64 %19, i64* %2
br label %20
20: ; preds = %18, %15
%21 = load i64, i64* %2
ret i64 %21
}

LLVM IR (-O2):
@.str = [24 x i8] c"/opt/ipnc/dhcpcd/dhcpcd\00"
@.str.1 = [19 x i8] c"exec dhcpcd failed\00"
@.str.2 = [19 x i8] c"fork dhcpcd failed\00"
define i64 @net_start_dhcpcd(i8* %0) {
%2 = tail call i64 (...) @vfork()
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i32 @execlp(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0, i32* null)
%6 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @_exit(i32 0)
unreachable
8: ; preds = %1
%9 = icmp slt i64 %2, 0
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %8, %10
%13 = phi i64 [ -1, %10 ], [ %2, %8 ]
ret i64 %13
}