#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_port_snooping(char *, char *, char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int br_cmd_setportsnooping(char **argv) {
  int err;
  err = br_set_port_snooping(argv[1], argv[2], argv[3]);
  if (err)
    fprintf(stderr, "set port snooping failed: %s\n", strerror(errno));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_setportsnooping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%rdx
call   1040 <br_set_port_snooping@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1192 <br_cmd_setportsnooping+0x62>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%rdx
lea    0xe73(%rip),%rsi
call   1030 <fprintf@plt>
cmpl   $0x0,-0xc(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<br_cmd_setportsnooping>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rdi),%rax
mov    0x10(%rdi),%rsi
mov    0x18(%rdi),%rdx
mov    %rax,%rdi
call   1040 <br_set_port_snooping@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1175 <br_cmd_setportsnooping+0x45>
mov    0x2e8c(%rip),%rax
mov    (%rax),%ebp
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe95(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1030 <fprintf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"set port snooping failed: %s\0A\00"
@errno = global i32 0
define i32 @br_cmd_setportsnooping(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8*, i8** %0, i64 2
%5 = load i8*, i8** %4
%6 = getelementptr inbounds i8*, i8** %0, i64 3
%7 = load i8*, i8** %6
%8 = tail call i32 @br_set_port_snooping(i8* %3, i8* %5, i8* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %1
%16 = zext i1 %9 to i32
ret i32 %16
}