#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 output {
  int dummy;
};
typedef int /*<<< orphan*/ echo;

/* Variables and functions */
int /*<<< orphan*/ add_output(struct output *, char *, int);
int /*<<< orphan*/ do_exec(char **, int /*<<< orphan*/, struct output *);
int /*<<< orphan*/ is_a_device(char *);
int /*<<< orphan*/ local_net_do(char **, int, char *, char *, char *,
                                struct output *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int no_route_and_arp(char *dev, char *addr, char *netmask,
                     struct output *output) {
  char echo[sizeof("echo 0 > /proc/sys/net/ipv4/conf/XXXXXXXXX/proxy_arp")];
  char *no_echo_argv[] = {"bash", "-c", echo, NULL};
  char *no_route_argv[] = {"route", "del", "-host", addr, "dev", dev, NULL};
  char *no_arp_argv[] = {"arp", "-i", "eth0", "-d", addr, "pub", NULL};
  if (!is_a_device(dev)) {
    add_output(output, "Device doesn't contain only alphanumeric characters\n",
               -1);
    return (-1);
  }
  do_exec(no_route_argv, 0, output);
  snprintf(echo, sizeof(echo) - 1,
           "echo 0 > /proc/sys/net/ipv4/conf/%.9s/proxy_arp", dev);
  do_exec(no_echo_argv, 0, output);
  if (netmask)
    local_net_do(no_arp_argv, 2, addr, netmask, dev, output);
  else
    do_exec(no_arp_argv, 0, output);
  return (0);
}


x86 assembly (clang, -O0):
<no_route_and_arp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
lea    0xe8e(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xe88(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
movq   $0x0,-0x68(%rbp)
lea    0xe70(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    0xe68(%rip),%rax
mov    %rax,-0xb8(%rbp)
lea    0xe5e(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
movq   $0x0,-0x90(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x100(%rbp)
lea    0xe1d(%rip),%rax
mov    %rax,-0xf8(%rbp)
lea    0xe12(%rip),%rax
mov    %rax,-0xf0(%rbp)
lea    0xe09(%rip),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    0xdf3(%rip),%rax
mov    %rax,-0xd8(%rbp)
movq   $0x0,-0xd0(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <is_a_device@plt>
cmp    $0x0,%eax
jne    1279 <no_route_and_arp+0x129>
mov    -0x28(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0xffffffff,%edx
call   1050 <add_output@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12fd <no_route_and_arp+0x1ad>
lea    -0xc0(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1030 <do_exec@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x34,%esi
lea    0xdc1(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1030 <do_exec@plt>
cmpq   $0x0,-0x20(%rbp)
je     12e4 <no_route_and_arp+0x194>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    $0x2,%esi
call   1070 <local_net_do@plt>
jmp    12f6 <no_route_and_arp+0x1a6>
lea    -0x100(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1030 <do_exec@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<no_route_and_arp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xe0,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
lea    0xe8e(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xe87(%rip),%rax
mov    %rax,0x48(%rsp)
lea    0xa0(%rsp),%rax
mov    %rax,0x50(%rsp)
movq   $0x0,0x58(%rsp)
lea    0xe68(%rip),%rax
mov    %rax,0x60(%rsp)
lea    0xe62(%rip),%rax
mov    %rax,0x68(%rsp)
lea    0xe5a(%rip),%rax
mov    %rax,0x70(%rsp)
mov    %rsi,0x78(%rsp)
lea    0xe4f(%rip),%rax
mov    %rax,0x80(%rsp)
mov    %rdi,0x88(%rsp)
movq   $0x0,0x90(%rsp)
lea    0xea0(%rip),%rax
mov    %rax,(%rsp)
lea    0xe25(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe1c(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe15(%rip),%rax
mov    %rax,0x18(%rsp)
mov    %rsi,0x20(%rsp)
lea    0xe07(%rip),%rax
mov    %rax,0x28(%rsp)
movq   $0x0,0x30(%rsp)
call   1060 <is_a_device@plt>
test   %eax,%eax
je     1293 <no_route_and_arp+0x143>
lea    0x60(%rsp),%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <do_exec@plt>
lea    0xe11(%rip),%rdx
lea    0xa0(%rsp),%rdi
mov    $0x34,%esi
mov    %rbx,%rcx
call   1040 <snprintf@plt>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <do_exec@plt>
mov    %rsp,%rdi
test   %r14,%r14
je     12ae <no_route_and_arp+0x15e>
mov    $0x2,%esi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %rbx,%r8
mov    %r15,%r9
call   1070 <local_net_do@plt>
jmp    12ba <no_route_and_arp+0x16a>
lea    0xd91(%rip),%rsi
mov    $0xffffffff,%ebp
mov    %r15,%rdi
mov    $0xffffffff,%edx
call   1050 <add_output@plt>
jmp    12ba <no_route_and_arp+0x16a>
xor    %ebp,%ebp
xor    %esi,%esi
mov    %r15,%rdx
call   1030 <do_exec@plt>
mov    %ebp,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.output = type { i32 }
@.str = [5 x i8] c"bash\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [6 x i8] c"route\00"
@.str.3 = [4 x i8] c"del\00"
@.str.4 = [6 x i8] c"-host\00"
@.str.5 = [4 x i8] c"dev\00"
@.str.6 = [4 x i8] c"arp\00"
@.str.7 = [3 x i8] c"-i\00"
@.str.8 = [5 x i8] c"eth0\00"
@.str.9 = [3 x i8] c"-d\00"
@.str.10 = [4 x i8] c"pub\00"
@.str.11 = [53 x i8] c"Device doesn't contain only alphanumeric characters\0A\00"
@.str.12 = [48 x i8] c"echo 0 > /proc/sys/net/ipv4/conf/%.9s/proxy_arp\00"
define i32 @no_route_and_arp(i8* %0, i8* %1, i8* %2, %struct.output* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.output*
%10 = alloca [53 x i8]
%11 = alloca [4 x i8*]
%12 = alloca [7 x i8*]
%13 = alloca [7 x i8*]
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store %struct.output* %3, %struct.output** %9
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %14
%15 = getelementptr inbounds i8*, i8** %14, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = getelementptr inbounds [53 x i8], [53 x i8]* %10, i64 0, i64 0
store i8* %17, i8** %16
%18 = getelementptr inbounds i8*, i8** %16, i64 1
store i8* null, i8** %18
%19 = getelementptr inbounds [7 x i8*], [7 x i8*]* %12, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds i8*, i8** %19, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds i8*, i8** %20, i64 1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %7
store i8* %23, i8** %22
%24 = getelementptr inbounds i8*, i8** %22, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %6
store i8* %26, i8** %25
%27 = getelementptr inbounds i8*, i8** %25, i64 1
store i8* null, i8** %27
%28 = getelementptr inbounds [7 x i8*], [7 x i8*]* %13, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %28
%29 = getelementptr inbounds i8*, i8** %28, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds i8*, i8** %29, i64 1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds i8*, i8** %30, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %7
store i8* %33, i8** %32
%34 = getelementptr inbounds i8*, i8** %32, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds i8*, i8** %34, i64 1
store i8* null, i8** %35
%36 = load i8*, i8** %6
%37 = call i32 @is_a_device(i8* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %4
%40 = load %struct.output*, %struct.output** %9
%41 = call i32 @add_output(%struct.output* %40, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 -1)
store i32 -1, i32* %5
br label %66
42: ; preds = %4
%43 = getelementptr inbounds [7 x i8*], [7 x i8*]* %12, i64 0, i64 0
%44 = load %struct.output*, %struct.output** %9
%45 = call i32 @do_exec(i8** %43, i32 0, %struct.output* %44)
%46 = getelementptr inbounds [53 x i8], [53 x i8]* %10, i64 0, i64 0
%47 = load i8*, i8** %6
%48 = call i32 @snprintf(i8* %46, i32 52, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 0
%50 = load %struct.output*, %struct.output** %9
%51 = call i32 @do_exec(i8** %49, i32 0, %struct.output* %50)
%52 = load i8*, i8** %8
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %61
54: ; preds = %42
%55 = getelementptr inbounds [7 x i8*], [7 x i8*]* %13, i64 0, i64 0
%56 = load i8*, i8** %7
%57 = load i8*, i8** %8
%58 = load i8*, i8** %6
%59 = load %struct.output*, %struct.output** %9
%60 = call i32 @local_net_do(i8** %55, i32 2, i8* %56, i8* %57, i8* %58, %struct.output* %59)
br label %65
61: ; preds = %42
%62 = getelementptr inbounds [7 x i8*], [7 x i8*]* %13, i64 0, i64 0
%63 = load %struct.output*, %struct.output** %9
%64 = call i32 @do_exec(i8** %62, i32 0, %struct.output* %63)
br label %65
65: ; preds = %61, %54
store i32 0, i32* %5
br label %66
66: ; preds = %65, %39
%67 = load i32, i32* %5
ret i32 %67
}

LLVM IR (-O2):
%struct.output = type { i32 }
@.str = [5 x i8] c"bash\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [6 x i8] c"route\00"
@.str.3 = [4 x i8] c"del\00"
@.str.4 = [6 x i8] c"-host\00"
@.str.5 = [4 x i8] c"dev\00"
@.str.6 = [4 x i8] c"arp\00"
@.str.7 = [3 x i8] c"-i\00"
@.str.8 = [5 x i8] c"eth0\00"
@.str.9 = [3 x i8] c"-d\00"
@.str.10 = [4 x i8] c"pub\00"
@.str.11 = [53 x i8] c"Device doesn't contain only alphanumeric characters\0A\00"
@.str.12 = [48 x i8] c"echo 0 > /proc/sys/net/ipv4/conf/%.9s/proxy_arp\00"
define i32 @no_route_and_arp(i8* %0, i8* %1, i8* %2, %struct.output* %3) {
%5 = alloca [53 x i8]
%6 = alloca [4 x i8*]
%7 = alloca [7 x i8*]
%8 = alloca [7 x i8*]
%9 = getelementptr inbounds [53 x i8], [53 x i8]* %5, i64 0, i64 0
%10 = bitcast [4 x i8*]* %6 to i8*
%11 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 2
store i8* %9, i8** %13
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 3
store i8* null, i8** %14
%15 = bitcast [7 x i8*]* %7 to i8*
%16 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %18
%19 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 3
store i8* %1, i8** %19
%20 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 5
store i8* %0, i8** %21
%22 = getelementptr inbounds [7 x i8*], [7 x i8*]* %7, i64 0, i64 6
store i8* null, i8** %22
%23 = bitcast [7 x i8*]* %8 to i8*
%24 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %26
%27 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i8** %27
%28 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 4
store i8* %1, i8** %28
%29 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [7 x i8*], [7 x i8*]* %8, i64 0, i64 6
store i8* null, i8** %30
%31 = call i32 @is_a_device(i8* %0)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %4
%34 = call i32 @add_output(%struct.output* %3, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0), i32 -1)
br label %44
35: ; preds = %4
%36 = call i32 @do_exec(i8** %16, i32 0, %struct.output* %3)
%37 = call i32 @snprintf(i8* %9, i32 52, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%38 = call i32 @do_exec(i8** %11, i32 0, %struct.output* %3)
%39 = icmp eq i8* %2, null
br i1 %39, label %42, label %40
40: ; preds = %35
%41 = call i32 @local_net_do(i8** %24, i32 2, i8* %1, i8* %2, i8* %0, %struct.output* %3)
br label %44
42: ; preds = %35
%43 = call i32 @do_exec(i8** %24, i32 0, %struct.output* %3)
br label %44
44: ; preds = %40, %42, %33
%45 = phi i32 [ -1, %33 ], [ 0, %42 ], [ 0, %40 ]
ret i32 %45
}