#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 */
struct wpa_ctrl {
  int dummy;
};
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int snprintf(char *, int, char *, ...);
int wpa_ctrl_command(struct wpa_ctrl *, char *);
int wpa_cli_cmd_bssid(struct wpa_ctrl *ctrl, int argc, const char *argv[]) {
  char cmd[256], *pos, *end;
  int i, ret;
  if (argc < 2) {
    printf("Invalid BSSID command: needs two arguments (network "
           "id and BSSID)\n");
    return -1;
  }
  end = cmd + sizeof(cmd);
  pos = cmd;
  ret = snprintf(pos, end - pos, "BSSID");
  if (ret < 0 || ret >= end - pos) {
    printf("Too long BSSID command.\n");
    return -1;
  }
  pos += ret;
  for (i = 0; i < argc; i++) {
    ret = snprintf(pos, end - pos, " %s", argv[i]);
    if (ret < 0 || ret >= end - pos) {
      printf("Too long BSSID command.\n");
      return -1;
    }
    pos += ret;
  }
  return wpa_ctrl_command(ctrl, cmd);
}


x86 assembly (clang, -O0):
<wpa_cli_cmd_bssid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1168 <wpa_cli_cmd_bssid+0x38>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f5 <wpa_cli_cmd_bssid+0x1c5>
lea    -0x120(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x130(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    -0x128(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
lea    0xe98(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x138(%rbp)
cmpl   $0x0,-0x138(%rbp)
jl     11e6 <wpa_cli_cmd_bssid+0xb6>
movslq -0x138(%rbp),%rax
mov    -0x130(%rbp),%rcx
mov    -0x128(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jl     11fe <wpa_cli_cmd_bssid+0xce>
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f5 <wpa_cli_cmd_bssid+0x1c5>
mov    -0x138(%rbp),%ecx
mov    -0x128(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x128(%rbp)
movl   $0x0,-0x134(%rbp)
mov    -0x134(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    12e2 <wpa_cli_cmd_bssid+0x1b2>
mov    -0x128(%rbp),%rdi
mov    -0x130(%rbp),%rax
mov    -0x128(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x20(%rbp),%rax
movslq -0x134(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xe01(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %eax,-0x138(%rbp)
cmpl   $0x0,-0x138(%rbp)
jl     129c <wpa_cli_cmd_bssid+0x16c>
movslq -0x138(%rbp),%rax
mov    -0x130(%rbp),%rcx
mov    -0x128(%rbp),%rdx
sub    %rdx,%rcx
cmp    %rcx,%rax
jl     12b4 <wpa_cli_cmd_bssid+0x184>
lea    0xda6(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12f5 <wpa_cli_cmd_bssid+0x1c5>
mov    -0x138(%rbp),%ecx
mov    -0x128(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x128(%rbp)
mov    -0x134(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134(%rbp)
jmp    1222 <wpa_cli_cmd_bssid+0xf2>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1050 <wpa_ctrl_command@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wpa_cli_cmd_bssid>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
cmp    $0x1,%esi
jg     114f <wpa_cli_cmd_bssid+0x1f>
lea    0xed5(%rip),%rdi
jmp    117d <wpa_cli_cmd_bssid+0x4d>
mov    %rdx,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xea2(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
cmp    $0x100,%eax
jb     1199 <wpa_cli_cmd_bssid+0x69>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,0x8(%rsp)
mov    %eax,%eax
lea    (%rsp,%rax,1),%rbx
add    $0x10,%rbx
mov    %ebp,%r14d
lea    0xe54(%rip),%r12
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x110(%rsp),%rbp
sub    %rbx,%rbp
mov    (%r15,%r13,8),%rcx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <snprintf@plt>
test   %eax,%eax
js     1176 <wpa_cli_cmd_bssid+0x46>
mov    %eax,%eax
cmp    %rax,%rbp
jle    1176 <wpa_cli_cmd_bssid+0x46>
add    %rax,%rbx
add    $0x1,%r13
cmp    %r13,%r14
jne    11c0 <wpa_cli_cmd_bssid+0x90>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdi
call   1050 <wpa_ctrl_command@plt>
jmp    1187 <wpa_cli_cmd_bssid+0x57>

LLVM IR (-O0):
%struct.wpa_ctrl = type { i32 }
@.str = [67 x i8] c"Invalid BSSID command: needs two arguments (network id and BSSID)\0A\00"
@.str.1 = [6 x i8] c"BSSID\00"
@.str.2 = [25 x i8] c"Too long BSSID command.\0A\00"
@.str.3 = [4 x i8] c" %s\00"
define i32 @wpa_cli_cmd_bssid(%struct.wpa_ctrl* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.wpa_ctrl*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca [256 x i8]
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store %struct.wpa_ctrl* %0, %struct.wpa_ctrl** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %90
17: ; preds = %3
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 256
store i8* %19, i8** %10
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i8*, i8** %10
%23 = load i8*, i8** %9
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %21, i32 %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 %28, i32* %12
%29 = load i32, i32* %12
%30 = icmp slt i32 %29, 0
br i1 %30, label %40, label %31
31: ; preds = %17
%32 = load i32, i32* %12
%33 = sext i32 %32 to i64
%34 = load i8*, i8** %10
%35 = load i8*, i8** %9
%36 = ptrtoint i8* %34 to i64
%37 = ptrtoint i8* %35 to i64
%38 = sub i64 %36, %37
%39 = icmp sge i64 %33, %38
br i1 %39, label %40, label %42
40: ; preds = %31, %17
%41 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %90
42: ; preds = %31
%43 = load i32, i32* %12
%44 = load i8*, i8** %9
%45 = sext i32 %43 to i64
%46 = getelementptr inbounds i8, i8* %44, i64 %45
store i8* %46, i8** %9
store i32 0, i32* %11
br label %47
47: ; preds = %83, %42
%48 = load i32, i32* %11
%49 = load i32, i32* %6
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %86
51: ; preds = %47
%52 = load i8*, i8** %9
%53 = load i8*, i8** %10
%54 = load i8*, i8** %9
%55 = ptrtoint i8* %53 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = load i8**, i8*** %7
%60 = load i32, i32* %11
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8*, i8** %59, i64 %61
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %52, i32 %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %63)
store i32 %64, i32* %12
%65 = load i32, i32* %12
%66 = icmp slt i32 %65, 0
br i1 %66, label %76, label %67
67: ; preds = %51
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = load i8*, i8** %10
%71 = load i8*, i8** %9
%72 = ptrtoint i8* %70 to i64
%73 = ptrtoint i8* %71 to i64
%74 = sub i64 %72, %73
%75 = icmp sge i64 %69, %74
br i1 %75, label %76, label %78
76: ; preds = %67, %51
%77 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %90
78: ; preds = %67
%79 = load i32, i32* %12
%80 = load i8*, i8** %9
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds i8, i8* %80, i64 %81
store i8* %82, i8** %9
br label %83
83: ; preds = %78
%84 = load i32, i32* %11
%85 = add nsw i32 %84, 1
store i32 %85, i32* %11
br label %47
86: ; preds = %47
%87 = load %struct.wpa_ctrl*, %struct.wpa_ctrl** %5
%88 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%89 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %87, i8* %88)
store i32 %89, i32* %4
br label %90
90: ; preds = %86, %76, %40, %15
%91 = load i32, i32* %4
ret i32 %91
}

LLVM IR (-O2):
%struct.wpa_ctrl = type { i32 }
@.str.1 = [6 x i8] c"BSSID\00"
@.str.3 = [4 x i8] c" %s\00"
@str.4 = [24 x i8] c"Too long BSSID command.\00"
@str.5 = [66 x i8] c"Invalid BSSID command: needs two arguments (network id and BSSID)\00"
define i32 @wpa_cli_cmd_bssid(%struct.wpa_ctrl* %0, i32 %1, i8** nocapture %2) {
%4 = alloca [256 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %1, 2
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @str.5, i64 0, i64 0))
br label %41
9: ; preds = %3
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 256
%11 = ptrtoint i8* %10 to i64
%12 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp ugt i32 %12, 255
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
br label %41
16: ; preds = %9
%17 = zext i32 %12 to i64
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %17
%19 = zext i32 %1 to i64
br label %20
20: ; preds = %16, %35
%21 = phi i64 [ 0, %16 ], [ %37, %35 ]
%22 = phi i8* [ %18, %16 ], [ %36, %35 ]
%23 = ptrtoint i8* %22 to i64
%24 = sub i64 %11, %23
%25 = trunc i64 %24 to i32
%26 = getelementptr inbounds i8*, i8** %2, i64 %21
%27 = load i8*, i8** %26
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %22, i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %27)
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %20
%31 = zext i32 %28 to i64
%32 = icmp sgt i64 %24, %31
br i1 %32, label %35, label %33
33: ; preds = %30, %20
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.4, i64 0, i64 0))
br label %41
35: ; preds = %30
%36 = getelementptr inbounds i8, i8* %22, i64 %31
%37 = add nuw nsw i64 %21, 1
%38 = icmp eq i64 %37, %19
br i1 %38, label %39, label %20
39: ; preds = %35
%40 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %0, i8* %5)
br label %41
41: ; preds = %39, %33, %14, %7
%42 = phi i32 [ -1, %7 ], [ -1, %14 ], [ -1, %33 ], [ %40, %39 ]
ret i32 %42
}