#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 /*<<< orphan*/ RTM_DELROUTE;
int /*<<< orphan*/ delete_radvd_conf(char const *, char const *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ error_message();
int iproute_modify(int /*<<< orphan*/, int /*<<< orphan*/, int, char **);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, int);
int /*<<< orphan*/ sprintf(int /*<<< orphan*/, char *, char *);
char *strerror(int /*<<< orphan*/);
int prefix_del(const char *ifname, int ifindex, const char *prefixPlain,
               int prefixLength) {
  int result;
  char *argv[3];
  char buf[512];
  delete_radvd_conf(ifname, prefixPlain, prefixLength);
  snprintf(buf, 127, "%s/%d", prefixPlain, prefixLength);
  argv[0] = buf;
  argv[1] = "dev";
  argv[2] = (char *)ifname;
  result = iproute_modify(RTM_DELROUTE, 0, 3, argv);
  if (result == 0)
    return 0;
  else {
    sprintf(error_message(), "Unable to delete prefix: %s", strerror(errno));
    return -1;
  }
}


x86 assembly (clang, -O0):
<prefix_del>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <delete_radvd_conf@plt>
lea    -0x240(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    $0x7f,%esi
lea    0xe5c(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x240(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0xe4b(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rcx
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <iproute_modify@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    11f9 <prefix_del+0x99>
movl   $0x0,-0x4(%rbp)
jmp    1230 <prefix_del+0xd0>
mov    $0x0,%al
call   1060 <error_message@plt>
mov    %eax,-0x244(%rbp)
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x244(%rbp),%edi
mov    %rax,%rdx
lea    0xde6(%rip),%rsi
call   1070 <sprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prefix_del>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x228,%rsp
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rdi,%r14
mov    %rdx,%rsi
mov    %ecx,%edx
call   1030 <delete_radvd_conf@plt>
lea    0xe7a(%rip),%rdx
lea    0x20(%rsp),%r15
mov    %r15,%rdi
mov    $0x7f,%esi
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1040 <snprintf@plt>
mov    %r15,(%rsp)
lea    0xe5d(%rip),%rax
mov    %rax,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
mov    %rsp,%rcx
xor    %esi,%esi
mov    $0x3,%edx
call   1050 <iproute_modify@plt>
test   %eax,%eax
je     11fe <prefix_del+0x9e>
xor    %eax,%eax
call   1060 <error_message@plt>
mov    %eax,%ebx
mov    0x2df7(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe1b(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <sprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x228,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s/%d\00"
@.str.1 = [4 x i8] c"dev\00"
@RTM_DELROUTE = global i32 0
@.str.2 = [28 x i8] c"Unable to delete prefix: %s\00"
@errno = global i32 0
define i32 @prefix_del(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [3 x i8*]
%12 = alloca [512 x i8]
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%13 = load i8*, i8** %6
%14 = load i8*, i8** %8
%15 = load i32, i32* %9
%16 = call i32 @delete_radvd_conf(i8* %13, i8* %14, i32 %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%18 = load i8*, i8** %8
%19 = load i32, i32* %9
%20 = call i32 @snprintf(i8* %17, i32 127, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19)
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 0
store i8* %21, i8** %22
%23 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %23
%24 = load i8*, i8** %6
%25 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 2
store i8* %24, i8** %25
%26 = load i32, i32* @RTM_DELROUTE
%27 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 0
%28 = call i32 @iproute_modify(i32 %26, i32 0, i32 3, i8** %27)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %4
store i32 0, i32* %5
br label %37
32: ; preds = %4
%33 = call i32 (...) @error_message()
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @sprintf(i32 %33, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store i32 -1, i32* %5
br label %37
37: ; preds = %32, %31
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%d\00"
@.str.1 = [4 x i8] c"dev\00"
@RTM_DELROUTE = global i32 0
@.str.2 = [28 x i8] c"Unable to delete prefix: %s\00"
@errno = global i32 0
define i32 @prefix_del(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [3 x i8*]
%6 = alloca [512 x i8]
%7 = bitcast [3 x i8*]* %5 to i8*
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%9 = tail call i32 @delete_radvd_conf(i8* %0, i8* %2, i32 %3)
%10 = call i32 @snprintf(i8* %8, i32 127, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %3)
%11 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
store i8* %8, i8** %11
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %12
%13 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 2
store i8* %0, i8** %13
%14 = load i32, i32* @RTM_DELROUTE
%15 = call i32 @iproute_modify(i32 %14, i32 0, i32 3, i8** %11)
%16 = icmp eq i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %4
%18 = call i32 (...) @error_message()
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @sprintf(i32 %18, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %4, %17
%23 = phi i32 [ -1, %17 ], [ 0, %4 ]
ret i32 %23
}