#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 WEXITSTATUS(int /*<<< orphan*/);
scalar_t__ executable_exists(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ system(char *);
int dhcp_client_stop(char *interface) {
  char command[32 + strlen(interface)];
  if (executable_exists("dhcpcd"))
    strcpy(command, "dhcpcd");
  else if (executable_exists("dhclient"))
    strcpy(command, "dhclient");
  else if (executable_exists("dhclient3"))
    strcpy(command, "dhclient3");
  else if (executable_exists("udhcpcd"))
    strcpy(command, "udhcpcd");
  else {
    puts("error: no dhcp client executable found!");
    return -1;
  }
  strcat(command, " -x ");
  strcat(command, interface);
  return WEXITSTATUS(system(command));
}


x86 assembly (clang, -O0):
<dhcp_client_stop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x20,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe62(%rip),%rdi
call   1070 <executable_exists@plt>
cmp    $0x0,%rax
je     11d6 <dhcp_client_stop+0x66>
mov    -0x30(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1285 <dhcp_client_stop+0x115>
lea    0xe23(%rip),%rdi
call   1070 <executable_exists@plt>
cmp    $0x0,%rax
je     1201 <dhcp_client_stop+0x91>
mov    -0x30(%rbp),%rdi
lea    0xe09(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1280 <dhcp_client_stop+0x110>
lea    0xe01(%rip),%rdi
call   1070 <executable_exists@plt>
cmp    $0x0,%rax
je     122c <dhcp_client_stop+0xbc>
mov    -0x30(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1030 <strcpy@plt>
jmp    127b <dhcp_client_stop+0x10b>
lea    0xde0(%rip),%rdi
call   1070 <executable_exists@plt>
cmp    $0x0,%rax
je     1257 <dhcp_client_stop+0xe7>
mov    -0x30(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1276 <dhcp_client_stop+0x106>
lea    0xdbd(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    12bc <dhcp_client_stop+0x14c>
jmp    127b <dhcp_client_stop+0x10b>
jmp    1280 <dhcp_client_stop+0x110>
jmp    1285 <dhcp_client_stop+0x115>
mov    -0x30(%rbp),%rdi
lea    0xdb3(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1060 <system@plt>
mov    %eax,%edi
call   1080 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dhcp_client_stop>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <strlen@plt>
add    $0x20,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe77(%rip),%r15
mov    %r15,%rdi
call   1070 <executable_exists@plt>
test   %rax,%rax
jne    11e6 <dhcp_client_stop+0x76>
lea    0xe4f(%rip),%r15
mov    %r15,%rdi
call   1070 <executable_exists@plt>
test   %rax,%rax
jne    11e6 <dhcp_client_stop+0x76>
lea    0xe44(%rip),%r15
mov    %r15,%rdi
call   1070 <executable_exists@plt>
test   %rax,%rax
jne    11e6 <dhcp_client_stop+0x76>
lea    0xe3a(%rip),%r15
mov    %r15,%rdi
call   1070 <executable_exists@plt>
test   %rax,%rax
je     1225 <dhcp_client_stop+0xb5>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
lea    0xe4b(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
mov    %eax,%edi
call   1080 <WEXITSTATUS@plt>
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdef(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    121a <dhcp_client_stop+0xaa>

LLVM IR (-O0):
@.str = [7 x i8] c"dhcpcd\00"
@.str.1 = [9 x i8] c"dhclient\00"
@.str.2 = [10 x i8] c"dhclient3\00"
@.str.3 = [8 x i8] c"udhcpcd\00"
@.str.4 = [40 x i8] c"error: no dhcp client executable found!\00"
@.str.5 = [5 x i8] c" -x \00"
define i32 @dhcp_client_stop(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
%9 = add nsw i32 32, %8
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i8, i64 %10
store i64 %10, i64* %5
%13 = call i64 @executable_exists(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %1
%16 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %37
17: ; preds = %1
%18 = call i64 @executable_exists(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %36
22: ; preds = %17
%23 = call i64 @executable_exists(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %35
27: ; preds = %22
%28 = call i64 @executable_exists(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %34
32: ; preds = %27
%33 = call i32 @puts(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %2
store i32 1, i32* %6
br label %43
34: ; preds = %30
br label %35
35: ; preds = %34, %25
br label %36
36: ; preds = %35, %20
br label %37
37: ; preds = %36, %15
%38 = call i32 @strcat(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%39 = load i8*, i8** %3
%40 = call i32 @strcat(i8* %12, i8* %39)
%41 = call i32 @system(i8* %12)
%42 = call i32 @WEXITSTATUS(i32 %41)
store i32 %42, i32* %2
store i32 1, i32* %6
br label %43
43: ; preds = %37, %32
%44 = load i8*, i8** %4
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [7 x i8] c"dhcpcd\00"
@.str.1 = [9 x i8] c"dhclient\00"
@.str.2 = [10 x i8] c"dhclient3\00"
@.str.3 = [8 x i8] c"udhcpcd\00"
@.str.4 = [40 x i8] c"error: no dhcp client executable found!\00"
@.str.5 = [5 x i8] c" -x \00"
define i32 @dhcp_client_stop(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 32
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = tail call i64 @executable_exists(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %1
%9 = tail call i64 @executable_exists(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = tail call i64 @executable_exists(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = tail call i64 @executable_exists(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %26
19: ; preds = %14, %11, %8, %1
%20 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %8 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %14 ]
%21 = call i32 @strcpy(i8* %5, i8* %20)
%22 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @strcat(i8* %5, i8* %0)
%24 = call i32 @system(i8* %5)
%25 = call i32 @WEXITSTATUS(i32 %24)
br label %26
26: ; preds = %19, %17
%27 = phi i32 [ %25, %19 ], [ -1, %17 ]
ret i32 %27
}