#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 sockaddr_ll {
  int dummy;
};

/* Variables and functions */
scalar_t__ eapol_init(int *, struct sockaddr_ll *);
int /*<<< orphan*/ eapol_logoff(int, struct sockaddr_ll *);
int filter_success(int, struct sockaddr_ll *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int eaplogoff(void) {
  int skfd;
  struct sockaddr_ll ll;
  int state;
  int i;
  fprintf(stderr, "[EAP:0] Initilize interface...\n");
  ;
  if (0 != eapol_init(&skfd, &ll))
    return -1;
  fprintf(stderr, "[EAP:1] Requset logoff...\n");
  ;
  for (i = 0; i < 3; ++i) {
    eapol_logoff(skfd, &ll);
    state = filter_success(skfd, &ll);
    if (-2 == state) {
      fprintf(stderr, "[EAP:2] Logoff!\n");
      ;
      return 0;
    }
    fprintf(stderr, " [EAP:1] %dth Try Requset logoff...\n", i + 1);
    ;
  }
  fprintf(stderr, "[EAP:ERROR] Not server in range. or You were logoff.\n");
  ;
  return -1;
}


x86 assembly (clang, -O0):
<eaplogoff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e91(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <eapol_init@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     1186 <eaplogoff+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    1243 <eaplogoff+0x103>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1225 <eaplogoff+0xe5>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1040 <eapol_logoff@plt>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1030 <filter_success@plt>
mov    %eax,-0x14(%rbp)
mov    $0xfffffffe,%eax
cmp    -0x14(%rbp),%eax
jne    11fa <eaplogoff+0xba>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1243 <eaplogoff+0x103>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
add    $0x1,%edx
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a4 <eaplogoff+0x64>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eaplogoff>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e8f(%rip),%r15
mov    (%r15),%edi
lea    0xea5(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1060 <eapol_init@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1267 <eaplogoff+0x127>
mov    (%r15),%edi
lea    0xe92(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <filter_success@plt>
lea    0xe82(%rip),%r14
cmp    $0xfffffffe,%eax
je     1258 <eaplogoff+0x118>
mov    (%r15),%edi
lea    0xe80(%rip),%rsi
xor    %ebp,%ebp
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <filter_success@plt>
cmp    $0xfffffffe,%eax
je     1258 <eaplogoff+0x118>
mov    (%r15),%edi
lea    0xe46(%rip),%rsi
xor    %ebp,%ebp
mov    $0x2,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1030 <filter_success@plt>
cmp    $0xfffffffe,%eax
je     1258 <eaplogoff+0x118>
mov    (%r15),%edi
lea    0xe0c(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
lea    0xe19(%rip),%r14
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_ll = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"[EAP:0] Initilize interface...\0A\00"
@.str.1 = [27 x i8] c"[EAP:1] Requset logoff...\0A\00"
@.str.2 = [17 x i8] c"[EAP:2] Logoff!\0A\00"
@.str.3 = [37 x i8] c" [EAP:1] %dth Try Requset logoff...\0A\00"
@.str.4 = [54 x i8] c"[EAP:ERROR] Not server in range. or You were logoff.\0A\00"
define i32 @eaplogoff() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_ll
%4 = alloca i32
%5 = alloca i32
%6 = load i32, i32* @stderr
%7 = call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @eapol_init(i32* %2, %struct.sockaddr_ll* %3)
%9 = icmp ne i64 0, %8
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 -1, i32* %1
br label %38
11: ; preds = %0
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %14
14: ; preds = %32, %11
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %35
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @eapol_logoff(i32 %18, %struct.sockaddr_ll* %3)
%20 = load i32, i32* %2
%21 = call i32 @filter_success(i32 %20, %struct.sockaddr_ll* %3)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp eq i32 -2, %22
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %38
27: ; preds = %17
%28 = load i32, i32* @stderr
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %14
35: ; preds = %14
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %38
38: ; preds = %35, %24, %10
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
%struct.sockaddr_ll = type { i32 }
@stderr = global i32 0
@.str = [32 x i8] c"[EAP:0] Initilize interface...\0A\00"
@.str.1 = [27 x i8] c"[EAP:1] Requset logoff...\0A\00"
@.str.2 = [17 x i8] c"[EAP:2] Logoff!\0A\00"
@.str.3 = [37 x i8] c" [EAP:1] %dth Try Requset logoff...\0A\00"
@.str.4 = [54 x i8] c"[EAP:ERROR] Not server in range. or You were logoff.\0A\00"
define i32 @eaplogoff() {
%1 = alloca i32
%2 = alloca %struct.sockaddr_ll
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.sockaddr_ll* %2 to i8*
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%7 = call i64 @eapol_init(i32* %1, %struct.sockaddr_ll* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %41
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %1
%13 = call i32 @eapol_logoff(i32 %12, %struct.sockaddr_ll* %2)
%14 = load i32, i32* %1
%15 = call i32 @filter_success(i32 %14, %struct.sockaddr_ll* %2)
%16 = icmp eq i32 %15, -2
br i1 %16, label %36, label %17
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 1)
%20 = load i32, i32* %1
%21 = call i32 @eapol_logoff(i32 %20, %struct.sockaddr_ll* %2)
%22 = load i32, i32* %1
%23 = call i32 @filter_success(i32 %22, %struct.sockaddr_ll* %2)
%24 = icmp eq i32 %23, -2
br i1 %24, label %36, label %25
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 2)
%28 = load i32, i32* %1
%29 = call i32 @eapol_logoff(i32 %28, %struct.sockaddr_ll* %2)
%30 = load i32, i32* %1
%31 = call i32 @filter_success(i32 %30, %struct.sockaddr_ll* %2)
%32 = icmp eq i32 %31, -2
br i1 %32, label %36, label %33
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 3)
br label %36
36: ; preds = %9, %17, %25, %33
%37 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), %33 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %25 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %17 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %9 ]
%38 = phi i32 [ -1, %33 ], [ 0, %25 ], [ 0, %17 ], [ 0, %9 ]
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* %37)
br label %41
41: ; preds = %36, %0
%42 = phi i32 [ -1, %0 ], [ %38, %36 ]
ret i32 %42
}