#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 *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int br_cmd_addbr(char **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    %rdi,-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     1171 <br_cmd_addbr+0x41>
jmp    115e <br_cmd_addbr+0x2e>
mov    -0x18(%rbp),%eax
sub    $0x80,%eax
je     117d <br_cmd_addbr+0x4d>
jmp    11a6 <br_cmd_addbr+0x76>
movl   $0x0,-0x4(%rbp)
jmp    11d3 <br_cmd_addbr+0xa3>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe6b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d3 <br_cmd_addbr+0xa3>
mov    0x2e33(%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    0xe7b(%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    %rdi,%rbx
mov    0x8(%rdi),%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(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
store i8** %0, i8*** %3
%5 = load i8**, i8*** %3
%6 = getelementptr inbounds i8*, i8** %5, i64 1
%7 = load i8*, i8** %6
%8 = call i32 @br_add_bridge(i8* %7)
store i32 %8, i32* %4
switch i32 %8, label %16 [
i32 0, label %9
i32 128, label %10
]
9: ; preds = %1
store i32 0, i32* %2
br label %21
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %3
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %2
br label %21
16: ; preds = %1
%17 = load i32, i32* @stderr
%18 = load i32, i32* %4
%19 = call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %19)
store i32 1, i32* %2
br label %21
21: ; preds = %16, %10, %9
%22 = load i32, i32* %2
ret i32 %22
}

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(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = tail call i32 @br_add_bridge(i8* %3)
switch i32 %4, label %9 [
i32 0, label %13
i32 128, label %5
]
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %2
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %13
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i8* @strerror(i32 %4)
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %1, %9, %5
%14 = phi i32 [ 1, %9 ], [ 1, %5 ], [ %4, %1 ]
ret i32 %14
}