#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 *, char *);
int wpa_ctrl_command(struct wpa_ctrl *, char *);
int wpa_cli_cmd_preauthenticate(struct wpa_ctrl *ctrl, int argc, char *argv[]) {
  char cmd[256];
  if (argc != 1) {
    printf("Invalid PREAUTH command: needs one argument "
           "(BSSID)\n");
    return 0;
  }
  if (snprintf(cmd, sizeof(cmd), "PREAUTH %s", argv[0]) >= sizeof(cmd) - 1) {
    printf("Too long PREAUTH command.\n");
    return 0;
  }
  return wpa_ctrl_command(ctrl, cmd);
}


x86 assembly (clang, -O0):
<wpa_cli_cmd_preauthenticate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
je     1168 <wpa_cli_cmd_preauthenticate+0x38>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <wpa_cli_cmd_preauthenticate+0x90>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    $0x100,%esi
lea    0xeb3(%rip),%rdx
call   1040 <snprintf@plt>
cltq
cmp    $0xff,%rax
jb     11ad <wpa_cli_cmd_preauthenticate+0x7d>
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <wpa_cli_cmd_preauthenticate+0x90>
mov    -0x10(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1050 <wpa_ctrl_command@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wpa_cli_cmd_preauthenticate>:
push   %rbx
sub    $0x100,%rsp
cmp    $0x1,%esi
jne    1167 <wpa_cli_cmd_preauthenticate+0x37>
mov    %rdi,%rbx
mov    (%rdx),%rcx
lea    0xeb6(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <snprintf@plt>
cmp    $0xff,%eax
jb     1177 <wpa_cli_cmd_preauthenticate+0x47>
lea    0xea6(%rip),%rdi
jmp    116e <wpa_cli_cmd_preauthenticate+0x3e>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    1182 <wpa_cli_cmd_preauthenticate+0x52>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1050 <wpa_ctrl_command@plt>
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.wpa_ctrl = type { i32 }
@.str = [53 x i8] c"Invalid PREAUTH command: needs one argument (BSSID)\0A\00"
@.str.1 = [11 x i8] c"PREAUTH %s\00"
@.str.2 = [27 x i8] c"Too long PREAUTH command.\0A\00"
define i32 @wpa_cli_cmd_preauthenticate(%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]
store %struct.wpa_ctrl* %0, %struct.wpa_ctrl** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %27
13: ; preds = %3
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%15 = load i8**, i8*** %7
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @snprintf(i8* %14, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = sext i32 %18 to i64
%20 = icmp uge i64 %19, 255
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %4
br label %27
23: ; preds = %13
%24 = load %struct.wpa_ctrl*, %struct.wpa_ctrl** %5
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%26 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %24, i8* %25)
store i32 %26, i32* %4
br label %27
27: ; preds = %23, %21, %11
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
%struct.wpa_ctrl = type { i32 }
@.str.1 = [11 x i8] c"PREAUTH %s\00"
@str = [26 x i8] c"Too long PREAUTH command.\00"
@str.3 = [52 x i8] c"Invalid PREAUTH command: needs one argument (BSSID)\00"
define i32 @wpa_cli_cmd_preauthenticate(%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 eq i32 %1, 1
br i1 %6, label %9, label %7
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.3, i64 0, i64 0))
br label %17
9: ; preds = %3
%10 = load i8*, i8** %2
%11 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = icmp ugt i32 %11, 254
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %17
15: ; preds = %9
%16 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %0, i8* %5)
br label %17
17: ; preds = %15, %13, %7
%18 = phi i32 [ 0, %7 ], [ 0, %13 ], [ %16, %15 ]
ret i32 %18
}