#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 EEXIST 128
int br_add_bridge(char *const);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *const);
int /*<<< orphan*/ stderr;
char *strerror(int);
int br_cmd_addbr(int argc, char *const *argv) {
  int err;
  switch (err = br_add_bridge(argv[1])) {
  case 0:
    return 0;
  case EEXIST:
    fprintf(stderr,
            "device %s already exists; can't create "
            "bridge with the same name\n",
            argv[1]);
    return 1;
  default:
    fprintf(stderr, "add bridge failed: %s\n", strerror(err));
    return 1;
  }
}


x86 assembly (clang, -O0):
<br_cmd_addbr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <br_add_bridge@plt>
mov    %eax,-0x14(%rbp)
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
test   %eax,%eax
je     1174 <br_cmd_addbr+0x44>
jmp    1161 <br_cmd_addbr+0x31>
mov    -0x18(%rbp),%eax
sub    $0x80,%eax
je     1180 <br_cmd_addbr+0x50>
jmp    11a9 <br_cmd_addbr+0x79>
movl   $0x0,-0x4(%rbp)
jmp    11d6 <br_cmd_addbr+0xa6>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe68(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d6 <br_cmd_addbr+0xa6>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe78(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_addbr>:
push   %rbx
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1030 <br_add_bridge@plt>
test   %eax,%eax
je     1184 <br_cmd_addbr+0x54>
cmp    $0x80,%eax
jne    115e <br_cmd_addbr+0x2e>
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xea4(%rip),%rsi
jmp    117a <br_cmd_addbr+0x4a>
mov    0x2e7b(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1050 <strerror@plt>
lea    0xecd(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [66 x i8] c"device %s already exists; can't create bridge with the same name\0A\00"
@.str.1 = [23 x i8] c"add bridge failed: %s\0A\00"
define i32 @br_cmd_addbr(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @br_add_bridge(i8* %9)
store i32 %10, i32* %6
switch i32 %10, label %18 [
i32 0, label %11
i32 128, label %12
]
11: ; preds = %2
store i32 0, i32* %3
br label %23
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i32, i32* %6
%21 = call i8* @strerror(i32 %20)
%22 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %23
23: ; preds = %18, %12, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [66 x i8] c"device %s already exists; can't create bridge with the same name\0A\00"
@.str.1 = [23 x i8] c"add bridge failed: %s\0A\00"
define i32 @br_cmd_addbr(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @br_add_bridge(i8* %4)
switch i32 %5, label %10 [
i32 0, label %14
i32 128, label %6
]
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %3
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i8* @strerror(i32 %5)
%13 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %2, %10, %6
%15 = phi i32 [ 1, %10 ], [ 1, %6 ], [ %5, %2 ]
ret i32 %15
}