#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_enable_port_snooping(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int br_cmd_enableportsnooping(char **argv) {
  int err;
  int enable;
  if (sscanf(argv[1], "%i", &enable) != 1) {
    fprintf(stderr, "bad value\n");
    return 1;
  }
  err = br_enable_port_snooping(enable);
  if (err)
    fprintf(stderr, "enable port snooping failed: %s\n", strerror(errno));
  return err != 0;
}


x86 assembly (clang, -O0):
<br_cmd_enableportsnooping>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea5(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1190 <br_cmd_enableportsnooping+0x50>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e2 <br_cmd_enableportsnooping+0xa2>
mov    -0x18(%rbp),%edi
call   1040 <br_enable_port_snooping@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11d3 <br_cmd_enableportsnooping+0x93>
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x14(%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_enableportsnooping>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rdi),%rdi
lea    0xeb2(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    119f <br_cmd_enableportsnooping+0x5f>
mov    0x4(%rsp),%edi
call   1040 <br_enable_port_snooping@plt>
mov    %eax,%ebx
test   %eax,%eax
je     1196 <br_cmd_enableportsnooping+0x56>
mov    0x2e6d(%rip),%rax
mov    (%rax),%ebp
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
lea    0xe84(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
jmp    11bb <br_cmd_enableportsnooping+0x7b>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   1030 <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 = [11 x i8] c"bad value\0A\00"
@.str.2 = [33 x i8] c"enable port snooping failed: %s\0A\00"
@errno = global i32 0
define i32 @br_cmd_enableportsnooping(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 1
%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* %5)
%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 ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %28
14: ; preds = %1
%15 = load i32, i32* %5
%16 = call i32 @br_enable_port_snooping(i32 %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i32, i32* @stderr
%21 = load i32, i32* @errno
%22 = call i8* @strerror(i32 %21)
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %19, %14
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i32
store i32 %27, i32* %2
br label %28
28: ; preds = %24, %11
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@stderr = global i32 0
@.str.1 = [11 x i8] c"bad value\0A\00"
@.str.2 = [33 x i8] c"enable port snooping failed: %s\0A\00"
@errno = global i32 0
define i32 @br_cmd_enableportsnooping(i8** nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = getelementptr inbounds i8*, i8** %0, i64 1
%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 ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %22
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 @br_enable_port_snooping(i32 %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %15, %11
%21 = zext i1 %14 to i32
br label %22
22: ; preds = %20, %8
%23 = phi i32 [ 1, %8 ], [ %21, %20 ]
ret i32 %23
}