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


x86 assembly (clang, -O0):
<wpa_cli_cmd_level>:
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_level+0x38>
lea    0xea9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119a <wpa_cli_cmd_level+0x6a>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    $0x100,%esi
lea    0xeb7(%rip),%rdx
call   1040 <snprintf@plt>
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_level>:
push   %r14
push   %rbx
sub    $0x108,%rsp
cmp    $0x1,%esi
jne    1169 <wpa_cli_cmd_level+0x39>
mov    %rdi,%rbx
mov    (%rdx),%rcx
lea    0xeb4(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x100,%esi
call   1040 <snprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <wpa_ctrl_command@plt>
jmp    1177 <wpa_cli_cmd_level+0x47>
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.wpa_ctrl = type { i32 }
@.str = [57 x i8] c"Invalid LEVEL command: needs one argument (debug level)\0A\00"
@.str.1 = [9 x i8] c"LEVEL %s\00"
define i32 @wpa_cli_cmd_level(%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 ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %22
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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load %struct.wpa_ctrl*, %struct.wpa_ctrl** %5
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%21 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %19, i8* %20)
store i32 %21, i32* %4
br label %22
22: ; preds = %13, %11
%23 = load i32, i32* %4
ret i32 %23
}

LLVM IR (-O2):
%struct.wpa_ctrl = type { i32 }
@.str.1 = [9 x i8] c"LEVEL %s\00"
@str = [56 x i8] c"Invalid LEVEL command: needs one argument (debug level)\00"
define i32 @wpa_cli_cmd_level(%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 ([56 x i8], [56 x i8]* @str, i64 0, i64 0))
br label %13
9: ; preds = %3
%10 = load i8*, i8** %2
%11 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %0, i8* %5)
br label %13
13: ; preds = %9, %7
%14 = phi i32 [ 0, %7 ], [ %12, %9 ]
ret i32 %14
}