#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 *const, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *const, char *, int *);
int /*<<< orphan*/ stderr;
char *strerror(int);
int br_cmd_setbridgeprio(int argc, char *const *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    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xea2(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1193 <br_cmd_setbridgeprio+0x53>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e7 <br_cmd_setbridgeprio+0xa7>
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     11d8 <br_cmd_setbridgeprio+0x98>
mov    0x2e29(%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    0xe40(%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    %rsi,%rbx
mov    0x10(%rsi),%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(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %33
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i32, i32* %6
%21 = call i32 @br_set_bridge_priority(i8* %19, i32 %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %16
%25 = load i32, i32* @stderr
%26 = load i32, i32* %7
%27 = call i8* @strerror(i32 %26)
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %24, %16
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i32
store i32 %32, i32* %3
br label %33
33: ; preds = %29, %13
%34 = load i32, i32* %3
ret i32 %34
}

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(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = icmp eq i32 %7, 1
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %24
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* %3
%16 = call i32 @br_set_bridge_priority(i8* %14, i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* @stderr
%20 = call i8* @strerror(i32 %16)
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18, %12
%23 = zext i1 %17 to i32
br label %24
24: ; preds = %22, %9
%25 = phi i32 [ 1, %9 ], [ %23, %22 ]
ret i32 %25
}