#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 sigma_dut {
  int dummy;
};
struct sigma_conn {
  int dummy;
};
struct sigma_cmd {
  int dummy;
};

/* Variables and functions */
char *get_param(struct sigma_cmd *, char *);
char *get_station_ifname();
int set_eap_common(struct sigma_dut *, struct sigma_conn *, char const *,
                   struct sigma_cmd *);
scalar_t__ set_network(char const *, int, char *, char *);
int cmd_sta_set_eapaka(struct sigma_dut *dut, struct sigma_conn *conn,
                       struct sigma_cmd *cmd) {
  const char *intf = get_param(cmd, "Interface");
  const char *ifname;
  int id;
  ifname = get_station_ifname();
  id = set_eap_common(dut, conn, ifname, cmd);
  if (id < 0)
    return id;
  if (set_network(ifname, id, "eap", "AKA") < 0)
    return -2;
  return 1;
}


x86 assembly (clang, -O0):
<cmd_sta_set_eapaka>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1030 <get_param@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <get_station_ifname@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1050 <set_eap_common@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    11a0 <cmd_sta_set_eapaka+0x60>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d7 <cmd_sta_set_eapaka+0x97>
mov    -0x30(%rbp),%rdi
mov    -0x34(%rbp),%esi
lea    0xe5c(%rip),%rdx
lea    0xe59(%rip),%rcx
call   1040 <set_network@plt>
cmp    $0x0,%rax
jge    11d0 <cmd_sta_set_eapaka+0x90>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11d7 <cmd_sta_set_eapaka+0x97>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_sta_set_eapaka>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xea8(%rip),%rsi
mov    %rdx,%rdi
call   1030 <get_param@plt>
xor    %eax,%eax
call   1060 <get_station_ifname@plt>
mov    %rax,%r14
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %rbx,%rcx
call   1050 <set_eap_common@plt>
test   %eax,%eax
js     119e <cmd_sta_set_eapaka+0x5e>
lea    0xe84(%rip),%rdx
lea    0xe81(%rip),%rcx
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <set_network@plt>
sar    $0x3f,%rax
xor    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.sigma_dut = type { i32 }
%struct.sigma_conn = type { i32 }
%struct.sigma_cmd = type { i32 }
@.str = [10 x i8] c"Interface\00"
@.str.1 = [4 x i8] c"eap\00"
@.str.2 = [4 x i8] c"AKA\00"
define i32 @cmd_sta_set_eapaka(%struct.sigma_dut* %0, %struct.sigma_conn* %1, %struct.sigma_cmd* %2) {
%4 = alloca i32
%5 = alloca %struct.sigma_dut*
%6 = alloca %struct.sigma_conn*
%7 = alloca %struct.sigma_cmd*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store %struct.sigma_dut* %0, %struct.sigma_dut** %5
store %struct.sigma_conn* %1, %struct.sigma_conn** %6
store %struct.sigma_cmd* %2, %struct.sigma_cmd** %7
%11 = load %struct.sigma_cmd*, %struct.sigma_cmd** %7
%12 = call i8* @get_param(%struct.sigma_cmd* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %8
%13 = call i8* (...) @get_station_ifname()
store i8* %13, i8** %9
%14 = load %struct.sigma_dut*, %struct.sigma_dut** %5
%15 = load %struct.sigma_conn*, %struct.sigma_conn** %6
%16 = load i8*, i8** %9
%17 = load %struct.sigma_cmd*, %struct.sigma_cmd** %7
%18 = call i32 @set_eap_common(%struct.sigma_dut* %14, %struct.sigma_conn* %15, i8* %16, %struct.sigma_cmd* %17)
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %3
%22 = load i32, i32* %10
store i32 %22, i32* %4
br label %30
23: ; preds = %3
%24 = load i8*, i8** %9
%25 = load i32, i32* %10
%26 = call i64 @set_network(i8* %24, i32 %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 -2, i32* %4
br label %30
29: ; preds = %23
store i32 1, i32* %4
br label %30
30: ; preds = %29, %28, %21
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
%struct.sigma_dut = type { i32 }
%struct.sigma_conn = type { i32 }
%struct.sigma_cmd = type { i32 }
@.str = [10 x i8] c"Interface\00"
@.str.1 = [4 x i8] c"eap\00"
@.str.2 = [4 x i8] c"AKA\00"
define i32 @cmd_sta_set_eapaka(%struct.sigma_dut* %0, %struct.sigma_conn* %1, %struct.sigma_cmd* %2) {
%4 = tail call i8* @get_param(%struct.sigma_cmd* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i8* (...) @get_station_ifname()
%6 = tail call i32 @set_eap_common(%struct.sigma_dut* %0, %struct.sigma_conn* %1, i8* %5, %struct.sigma_cmd* %2)
%7 = icmp slt i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = tail call i64 @set_network(i8* %5, i32 %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i64 %9, 0
%11 = select i1 %10, i32 -2, i32 1
br label %12
12: ; preds = %8, %3
%13 = phi i32 [ %6, %3 ], [ %11, %8 ]
ret i32 %13
}