#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ test000559(int /*<<< orphan*/ *, unsigned long long);
int /*<<< orphan*/ writebssid(int /*<<< orphan*/ *, unsigned long long);
void preparebssid(FILE *fhout, unsigned long long int macaddr) {
  static int c;
  static unsigned long long int oui;
  static unsigned long long int nic;
  static int swap;
  static int me;
  static char pskstring[64] = {};
  me = macaddr & 0xffffff;
  fprintf(fhout, "05%6d\n", me);
  oui = macaddr & 0xffffff000000L;
  nic = (macaddr - 0x0f) & 0xffffffL;
  for (c = 0; c < 0x10; c++)
    writebssid(fhout, oui + ((nic + c) & 0xffffffL));
  swap = (nic >> 8) & 0xffff;
  {
    swap = (swap & 0xf000) >> 12 | (swap & 0x0f00) >> 4 | (swap & 0x00f0) << 4 |
           (swap & 0x000f) << 12;
    snprintf(pskstring, 64, "000000%04X", swap);
    fprintf(fhout, "%s\n", pskstring);
  }
  test000559(fhout, macaddr);
  return;
}


x86 assembly (clang, -O0):
<preparebssid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
and    $0xffffff,%rax
mov    %eax,0x2f0c(%rip)
mov    -0x8(%rbp),%rdi
mov    0x2f02(%rip),%edx
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movabs $0xffffff000000,%rax
and    -0x10(%rbp),%rax
mov    %rax,0x2ecb(%rip)
mov    -0x10(%rbp),%rax
sub    $0xf,%rax
and    $0xffffff,%rax
mov    %rax,0x2ebe(%rip)
movl   $0x0,0x2ea4(%rip)
cmpl   $0x10,0x2e9d(%rip)
jge    11f7 <preparebssid+0xb7>
mov    -0x8(%rbp),%rdi
mov    0x2e94(%rip),%rsi
mov    0x2e95(%rip),%rax
movslq 0x2e7e(%rip),%rcx
add    %rcx,%rax
and    $0xffffff,%rax
add    %rax,%rsi
call   1030 <writebssid@plt>
mov    0x2e67(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e5e(%rip)
jmp    11ac <preparebssid+0x6c>
mov    0x2e62(%rip),%rax
shr    $0x8,%rax
and    $0xffff,%rax
mov    %eax,0x2e5a(%rip)
mov    0x2e54(%rip),%eax
and    $0xf000,%eax
sar    $0xc,%eax
mov    0x2e46(%rip),%ecx
and    $0xf00,%ecx
sar    $0x4,%ecx
or     %ecx,%eax
mov    0x2e35(%rip),%ecx
and    $0xf0,%ecx
shl    $0x4,%ecx
or     %ecx,%eax
mov    0x2e24(%rip),%ecx
and    $0xf,%ecx
shl    $0xc,%ecx
or     %ecx,%eax
mov    %eax,0x2e16(%rip)
mov    0x2e10(%rip),%ecx
lea    0x2e11(%rip),%rdi
mov    $0x40,%esi
lea    0xd9c(%rip),%rdx
call   1050 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xd97(%rip),%rsi
lea    0x2dee(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <test000559@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<preparebssid>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %r14d,%edx
and    $0xffffff,%edx
lea    0xea5(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
movabs $0xffffff000000,%rsi
and    %r14,%rsi
mov    %rsi,0x2ee2(%rip)
lea    0xfffff1(%r14),%eax
and    $0xffffff,%eax
mov    %rax,0x2ed7(%rip)
movl   $0x0,0x2ebd(%rip)
or     %rax,%rsi
mov    %rbx,%rdi
call   1030 <writebssid@plt>
mov    0x2eac(%rip),%eax
lea    0x1(%rax),%esi
mov    %esi,0x2ea3(%rip)
cmp    $0xe,%eax
jg     11ef <preparebssid+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    0x2e9a(%rip),%esi
and    $0xffffff,%esi
add    0x2e85(%rip),%rsi
mov    %rbx,%rdi
call   1030 <writebssid@plt>
mov    0x2e6f(%rip),%eax
lea    0x1(%rax),%esi
mov    %esi,0x2e66(%rip)
cmp    $0xf,%eax
jl     11c0 <preparebssid+0x80>
mov    0x2e6b(%rip),%ecx
mov    %ecx,%eax
shr    $0x14,%eax
and    $0xf,%eax
mov    %ecx,%edx
shr    $0xc,%edx
and    $0xf0,%edx
or     %eax,%edx
mov    %ecx,%eax
shr    $0x4,%eax
and    $0xf00,%eax
or     %edx,%eax
shl    $0x4,%ecx
and    $0xf000,%ecx
or     %eax,%ecx
lea    0x2e48(%rip),%r15
lea    0xdd8(%rip),%rdx
mov    %r15,%rdi
mov    $0x40,%esi
call   1050 <snprintf@plt>
lea    0xdcf(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <test000559@plt>

LLVM IR (-O0):
@preparebssid.c = internal global i32 0
@preparebssid.oui = internal global i64 0
@preparebssid.nic = internal global i64 0
@preparebssid.swap = internal global i32 0
@preparebssid.me = internal global i32 0
@preparebssid.pskstring = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"05%6d\0A\00"
@.str.1 = [11 x i8] c"000000%04X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @preparebssid(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = and i64 %5, 16777215
%7 = trunc i64 %6 to i32
store i32 %7, i32* @preparebssid.me
%8 = load i32*, i32** %3
%9 = load i32, i32* @preparebssid.me
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i64, i64* %4
%12 = and i64 %11, 281474959933440
store i64 %12, i64* @preparebssid.oui
%13 = load i64, i64* %4
%14 = sub i64 %13, 15
%15 = and i64 %14, 16777215
store i64 %15, i64* @preparebssid.nic
store i32 0, i32* @preparebssid.c
br label %16
16: ; preds = %29, %2
%17 = load i32, i32* @preparebssid.c
%18 = icmp slt i32 %17, 16
br i1 %18, label %19, label %32
19: ; preds = %16
%20 = load i32*, i32** %3
%21 = load i64, i64* @preparebssid.oui
%22 = load i64, i64* @preparebssid.nic
%23 = load i32, i32* @preparebssid.c
%24 = sext i32 %23 to i64
%25 = add i64 %22, %24
%26 = and i64 %25, 16777215
%27 = add i64 %21, %26
%28 = call i32 @writebssid(i32* %20, i64 %27)
br label %29
29: ; preds = %19
%30 = load i32, i32* @preparebssid.c
%31 = add nsw i32 %30, 1
store i32 %31, i32* @preparebssid.c
br label %16
32: ; preds = %16
%33 = load i64, i64* @preparebssid.nic
%34 = lshr i64 %33, 8
%35 = and i64 %34, 65535
%36 = trunc i64 %35 to i32
store i32 %36, i32* @preparebssid.swap
%37 = load i32, i32* @preparebssid.swap
%38 = and i32 %37, 61440
%39 = ashr i32 %38, 12
%40 = load i32, i32* @preparebssid.swap
%41 = and i32 %40, 3840
%42 = ashr i32 %41, 4
%43 = or i32 %39, %42
%44 = load i32, i32* @preparebssid.swap
%45 = and i32 %44, 240
%46 = shl i32 %45, 4
%47 = or i32 %43, %46
%48 = load i32, i32* @preparebssid.swap
%49 = and i32 %48, 15
%50 = shl i32 %49, 12
%51 = or i32 %47, %50
store i32 %51, i32* @preparebssid.swap
%52 = load i32, i32* @preparebssid.swap
%53 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @preparebssid.pskstring, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %52)
%54 = load i32*, i32** %3
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @preparebssid.pskstring, i64 0, i64 0))
%56 = load i32*, i32** %3
%57 = load i64, i64* %4
%58 = call i32 @test000559(i32* %56, i64 %57)
ret void
}

LLVM IR (-O2):
@preparebssid.c = internal unnamed_addr global i32 0
@preparebssid.oui = internal unnamed_addr global i64 0
@preparebssid.nic = internal unnamed_addr global i64 0
@preparebssid.pskstring = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"05%6d\0A\00"
@.str.1 = [11 x i8] c"000000%04X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @preparebssid(i32* %0, i64 %1) {
%3 = trunc i64 %1 to i32
%4 = and i32 %3, 16777215
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = and i64 %1, 281474959933440
store i64 %6, i64* @preparebssid.oui
%7 = add i64 %1, 16777201
%8 = and i64 %7, 16777215
store i64 %8, i64* @preparebssid.nic
store i32 0, i32* @preparebssid.c
%9 = or i64 %8, %6
%10 = tail call i32 @writebssid(i32* %0, i64 %9)
%11 = load i32, i32* @preparebssid.c
%12 = add nsw i32 %11, 1
store i32 %12, i32* @preparebssid.c
%13 = icmp slt i32 %11, 15
br i1 %13, label %14, label %26
14: ; preds = %2, %14
%15 = phi i32 [ %24, %14 ], [ %12, %2 ]
%16 = load i64, i64* @preparebssid.oui
%17 = load i64, i64* @preparebssid.nic
%18 = zext i32 %15 to i64
%19 = add i64 %17, %18
%20 = and i64 %19, 16777215
%21 = add i64 %20, %16
%22 = tail call i32 @writebssid(i32* %0, i64 %21)
%23 = load i32, i32* @preparebssid.c
%24 = add nsw i32 %23, 1
store i32 %24, i32* @preparebssid.c
%25 = icmp slt i32 %23, 15
br i1 %25, label %14, label %26
26: ; preds = %14, %2
%27 = load i64, i64* @preparebssid.nic
%28 = trunc i64 %27 to i32
%29 = lshr i32 %28, 8
%30 = lshr i32 %28, 20
%31 = and i32 %30, 15
%32 = lshr i32 %28, 12
%33 = and i32 %32, 240
%34 = or i32 %31, %33
%35 = shl nuw nsw i32 %29, 4
%36 = and i32 %35, 3840
%37 = or i32 %34, %36
%38 = shl i32 %29, 12
%39 = and i32 %38, 61440
%40 = or i32 %37, %39
%41 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @preparebssid.pskstring, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @preparebssid.pskstring, i64 0, i64 0))
%43 = tail call i32 @test000559(i32* %0, i64 %1)
ret void
}