#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 */
#define EINVAL 129
#define ENODEV 128
int br_del_interface(char const *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, ...);
int /*<<< orphan*/ if_nametoindex(char const *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int br_cmd_delif(int argc, char *const *argv) {
  const char *brname;
  int err;
  argc -= 2;
  brname = *++argv;
  while (argc-- > 0) {
    const char *ifname = *++argv;
    err = br_del_interface(brname, ifname);
    switch (err) {
    case 0:
      continue;
    case ENODEV:
      if (if_nametoindex(ifname) == 0)
        fprintf(stderr, "interface %s does not exist!\n", ifname);
      else
        fprintf(stderr, "bridge %s does not exist!\n", brname);
      break;
    case EINVAL:
      fprintf(stderr, "device %s is not a slave of %s\n", ifname, brname);
      break;
    default:
      fprintf(stderr, "can't delete %s from %s: %s\n", ifname, brname,
              strerror(err));
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<br_cmd_delif>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    12aa <br_cmd_delif+0x16a>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <br_del_interface@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     11e3 <br_cmd_delif+0xa3>
jmp    11bd <br_cmd_delif+0x7d>
mov    -0x2c(%rbp),%eax
sub    $0x80,%eax
je     11e8 <br_cmd_delif+0xa8>
jmp    11d0 <br_cmd_delif+0x90>
mov    -0x2c(%rbp),%eax
sub    $0x81,%eax
je     123a <br_cmd_delif+0xfa>
jmp    125e <br_cmd_delif+0x11e>
jmp    116f <br_cmd_delif+0x2f>
mov    -0x28(%rbp),%rdi
call   1040 <if_nametoindex@plt>
cmp    $0x0,%eax
jne    121a <br_cmd_delif+0xda>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    1235 <br_cmd_delif+0xf5>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129e <br_cmd_delif+0x15e>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
lea    0xde7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    129e <br_cmd_delif+0x15e>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    %rax,%r8
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12b1 <br_cmd_delif+0x171>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_delif>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
add    $0xfffffffe,%ebp
mov    0x8(%rsi),%r14
add    $0x10,%rbx
nopw   0x0(%rax,%rax,1)
test   %ebp,%ebp
jle    11ac <br_cmd_delif+0x6c>
add    $0xffffffff,%ebp
mov    (%rbx),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <br_del_interface@plt>
add    $0x8,%rbx
test   %eax,%eax
je     1160 <br_cmd_delif+0x20>
cmp    $0x81,%eax
je     11b0 <br_cmd_delif+0x70>
cmp    $0x80,%eax
jne    11cf <br_cmd_delif+0x8f>
mov    %r15,%rdi
call   1040 <if_nametoindex@plt>
mov    0x2e46(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     11fa <br_cmd_delif+0xba>
lea    0xe77(%rip),%rsi
mov    %r14,%rdx
jmp    1204 <br_cmd_delif+0xc4>
xor    %eax,%eax
jmp    1210 <br_cmd_delif+0xd0>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    120b <br_cmd_delif+0xcb>
mov    0x2e0a(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe73(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1030 <fprintf@plt>
jmp    120b <br_cmd_delif+0xcb>
lea    0xdff(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"interface %s does not exist!\0A\00"
@.str.1 = [27 x i8] c"bridge %s does not exist!\0A\00"
@.str.2 = [32 x i8] c"device %s is not a slave of %s\0A\00"
@.str.3 = [29 x i8] c"can't delete %s from %s: %s\0A\00"
define i32 @br_cmd_delif(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = sub nsw i32 %9, 2
store i32 %10, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %5
%13 = load i8*, i8** %12
store i8* %13, i8** %6
br label %14
14: ; preds = %26, %2
%15 = load i32, i32* %4
%16 = add nsw i32 %15, -1
store i32 %16, i32* %4
%17 = icmp sgt i32 %15, 0
br i1 %17, label %18, label %53
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i32 1
store i8** %20, i8*** %5
%21 = load i8*, i8** %20
store i8* %21, i8** %8
%22 = load i8*, i8** %6
%23 = load i8*, i8** %8
%24 = call i32 @br_del_interface(i8* %22, i8* %23)
store i32 %24, i32* %7
%25 = load i32, i32* %7
switch i32 %25, label %45 [
i32 0, label %26
i32 128, label %27
i32 129, label %40
]
26: ; preds = %18
br label %14
27: ; preds = %18
%28 = load i8*, i8** %8
%29 = call i32 @if_nametoindex(i8* %28)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %8
%34 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %39
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %6
%38 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %35, %31
br label %52
40: ; preds = %18
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %8
%43 = load i8*, i8** %6
%44 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %42, i8* %43)
br label %52
45: ; preds = %18
%46 = load i32, i32* @stderr
%47 = load i8*, i8** %8
%48 = load i8*, i8** %6
%49 = load i32, i32* %7
%50 = call i8* @strerror(i32 %49)
%51 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %47, i8* %48, i8* %50)
br label %52
52: ; preds = %45, %40, %39
store i32 1, i32* %3
br label %54
53: ; preds = %14
store i32 0, i32* %3
br label %54
54: ; preds = %53, %52
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"interface %s does not exist!\0A\00"
@.str.1 = [27 x i8] c"bridge %s does not exist!\0A\00"
@.str.2 = [32 x i8] c"device %s is not a slave of %s\0A\00"
@.str.3 = [29 x i8] c"can't delete %s from %s: %s\0A\00"
define i32 @br_cmd_delif(i32 %0, i8** nocapture %1) {
%3 = add nsw i32 %0, -2
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
br label %6
6: ; preds = %10, %2
%7 = phi i8** [ %4, %2 ], [ %12, %10 ]
%8 = phi i32 [ %3, %2 ], [ %11, %10 ]
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %30
10: ; preds = %6
%11 = add nsw i32 %8, -1
%12 = getelementptr inbounds i8*, i8** %7, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @br_del_interface(i8* %5, i8* %13)
switch i32 %14, label %26 [
i32 0, label %6
i32 128, label %15
i32 129, label %23
]
15: ; preds = %10
%16 = tail call i32 @if_nametoindex(i8* %13)
%17 = icmp eq i32 %16, 0
%18 = load i32, i32* @stderr
br i1 %17, label %19, label %21
19: ; preds = %15
%20 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %30
21: ; preds = %15
%22 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %5)
br label %30
23: ; preds = %10
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %13, i8* %5)
br label %30
26: ; preds = %10
%27 = load i32, i32* @stderr
%28 = tail call i8* @strerror(i32 %14)
%29 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* %5, i8* %28)
br label %30
30: ; preds = %6, %19, %21, %26, %23
%31 = phi i32 [ 1, %23 ], [ 1, %26 ], [ 1, %21 ], [ 1, %19 ], [ 0, %6 ]
ret i32 %31
}