#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 const *);
int wpa_ctrl_command(struct wpa_ctrl *, char *);
int wpa_cli_cmd_enable_network(struct wpa_ctrl *ctrl, int argc,
                               const char *argv[]) {
  char cmd[32];
  if (argc < 1) {
    printf("Invalid ENABLE_NETWORK command: needs one argument "
           "(network id)\n");
    return -1;
  }
  snprintf(cmd, sizeof(cmd), "ENABLE_NETWORK %s", argv[0]);
  cmd[sizeof(cmd) - 1] = '\0';
  return wpa_ctrl_command(ctrl, cmd);
}


x86 assembly (clang, -O0):
<wpa_cli_cmd_enable_network>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1165 <wpa_cli_cmd_enable_network+0x35>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1195 <wpa_cli_cmd_enable_network+0x65>
lea    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    $0x20,%esi
lea    0xec5(%rip),%rdx
call   1040 <snprintf@plt>
movb   $0x0,-0x21(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <wpa_ctrl_command@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wpa_cli_cmd_enable_network>:
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %esi,%esi
jle    116a <wpa_cli_cmd_enable_network+0x3a>
mov    %rdi,%rbx
mov    (%rdx),%rcx
lea    0xeb8(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   1040 <snprintf@plt>
movb   $0x0,0x1f(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <wpa_ctrl_command@plt>
jmp    117b <wpa_cli_cmd_enable_network+0x4b>
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.wpa_ctrl = type { i32 }
@.str = [65 x i8] c"Invalid ENABLE_NETWORK command: needs one argument (network id)\0A\00"
@.str.1 = [18 x i8] c"ENABLE_NETWORK %s\00"
define i32 @wpa_cli_cmd_enable_network(%struct.wpa_ctrl* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.wpa_ctrl*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca [32 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 slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %3
%12 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %23
13: ; preds = %3
%14 = getelementptr inbounds [32 x i8], [32 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 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 31
store i8 0, i8* %19
%20 = load %struct.wpa_ctrl*, %struct.wpa_ctrl** %5
%21 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%22 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %20, i8* %21)
store i32 %22, i32* %4
br label %23
23: ; preds = %13, %11
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
%struct.wpa_ctrl = type { i32 }
@.str.1 = [18 x i8] c"ENABLE_NETWORK %s\00"
@str = [64 x i8] c"Invalid ENABLE_NETWORK command: needs one argument (network id)\00"
define i32 @wpa_cli_cmd_enable_network(%struct.wpa_ctrl* %0, i32 %1, i8** nocapture %2) {
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %1, 1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @str, i64 0, i64 0))
br label %14
9: ; preds = %3
%10 = load i8*, i8** %2
%11 = call i32 @snprintf(i8* %5, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 31
store i8 0, i8* %12
%13 = call i32 @wpa_ctrl_command(%struct.wpa_ctrl* %0, i8* %5)
br label %14
14: ; preds = %9, %7
%15 = phi i32 [ -1, %7 ], [ %13, %9 ]
ret i32 %15
}