#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 int /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;
struct lcpa_metapack {
  int dummy;
};

/* Variables and functions */
struct lcpa_metapack *lcpa_append_copy(struct lcpa_metapack *, char *, int,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ lcpf_80211headers(struct lcpa_metapack *, int /*<<< orphan*/,
                                     int, int, int, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *, int, int);
void lcpf_authreq(struct lcpa_metapack *pack, uint8_t *dst, uint8_t *src,
                  uint8_t *bssid, int framecontrol, int duration, int fragment,
                  int sequence, uint16_t authalgo, uint16_t auth_seq,
                  uint16_t auth_status) {
  uint8_t chunk[2];
  uint16_t *sixptr = (uint16_t *)chunk;
  lcpf_80211headers(pack, 0, 11, framecontrol, duration, dst, src, bssid, NULL,
                    fragment, sequence);
  *sixptr = authalgo;
  pack = lcpa_append_copy(pack, "AUTHALGO", 2, chunk);
  *sixptr = auth_seq;
  pack = lcpa_append_copy(pack, "AUTHSEQ", 2, chunk);
  *sixptr = auth_status;
  pack = lcpa_append_copy(pack, "AUTHSTATUS", 2, chunk);
}


x86 assembly (clang, -O0):
<lcpf_authreq>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8d,-0x34(%rbp)
mov    %r9d,-0x38(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%ecx
mov    -0x38(%rbp),%r8d
mov    -0x20(%rbp),%r9
mov    -0x28(%rbp),%rbx
mov    -0x30(%rbp),%r11
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
xor    %esi,%esi
mov    $0xb,%edx
xor    %r14d,%r14d
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1040 <lcpf_80211headers@plt>
mov    0x20(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe46(%rip),%rsi
mov    $0x2,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
mov    0x28(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe29(%rip),%rsi
mov    $0x2,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
mov    0x30(%rbp),%ecx
mov    -0x48(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x40(%rbp),%rcx
lea    0xe0b(%rip),%rsi
mov    $0x2,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcpf_authreq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r11
mov    %rdx,%r10
mov    %rsi,%rax
mov    %rdi,%rbx
mov    0x60(%rsp),%r15d
mov    0x58(%rsp),%r12d
mov    0x50(%rsp),%r14d
mov    0x40(%rsp),%r13d
mov    0x48(%rsp),%ebp
sub    $0x8,%rsp
xor    %esi,%esi
mov    $0xb,%edx
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %rax,%r9
push   %rbp
push   %r13
push   $0x0
push   %r11
push   %r10
call   1040 <lcpf_80211headers@plt>
add    $0x30,%rsp
mov    %r14d,(%rsp)
lea    0xe80(%rip),%rsi
mov    %rsp,%r14
mov    %rbx,%rdi
mov    $0x2,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
mov    %r12d,(%rsp)
lea    0xe6b(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
mov    %r15d,(%rsp)
lea    0xe58(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.lcpa_metapack = type { i32 }
@.str = [9 x i8] c"AUTHALGO\00"
@.str.1 = [8 x i8] c"AUTHSEQ\00"
@.str.2 = [11 x i8] c"AUTHSTATUS\00"
define void @lcpf_authreq(%struct.lcpa_metapack* %0, i32* %1, i32* %2, i32* %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = alloca %struct.lcpa_metapack*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca [2 x i32]
%24 = alloca i32*
store %struct.lcpa_metapack* %0, %struct.lcpa_metapack** %12
store i32* %1, i32** %13
store i32* %2, i32** %14
store i32* %3, i32** %15
store i32 %4, i32* %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %7, i32* %19
store i32 %8, i32* %20
store i32 %9, i32* %21
store i32 %10, i32* %22
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 0
store i32* %25, i32** %24
%26 = load %struct.lcpa_metapack*, %struct.lcpa_metapack** %12
%27 = load i32, i32* %16
%28 = load i32, i32* %17
%29 = load i32*, i32** %13
%30 = load i32*, i32** %14
%31 = load i32*, i32** %15
%32 = load i32, i32* %18
%33 = load i32, i32* %19
%34 = call i32 @lcpf_80211headers(%struct.lcpa_metapack* %26, i32 0, i32 11, i32 %27, i32 %28, i32* %29, i32* %30, i32* %31, i32* null, i32 %32, i32 %33)
%35 = load i32, i32* %20
%36 = load i32*, i32** %24
store i32 %35, i32* %36
%37 = load %struct.lcpa_metapack*, %struct.lcpa_metapack** %12
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 0
%39 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %37, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2, i32* %38)
store %struct.lcpa_metapack* %39, %struct.lcpa_metapack** %12
%40 = load i32, i32* %21
%41 = load i32*, i32** %24
store i32 %40, i32* %41
%42 = load %struct.lcpa_metapack*, %struct.lcpa_metapack** %12
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 0
%44 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2, i32* %43)
store %struct.lcpa_metapack* %44, %struct.lcpa_metapack** %12
%45 = load i32, i32* %22
%46 = load i32*, i32** %24
store i32 %45, i32* %46
%47 = load %struct.lcpa_metapack*, %struct.lcpa_metapack** %12
%48 = getelementptr inbounds [2 x i32], [2 x i32]* %23, i64 0, i64 0
%49 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %47, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 2, i32* %48)
store %struct.lcpa_metapack* %49, %struct.lcpa_metapack** %12
ret void
}

LLVM IR (-O2):
%struct.lcpa_metapack = type { i32 }
@.str = [9 x i8] c"AUTHALGO\00"
@.str.1 = [8 x i8] c"AUTHSEQ\00"
@.str.2 = [11 x i8] c"AUTHSTATUS\00"
define void @lcpf_authreq(%struct.lcpa_metapack* %0, i32* %1, i32* %2, i32* %3, i32 %4, i32 %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10) {
%12 = alloca [2 x i32]
%13 = bitcast [2 x i32]* %12 to i8*
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %12, i64 0, i64 0
%15 = tail call i32 @lcpf_80211headers(%struct.lcpa_metapack* %0, i32 0, i32 11, i32 %4, i32 %5, i32* %1, i32* %2, i32* %3, i32* null, i32 %6, i32 %7)
store i32 %8, i32* %14
%16 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2, i32* %14)
store i32 %9, i32* %14
%17 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 2, i32* %14)
store i32 %10, i32* %14
%18 = call %struct.lcpa_metapack* @lcpa_append_copy(%struct.lcpa_metapack* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 2, i32* %14)
ret void
}