#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;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ no_route_and_arp(char *, char *, char *, struct output *);
int /*<<< orphan*/ output_errno(struct output *, char *);
int /*<<< orphan*/ route_and_arp(char *, char *, char *, int /*<<< orphan*/,
                                 struct output *);
scalar_t__ setreuid(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
void change_addr(char *op, char *dev, char *address, char *netmask,
                 struct output *output) {
  if (setreuid(0, 0) < 0) {
    output_errno(output, "setreuid");
    exit(1);
  }
  if (!strcmp(op, "add"))
    route_and_arp(dev, address, netmask, 0, output);
  else
    no_route_and_arp(dev, address, netmask, output);
}


x86 assembly (clang, -O0):
<change_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
xor    %esi,%esi
mov    %esi,%edi
call   1050 <setreuid@plt>
cmp    $0x0,%rax
jge    11a9 <change_addr+0x49>
mov    -0x28(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <output_errno@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <change_addr+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%r8
xor    %ecx,%ecx
call   1060 <route_and_arp@plt>
jmp    11f3 <change_addr+0x93>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1070 <no_route_and_arp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change_addr>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   1050 <setreuid@plt>
test   %rax,%rax
js     11c6 <change_addr+0x66>
lea    0xe7c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
test   %eax,%eax
je     11b3 <change_addr+0x53>
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <no_route_and_arp@plt>
xor    %ecx,%ecx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1060 <route_and_arp@plt>
lea    0xe33(%rip),%rsi
mov    %r14,%rdi
call   1030 <output_errno@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.output = type { i32 }
@.str = [9 x i8] c"setreuid\00"
@.str.1 = [4 x i8] c"add\00"
define void @change_addr(i8* %0, i8* %1, i8* %2, i8* %3, %struct.output* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.output*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store %struct.output* %4, %struct.output** %10
%11 = call i64 @setreuid(i32 0, i32 0)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %5
%14 = load %struct.output*, %struct.output** %10
%15 = call i32 @output_errno(%struct.output* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %5
%18 = load i8*, i8** %6
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %17
%22 = load i8*, i8** %7
%23 = load i8*, i8** %8
%24 = load i8*, i8** %9
%25 = load %struct.output*, %struct.output** %10
%26 = call i32 @route_and_arp(i8* %22, i8* %23, i8* %24, i32 0, %struct.output* %25)
br label %33
27: ; preds = %17
%28 = load i8*, i8** %7
%29 = load i8*, i8** %8
%30 = load i8*, i8** %9
%31 = load %struct.output*, %struct.output** %10
%32 = call i32 @no_route_and_arp(i8* %28, i8* %29, i8* %30, %struct.output* %31)
br label %33
33: ; preds = %27, %21
ret void
}

LLVM IR (-O2):
%struct.output = type { i32 }
@.str = [9 x i8] c"setreuid\00"
@.str.1 = [4 x i8] c"add\00"
define void @change_addr(i8* nocapture %0, i8* %1, i8* %2, i8* %3, %struct.output* %4) {
%6 = tail call i64 @setreuid(i32 0, i32 0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call i32 @output_errno(%struct.output* %4, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %5
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @route_and_arp(i8* %1, i8* %2, i8* %3, i32 0, %struct.output* %4)
br label %18
16: ; preds = %11
%17 = tail call i32 @no_route_and_arp(i8* %1, i8* %2, i8* %3, %struct.output* %4)
br label %18
18: ; preds = %16, %14
ret void
}