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

/* Variables and functions */
scalar_t__ eapol_init(int *, struct sockaddr *);
int /*<<< orphan*/ eapol_logoff(int, struct sockaddr *);
int filte_success(int, struct sockaddr *);
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, (struct sockaddr *)&ll))
    return -1;
  fprintf(stderr, "[EAP:1] Requset logoff...\n");
  ;
  for (i = 0; i < (3); ++i) {
    eapol_logoff(skfd, (struct sockaddr *)&ll);
    state = filte_success(skfd, (struct sockaddr *)&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   1040 <fprintf@plt>
lea    -0x10(%rbp),%rsi
lea    -0x8(%rbp),%rdi
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   1040 <fprintf@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    1225 <eaplogoff+0xe5>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1030 <eapol_logoff@plt>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <filte_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   1040 <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   1040 <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   1040 <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   1040 <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   1040 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <filte_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   1040 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <filte_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   1040 <fprintf@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1030 <eapol_logoff@plt>
mov    0xc(%rsp),%edi
mov    %rbx,%rsi
call   1050 <filte_success@plt>
cmp    $0xfffffffe,%eax
je     1258 <eaplogoff+0x118>
mov    (%r15),%edi
lea    0xe0c(%rip),%rsi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebp
lea    0xe19(%rip),%r14
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <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 }
%struct.sockaddr = 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 = bitcast %struct.sockaddr_ll* %3 to %struct.sockaddr*
%9 = call i64 @eapol_init(i32* %2, %struct.sockaddr* %8)
%10 = icmp ne i64 0, %9
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 -1, i32* %1
br label %41
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %5
br label %15
15: ; preds = %35, %12
%16 = load i32, i32* %5
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %2
%20 = bitcast %struct.sockaddr_ll* %3 to %struct.sockaddr*
%21 = call i32 @eapol_logoff(i32 %19, %struct.sockaddr* %20)
%22 = load i32, i32* %2
%23 = bitcast %struct.sockaddr_ll* %3 to %struct.sockaddr*
%24 = call i32 @filte_success(i32 %22, %struct.sockaddr* %23)
store i32 %24, i32* %4
%25 = load i32, i32* %4
%26 = icmp eq i32 -2, %25
br i1 %26, label %27, label %30
27: ; preds = %18
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %41
30: ; preds = %18
%31 = load i32, i32* @stderr
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %30
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 1
store i32 %37, i32* %5
br label %15
38: ; preds = %15
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %1
br label %41
41: ; preds = %38, %27, %11
%42 = load i32, i32* %1
ret i32 %42
}

LLVM IR (-O2):
%struct.sockaddr_ll = type { i32 }
%struct.sockaddr = 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 = bitcast %struct.sockaddr_ll* %2 to %struct.sockaddr*
%8 = call i64 @eapol_init(i32* %1, %struct.sockaddr* %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %42
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %1
%14 = call i32 @eapol_logoff(i32 %13, %struct.sockaddr* %7)
%15 = load i32, i32* %1
%16 = call i32 @filte_success(i32 %15, %struct.sockaddr* %7)
%17 = icmp eq i32 %16, -2
br i1 %17, label %37, label %18
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 1)
%21 = load i32, i32* %1
%22 = call i32 @eapol_logoff(i32 %21, %struct.sockaddr* %7)
%23 = load i32, i32* %1
%24 = call i32 @filte_success(i32 %23, %struct.sockaddr* %7)
%25 = icmp eq i32 %24, -2
br i1 %25, label %37, label %26
26: ; preds = %18
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 2)
%29 = load i32, i32* %1
%30 = call i32 @eapol_logoff(i32 %29, %struct.sockaddr* %7)
%31 = load i32, i32* %1
%32 = call i32 @filte_success(i32 %31, %struct.sockaddr* %7)
%33 = icmp eq i32 %32, -2
br i1 %33, label %37, label %34
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0), i32 3)
br label %37
37: ; preds = %10, %18, %26, %34
%38 = phi i8* [ getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0), %34 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %26 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %18 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), %10 ]
%39 = phi i32 [ -1, %34 ], [ 0, %26 ], [ 0, %18 ], [ 0, %10 ]
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* %38)
br label %42
42: ; preds = %37, %0
%43 = phi i32 [ -1, %0 ], [ %39, %37 ]
ret i32 %43
}