#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 */
struct stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ any_dhcp();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ sbox_run(int, int, char *, char *, char *, char *);
int stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
void dhcp_store_exec(void) {
  if (!any_dhcp())
    return;
  char *dhclient_path = "/sbin/dhclient";
  struct stat s;
  if (stat(dhclient_path, &s) == -1) {
    dhclient_path = "/usr/sbin/dhclient";
    if (stat(dhclient_path, &s) == -1) {
      fprintf(stderr, "Error: dhclient was not found.\n");
      exit(1);
    }
  }
  sbox_run((1 << 0) | (1 << 2), 4,
           ("/run"
            "/firejail"
            "/lib"
            "/fcopy"),
           "--follow-link", dhclient_path,
           "/run"
           "/firejail"
           "/mnt");
}


x86 assembly (clang, -O0):
<dhcp_store_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1070 <any_dhcp@plt>
cmp    $0x0,%eax
jne    116d <dhcp_store_exec+0x1d>
jmp    11fb <dhcp_store_exec+0xab>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    11d3 <dhcp_store_exec+0x83>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    11ce <dhcp_store_exec+0x7e>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11d3 <dhcp_store_exec+0x83>
mov    -0x8(%rbp),%r8
mov    $0x5,%edi
mov    $0x4,%esi
lea    0xe4b(%rip),%rdx
lea    0xe5c(%rip),%rcx
lea    0xe63(%rip),%r9
call   1050 <sbox_run@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcp_store_exec>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <any_dhcp@plt>
test   %eax,%eax
je     11b9 <dhcp_store_exec+0x69>
lea    0xe9d(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
jne    1192 <dhcp_store_exec+0x42>
lea    0xe80(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <stat@plt>
cmp    $0xffffffff,%eax
je     11bf <dhcp_store_exec+0x6f>
lea    0xe9a(%rip),%rdx
lea    0xeab(%rip),%rcx
lea    0xeb2(%rip),%r9
mov    $0x5,%edi
mov    $0x4,%esi
mov    %rbx,%r8
call   1050 <sbox_run@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [15 x i8] c"/sbin/dhclient\00"
@.str.1 = [19 x i8] c"/usr/sbin/dhclient\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"Error: dhclient was not found.\0A\00"
@.str.3 = [24 x i8] c"/run/firejail/lib/fcopy\00"
@.str.4 = [14 x i8] c"--follow-link\00"
@.str.5 = [18 x i8] c"/run/firejail/mnt\00"
define void @dhcp_store_exec() {
%1 = alloca i8*
%2 = alloca %struct.stat
%3 = call i32 (...) @any_dhcp()
%4 = icmp ne i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %0
br label %22
6: ; preds = %0
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %1
%7 = load i8*, i8** %1
%8 = call i32 @stat(i8* %7, %struct.stat* %2)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %19
10: ; preds = %6
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8** %1
%11 = load i8*, i8** %1
%12 = call i32 @stat(i8* %11, %struct.stat* %2)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %10
br label %19
19: ; preds = %18, %6
%20 = load i8*, i8** %1
%21 = call i32 @sbox_run(i32 5, i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %19, %5
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [15 x i8] c"/sbin/dhclient\00"
@.str.1 = [19 x i8] c"/usr/sbin/dhclient\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"Error: dhclient was not found.\0A\00"
@.str.3 = [24 x i8] c"/run/firejail/lib/fcopy\00"
@.str.4 = [14 x i8] c"--follow-link\00"
@.str.5 = [18 x i8] c"/run/firejail/mnt\00"
define void @dhcp_store_exec() {
%1 = alloca %struct.stat
%2 = tail call i32 (...) @any_dhcp()
%3 = icmp eq i32 %2, 0
br i1 %3, label %18, label %4
4: ; preds = %0
%5 = bitcast %struct.stat* %1 to i8*
%6 = call i32 @stat(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %struct.stat* %1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = call i32 @stat(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %struct.stat* %1)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %8, %4
%16 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %4 ]
%17 = tail call i32 @sbox_run(i32 5, i32 4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %0, %15
ret void
}