#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*/ uint64_t;
typedef int 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);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, char *, int);
void lcpf_beacon(struct lcpa_metapack *pack, uint8_t *src, uint8_t *bssid,
                 int framecontrol, int duration, int fragment, int sequence,
                 uint64_t timestamp, int beacon, int capabilities) {
  uint8_t chunk[8];
  uint16_t *sixptr = (uint16_t *)chunk;
  uint64_t *ch64 = (uint64_t *)chunk;
  memcpy(chunk, "\xFF\xFF\xFF\xFF\xFF\xFF", 6);
  lcpf_80211headers(pack, 0, 8, framecontrol, duration, chunk, src, bssid, NULL,
                    fragment, sequence);
  *ch64 = timestamp;
  pack = lcpa_append_copy(pack, "BEACONBSSTIME", 8, chunk);
  *sixptr = beacon;
  pack = lcpa_append_copy(pack, "BEACONINT", 2, chunk);
  *sixptr = capabilities;
  pack = lcpa_append_copy(pack, "BEACONCAP", 2, chunk);
}


x86 assembly (clang, -O0):
<lcpf_beacon>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
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    %ecx,-0x2c(%rbp)
mov    %r8d,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x70(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x6,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    -0x60(%rbp),%r9
mov    -0x20(%rbp),%rbx
mov    -0x28(%rbp),%r11
mov    -0x34(%rbp),%r10d
mov    0x10(%rbp),%eax
xor    %esi,%esi
mov    $0x8,%edx
xor    %r14d,%r14d
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1050 <lcpf_80211headers@plt>
mov    0x18(%rbp),%ecx
mov    -0x70(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    0xe21(%rip),%rsi
mov    $0x8,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
mov    0x20(%rbp),%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    0xe09(%rip),%rsi
mov    $0x2,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
mov    0x28(%rbp),%ecx
mov    -0x68(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
lea    -0x60(%rbp),%rcx
lea    0xded(%rip),%rsi
mov    $0x2,%edx
call   1030 <lcpa_append_copy@plt>
mov    %rax,-0x18(%rbp)
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<lcpf_beacon>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,%r13d
mov    %r8d,%ebp
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
lea    0xea7(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x6,%edx
call   1040 <memcpy@plt>
sub    $0x8,%rsp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x8,%edx
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    %r14,%r9
mov    0x78(%rsp),%eax
push   %rax
push   %r13
push   $0x0
push   %r12
push   0x30(%rsp)
call   1050 <lcpf_80211headers@plt>
add    $0x30,%rsp
mov    0x78(%rsp),%eax
mov    %eax,0x10(%rsp)
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x8,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
mov    0x80(%rsp),%ecx
mov    %ecx,0x10(%rsp)
lea    0xe4a(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
mov    0x88(%rsp),%ecx
mov    %ecx,0x10(%rsp)
lea    0xe32(%rip),%rsi
mov    %rax,%rdi
mov    $0x2,%edx
mov    %r14,%rcx
call   1030 <lcpa_append_copy@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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