#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 */
typedef char uint8_t;
typedef char uint32_t;

/* Variables and functions */
int /*<<< orphan*/ EVP_sha1();
char *HMAC(int /*<<< orphan*/, char *, int, char *, int, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fillbuf(char *, int);
int /*<<< orphan*/ free(char *);
char *generatePMK(char *, char *);
char *generatePTK(char *, char *, char *, char *, char *, int);
char generatecrc32(int /*<<< orphan*/, char *, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sendframe(char *, int, char *);
int sendeap(uint8_t *bssid, uint8_t *supmac, char *essid, char *psk,
            char *intname) {
  uint8_t *kck;
  uint8_t *pmk;
  uint8_t *mic;
  uint8_t *anonce;
  uint8_t *snonce;
  uint8_t *eapol1;
  uint8_t *eapol2;
  uint32_t eapol2CRC;
  anonce = (uint8_t *)malloc(32);
  if (anonce == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  snonce = (uint8_t *)malloc(32);
  if (snonce == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  fillbuf(anonce, 32);
  fillbuf(snonce, 32);
  eapol1 = (uint8_t *)malloc(144);
  if (eapol1 == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  memcpy(eapol1,
         "\x00\x00\x0d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x08\x02\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x40\x01"
         "\xaa\xaa\x03\x00\x00\x00\x88\x8e"
         "\x02\x03\x00\x5f\x02\x00\x8a\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01"
         "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
         "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
         144);
  memcpy(eapol1 + 17, supmac, 6);
  memcpy(eapol1 + 23, bssid, 6);
  memcpy(eapol1 + 29, bssid, 6);
  memcpy(eapol1 + 62, anonce, 32);
  eapol2 = (uint8_t *)malloc(175);
  if (eapol2 == NULL) {
    perror("can't allocate memory");
    exit(1);
  }
  memcpy(
      eapol2,
      "\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x08\x01\x3a\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x20\x65\xaa\xaa\x03\x00\x00\x00\x88\x8e\x02\x03\x00\x75"
      "\x02\x01\x0a\x00\x10\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x16\x30\x14\x01\x00\x00\x0f\xac\x04\x01\x00\x00\x0f\xac"
      "\x04\x01\x00\x00\x0f\xac\x02\x0c\x00\x00\x00\x00\x00",
      175);
  memcpy(eapol2 + 28, supmac, 6);
  memcpy(eapol2 + 22, bssid, 6);
  memcpy(eapol2 + 34, bssid, 6);
  memcpy(eapol2 + 67, snonce, 32);
  pmk = generatePMK(psk, (char *)essid);
  kck = generatePTK(bssid, supmac, pmk, anonce, snonce, 32);
  mic = HMAC(EVP_sha1(), kck, 16, (uint8_t *)(eapol2 + 50), 121, NULL, NULL);
  memcpy(eapol2 + 131, mic, 16);
  eapol2CRC = generatecrc32(0, (eapol2 + 18), 153);
  memcpy((eapol2 + 171), &eapol2CRC, 4);
  sendframe(eapol1, 144, intname);
  sendframe(eapol2, 175, intname);
  free(kck);
  free(pmk);
  free(eapol1);
  free(eapol2);
  free(anonce);
  free(snonce);
  return (0);
}


x86 assembly (clang, -O0):
<sendeap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x20,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    120b <sendeap+0x4b>
lea    0xe04(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    $0x20,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    123a <sendeap+0x7a>
lea    0xdd5(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x48(%rbp),%rdi
mov    $0x20,%esi
call   1070 <fillbuf@plt>
mov    -0x50(%rbp),%rdi
mov    $0x20,%esi
call   1070 <fillbuf@plt>
mov    $0x90,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    1285 <sendeap+0xc5>
lea    0xd8a(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x58(%rbp),%rdi
lea    0xd86(%rip),%rsi
mov    $0x90,%edx
call   1080 <memcpy@plt>
mov    -0x58(%rbp),%rdi
add    $0x11,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x58(%rbp),%rdi
add    $0x17,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x58(%rbp),%rdi
add    $0x1d,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x58(%rbp),%rdi
add    $0x3e,%rdi
mov    -0x48(%rbp),%rsi
mov    $0x20,%edx
call   1080 <memcpy@plt>
mov    $0xaf,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    1321 <sendeap+0x161>
lea    0xcee(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x60(%rbp),%rdi
lea    0xd7b(%rip),%rsi
mov    $0xaf,%edx
call   1080 <memcpy@plt>
mov    -0x60(%rbp),%rdi
add    $0x1c,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x60(%rbp),%rdi
add    $0x16,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x60(%rbp),%rdi
add    $0x22,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    -0x60(%rbp),%rdi
add    $0x43,%rdi
mov    -0x50(%rbp),%rsi
mov    $0x20,%edx
call   1080 <memcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <generatePMK@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%r8
mov    $0x20,%r9d
call   10b0 <generatePTK@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x30(%rbp),%rsi
mov    -0x60(%rbp),%rcx
add    $0x32,%rcx
mov    $0x10,%edx
mov    $0x79,%r8d
xor    %eax,%eax
mov    %eax,%r9d
movq   $0x0,(%rsp)
call   1090 <HMAC@plt>
mov    %rax,-0x40(%rbp)
mov    -0x60(%rbp),%rdi
add    $0x83,%rdi
mov    -0x40(%rbp),%rsi
mov    $0x10,%edx
call   1080 <memcpy@plt>
mov    -0x60(%rbp),%rsi
add    $0x12,%rsi
xor    %edi,%edi
mov    $0x99,%edx
call   1050 <generatecrc32@plt>
mov    %al,-0x61(%rbp)
mov    -0x60(%rbp),%rdi
add    $0xab,%rdi
lea    -0x61(%rbp),%rsi
mov    $0x4,%edx
call   1080 <memcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x90,%esi
call   10c0 <sendframe@plt>
mov    -0x60(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0xaf,%esi
call   10c0 <sendframe@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendeap>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r15
mov    %rcx,0x10(%rsp)
mov    %rdx,%rbx
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x20,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1416 <sendeap+0x256>
mov    %rax,%rbp
mov    %rbx,0x20(%rsp)
mov    $0x20,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1416 <sendeap+0x256>
mov    %rax,%r12
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fillbuf@plt>
mov    %r12,%rdi
mov    $0x20,%esi
call   1070 <fillbuf@plt>
mov    $0x90,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1416 <sendeap+0x256>
mov    %rax,%rbx
mov    %r15,0x18(%rsp)
lea    0xdca(%rip),%rsi
mov    %rax,%rdi
mov    $0x90,%edx
call   1080 <memcpy@plt>
lea    0x11(%rbx),%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
lea    0x17(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
lea    0x1d(%rbx),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
mov    %rbx,%rdi
add    $0x3e,%rdi
mov    %rbp,%rsi
mov    $0x20,%edx
call   1080 <memcpy@plt>
mov    $0xaf,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1416 <sendeap+0x256>
mov    %rax,%r15
lea    0xdea(%rip),%rsi
mov    %rax,%rdi
mov    $0xaf,%edx
call   1080 <memcpy@plt>
lea    0x1c(%r15),%rdi
mov    %r13,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
lea    0x16(%r15),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
lea    0x22(%r15),%rdi
mov    %r14,%rsi
mov    $0x6,%edx
call   1080 <memcpy@plt>
lea    0x43(%r15),%rdi
mov    %r12,%rsi
mov    $0x20,%edx
call   1080 <memcpy@plt>
mov    0x10(%rsp),%rdi
mov    0x20(%rsp),%rsi
call   1060 <generatePMK@plt>
mov    %r13,%rsi
mov    %rax,%r13
mov    %r14,%rdi
mov    %rax,%rdx
mov    %rbp,%rcx
mov    %r12,%r8
mov    $0x20,%r9d
call   10b0 <generatePTK@plt>
mov    %rbp,0x10(%rsp)
mov    %rax,%rbp
xor    %eax,%eax
call   1040 <EVP_sha1@plt>
lea    0x32(%r15),%rcx
movq   $0x0,(%rsp)
mov    %eax,%edi
mov    %rbp,%rsi
mov    $0x10,%edx
mov    $0x79,%r8d
xor    %r9d,%r9d
call   1090 <HMAC@plt>
lea    0x83(%r15),%rdi
mov    %rax,%rsi
mov    $0x10,%edx
call   1080 <memcpy@plt>
lea    0x12(%r15),%rsi
xor    %edi,%edi
mov    $0x99,%edx
call   1050 <generatecrc32@plt>
mov    %al,0xf(%rsp)
mov    %r15,%rdi
add    $0xab,%rdi
lea    0xf(%rsp),%rsi
mov    $0x4,%edx
call   1080 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x90,%esi
mov    0x18(%rsp),%r14
mov    %r14,%rdx
call   10c0 <sendframe@plt>
mov    %r15,%rdi
mov    $0xaf,%esi
mov    %r14,%rdx
call   10c0 <sendframe@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbe3(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"can't allocate memory\00"
@.str.1 = [145 x i8] c"\00\00\0D\00\00\00\00\00\00\00\00\00\00\08\02:\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00@\01\AA\AA\03\00\00\00\88\8E\02\03\00_\02\00\8A\00\10\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [176 x i8] c"\00\00\12\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\08\01:\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 e\AA\AA\03\00\00\00\88\8E\02\03\00u\02\01\0A\00\10\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\160\14\01\00\00\0F\AC\04\01\00\00\0F\AC\04\01\00\00\0F\AC\02\0C\00\00\00\00\00\00"
define i32 @sendeap(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%19 = call i64 @malloc(i32 32)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %14
%21 = load i8*, i8** %14
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %5
%24 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %5
%27 = call i64 @malloc(i32 32)
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %15
%29 = load i8*, i8** %15
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %26
%35 = load i8*, i8** %14
%36 = call i32 @fillbuf(i8* %35, i32 32)
%37 = load i8*, i8** %15
%38 = call i32 @fillbuf(i8* %37, i32 32)
%39 = call i64 @malloc(i32 144)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %16
%41 = load i8*, i8** %16
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %34
%47 = load i8*, i8** %16
%48 = call i32 @memcpy(i8* %47, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 144)
%49 = load i8*, i8** %16
%50 = getelementptr inbounds i8, i8* %49, i64 17
%51 = load i8*, i8** %7
%52 = call i32 @memcpy(i8* %50, i8* %51, i32 6)
%53 = load i8*, i8** %16
%54 = getelementptr inbounds i8, i8* %53, i64 23
%55 = load i8*, i8** %6
%56 = call i32 @memcpy(i8* %54, i8* %55, i32 6)
%57 = load i8*, i8** %16
%58 = getelementptr inbounds i8, i8* %57, i64 29
%59 = load i8*, i8** %6
%60 = call i32 @memcpy(i8* %58, i8* %59, i32 6)
%61 = load i8*, i8** %16
%62 = getelementptr inbounds i8, i8* %61, i64 62
%63 = load i8*, i8** %14
%64 = call i32 @memcpy(i8* %62, i8* %63, i32 32)
%65 = call i64 @malloc(i32 175)
%66 = inttoptr i64 %65 to i8*
store i8* %66, i8** %17
%67 = load i8*, i8** %17
%68 = icmp eq i8* %67, null
br i1 %68, label %69, label %72
69: ; preds = %46
%70 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %46
%73 = load i8*, i8** %17
%74 = call i32 @memcpy(i8* %73, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.2, i64 0, i64 0), i32 175)
%75 = load i8*, i8** %17
%76 = getelementptr inbounds i8, i8* %75, i64 28
%77 = load i8*, i8** %7
%78 = call i32 @memcpy(i8* %76, i8* %77, i32 6)
%79 = load i8*, i8** %17
%80 = getelementptr inbounds i8, i8* %79, i64 22
%81 = load i8*, i8** %6
%82 = call i32 @memcpy(i8* %80, i8* %81, i32 6)
%83 = load i8*, i8** %17
%84 = getelementptr inbounds i8, i8* %83, i64 34
%85 = load i8*, i8** %6
%86 = call i32 @memcpy(i8* %84, i8* %85, i32 6)
%87 = load i8*, i8** %17
%88 = getelementptr inbounds i8, i8* %87, i64 67
%89 = load i8*, i8** %15
%90 = call i32 @memcpy(i8* %88, i8* %89, i32 32)
%91 = load i8*, i8** %9
%92 = load i8*, i8** %8
%93 = call i8* @generatePMK(i8* %91, i8* %92)
store i8* %93, i8** %12
%94 = load i8*, i8** %6
%95 = load i8*, i8** %7
%96 = load i8*, i8** %12
%97 = load i8*, i8** %14
%98 = load i8*, i8** %15
%99 = call i8* @generatePTK(i8* %94, i8* %95, i8* %96, i8* %97, i8* %98, i32 32)
store i8* %99, i8** %11
%100 = call i32 (...) @EVP_sha1()
%101 = load i8*, i8** %11
%102 = load i8*, i8** %17
%103 = getelementptr inbounds i8, i8* %102, i64 50
%104 = call i8* @HMAC(i32 %100, i8* %101, i32 16, i8* %103, i32 121, i32* null, i32* null)
store i8* %104, i8** %13
%105 = load i8*, i8** %17
%106 = getelementptr inbounds i8, i8* %105, i64 131
%107 = load i8*, i8** %13
%108 = call i32 @memcpy(i8* %106, i8* %107, i32 16)
%109 = load i8*, i8** %17
%110 = getelementptr inbounds i8, i8* %109, i64 18
%111 = call signext i8 @generatecrc32(i32 0, i8* %110, i32 153)
store i8 %111, i8* %18
%112 = load i8*, i8** %17
%113 = getelementptr inbounds i8, i8* %112, i64 171
%114 = call i32 @memcpy(i8* %113, i8* %18, i32 4)
%115 = load i8*, i8** %16
%116 = load i8*, i8** %10
%117 = call i32 @sendframe(i8* %115, i32 144, i8* %116)
%118 = load i8*, i8** %17
%119 = load i8*, i8** %10
%120 = call i32 @sendframe(i8* %118, i32 175, i8* %119)
%121 = load i8*, i8** %11
%122 = call i32 @free(i8* %121)
%123 = load i8*, i8** %12
%124 = call i32 @free(i8* %123)
%125 = load i8*, i8** %16
%126 = call i32 @free(i8* %125)
%127 = load i8*, i8** %17
%128 = call i32 @free(i8* %127)
%129 = load i8*, i8** %14
%130 = call i32 @free(i8* %129)
%131 = load i8*, i8** %15
%132 = call i32 @free(i8* %131)
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"can't allocate memory\00"
@.str.1 = [145 x i8] c"\00\00\0D\00\00\00\00\00\00\00\00\00\00\08\02:\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00@\01\AA\AA\03\00\00\00\88\8E\02\03\00_\02\00\8A\00\10\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [176 x i8] c"\00\00\12\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\08\01:\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 e\AA\AA\03\00\00\00\88\8E\02\03\00u\02\01\0A\00\10\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\160\14\01\00\00\0F\AC\04\01\00\00\0F\AC\04\01\00\00\0F\AC\02\0C\00\00\00\00\00\00"
define i32 @sendeap(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8
%7 = tail call i64 @malloc(i32 32)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %5
%14 = tail call i64 @malloc(i32 32)
%15 = inttoptr i64 %14 to i8*
%16 = icmp eq i64 %14, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %13
%21 = tail call i32 @fillbuf(i8* %8, i32 32)
%22 = tail call i32 @fillbuf(i8* %15, i32 32)
%23 = tail call i64 @malloc(i32 144)
%24 = inttoptr i64 %23 to i8*
%25 = icmp eq i64 %23, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %20
%30 = tail call i32 @memcpy(i8* %24, i8* getelementptr inbounds ([145 x i8], [145 x i8]* @.str.1, i64 0, i64 0), i32 144)
%31 = getelementptr inbounds i8, i8* %24, i64 17
%32 = tail call i32 @memcpy(i8* %31, i8* %1, i32 6)
%33 = getelementptr inbounds i8, i8* %24, i64 23
%34 = tail call i32 @memcpy(i8* %33, i8* %0, i32 6)
%35 = getelementptr inbounds i8, i8* %24, i64 29
%36 = tail call i32 @memcpy(i8* %35, i8* %0, i32 6)
%37 = getelementptr inbounds i8, i8* %24, i64 62
%38 = tail call i32 @memcpy(i8* %37, i8* %8, i32 32)
%39 = tail call i64 @malloc(i32 175)
%40 = inttoptr i64 %39 to i8*
%41 = icmp eq i64 %39, 0
br i1 %41, label %42, label %45
42: ; preds = %29
%43 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %29
%46 = tail call i32 @memcpy(i8* %40, i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.2, i64 0, i64 0), i32 175)
%47 = getelementptr inbounds i8, i8* %40, i64 28
%48 = tail call i32 @memcpy(i8* %47, i8* %1, i32 6)
%49 = getelementptr inbounds i8, i8* %40, i64 22
%50 = tail call i32 @memcpy(i8* %49, i8* %0, i32 6)
%51 = getelementptr inbounds i8, i8* %40, i64 34
%52 = tail call i32 @memcpy(i8* %51, i8* %0, i32 6)
%53 = getelementptr inbounds i8, i8* %40, i64 67
%54 = tail call i32 @memcpy(i8* %53, i8* %15, i32 32)
%55 = tail call i8* @generatePMK(i8* %3, i8* %2)
%56 = tail call i8* @generatePTK(i8* %0, i8* %1, i8* %55, i8* %8, i8* %15, i32 32)
%57 = tail call i32 (...) @EVP_sha1()
%58 = getelementptr inbounds i8, i8* %40, i64 50
%59 = tail call i8* @HMAC(i32 %57, i8* %56, i32 16, i8* %58, i32 121, i32* null, i32* null)
%60 = getelementptr inbounds i8, i8* %40, i64 131
%61 = tail call i32 @memcpy(i8* %60, i8* %59, i32 16)
%62 = getelementptr inbounds i8, i8* %40, i64 18
%63 = tail call signext i8 @generatecrc32(i32 0, i8* %62, i32 153)
store i8 %63, i8* %6
%64 = getelementptr inbounds i8, i8* %40, i64 171
%65 = call i32 @memcpy(i8* %64, i8* %6, i32 4)
%66 = call i32 @sendframe(i8* %24, i32 144, i8* %4)
%67 = call i32 @sendframe(i8* %40, i32 175, i8* %4)
%68 = call i32 @free(i8* %56)
%69 = call i32 @free(i8* %55)
%70 = call i32 @free(i8* %24)
%71 = call i32 @free(i8* %40)
%72 = call i32 @free(i8* %8)
%73 = call i32 @free(i8* %15)
ret i32 0
}