#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 br_set_bridge_priority(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int br_cmd_setbridgeprio(char **argv) {
  int prio;
  int err;
  if (sscanf(argv[2], "%i", &prio) != 1) {
    fprintf(stderr, "bad priority\n");
    return 1;
  }
  err = br_set_bridge_priority(argv[1], prio);
  if (err)
    fprintf(stderr, "set bridge priority failed: %s\n", strerror(err));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_setbridgeprio>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea5(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1190 <br_cmd_setbridgeprio+0x50>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <br_cmd_setbridgeprio+0xa4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <br_set_bridge_priority@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11d5 <br_cmd_setbridgeprio+0x95>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpl   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_setbridgeprio>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x10(%rdi),%rdi
lea    0xeaf(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    119f <br_cmd_setbridgeprio+0x5f>
mov    0x8(%rbx),%rdi
mov    0x4(%rsp),%esi
call   1030 <br_set_bridge_priority@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1196 <br_cmd_setbridgeprio+0x56>
mov    0x2e66(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe87(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
jmp    11bb <br_cmd_setbridgeprio+0x7b>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"bad priority\0A\00"
@.str.2 = [32 x i8] c"set bridge priority failed: %s\0A\00"
define i32 @br_cmd_setbridgeprio(i8** %0) {
%2 = alloca i32
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
store i8** %0, i8*** %3
%6 = load i8**, i8*** %3
%7 = getelementptr inbounds i8*, i8** %6, i64 2
%8 = load i8*, i8** %7
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %31
14: ; preds = %1
%15 = load i8**, i8*** %3
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* %4
%19 = call i32 @br_set_bridge_priority(i8* %17, i32 %18)
store i32 %19, i32* %5
%20 = load i32, i32* %5
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i32, i32* @stderr
%24 = load i32, i32* %5
%25 = call i8* @strerror(i32 %24)
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %22, %14
%28 = load i32, i32* %5
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i32
store i32 %30, i32* %2
br label %31
31: ; preds = %27, %11
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [14 x i8] c"bad priority\0A\00"
@.str.2 = [32 x i8] c"set bridge priority failed: %s\0A\00"
define i32 @br_cmd_setbridgeprio(i8** nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = getelementptr inbounds i8*, i8** %0, i64 2
%5 = load i8*, i8** %4
%6 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %23
11: ; preds = %1
%12 = getelementptr inbounds i8*, i8** %0, i64 1
%13 = load i8*, i8** %12
%14 = load i32, i32* %2
%15 = call i32 @br_set_bridge_priority(i8* %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32, i32* @stderr
%19 = call i8* @strerror(i32 %15)
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %11
%22 = zext i1 %16 to i32
br label %23
23: ; preds = %21, %8
%24 = phi i32 [ 1, %8 ], [ %22, %21 ]
ret i32 %24
}