#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 uint8_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int);
int /*<<< orphan*/ isxdigit(int);
scalar_t__ memcmp(int *, char *, int);
void testcg3000dv2(FILE *fhout, uint8_t essidlen, uint8_t *essid) {
  static int k1;
  static char *cg3000dv2 = "CG3000DV2";
  if (essidlen < 11)
    return;
  if (memcmp(essid, cg3000dv2, 9) != 0)
    return;
  if ((!isxdigit(essid[9])) || (!isxdigit(essid[10])))
    return;
  for (k1 = 0; k1 < 0x10000; k1++)
    fprintf(fhout, "CG3000DV2%04X%c%c\n", k1, essid[9], essid[10]);
  return;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0xb,-0xc(%rbp)
jge    1152 <testcg3000dv2+0x22>
jmp    11fd <testcg3000dv2+0xcd>
mov    -0x18(%rbp),%rdi
mov    0x2edb(%rip),%rsi
mov    $0x9,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     1176 <testcg3000dv2+0x46>
jmp    11fd <testcg3000dv2+0xcd>
mov    -0x18(%rbp),%rax
mov    0x24(%rax),%edi
call   1050 <isxdigit@plt>
cmp    $0x0,%eax
je     11a0 <testcg3000dv2+0x70>
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%edi
call   1050 <isxdigit@plt>
cmp    $0x0,%eax
jne    11a5 <testcg3000dv2+0x75>
jmp    11fd <testcg3000dv2+0xcd>
movl   $0x0,0x2e95(%rip)
cmpl   $0x10000,0x2e8b(%rip)
jge    11f8 <testcg3000dv2+0xc8>
mov    -0x8(%rbp),%rdi
mov    0x2e7b(%rip),%edx
mov    -0x18(%rbp),%rax
mov    0x24(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%r8d
lea    0xe2b(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e5a(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e51(%rip)
jmp    11af <testcg3000dv2+0x7f>
jmp    11fd <testcg3000dv2+0xcd>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0xb,%esi
jl     115b <testcg3000dv2+0x2b>
mov    %rdx,%rbx
mov    %rdi,%r14
lea    0xeb7(%rip),%rsi
mov    %rdx,%rdi
mov    $0x9,%edx
call   1030 <memcmp@plt>
test   %rax,%rax
je     1166 <testcg3000dv2+0x36>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x24(%rbx),%ebp
mov    %ebp,%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     115b <testcg3000dv2+0x2b>
mov    0x28(%rbx),%r15d
mov    %r15d,%edi
call   1050 <isxdigit@plt>
test   %eax,%eax
je     115b <testcg3000dv2+0x2b>
movl   $0x0,0x2eae(%rip)
lea    0xe75(%rip),%rsi
mov    %r14,%rdi
xor    %edx,%edx
mov    %ebp,%ecx
mov    %r15d,%r8d
call   1040 <fprintf@plt>
mov    0x2e92(%rip),%eax
lea    0x1(%rax),%edx
mov    %edx,0x2e89(%rip)
cmp    $0xfffe,%eax
jg     115b <testcg3000dv2+0x2b>
lea    0xe49(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x24(%rbx),%ecx
mov    0x28(%rbx),%r8d
mov    %r14,%rdi
mov    %rbp,%rsi
call   1040 <fprintf@plt>
mov    0x2e54(%rip),%eax
lea    0x1(%rax),%edx
mov    %edx,0x2e4b(%rip)
cmp    $0xffff,%eax
jl     11d0 <testcg3000dv2+0xa0>
jmp    115b <testcg3000dv2+0x2b>

LLVM IR (-O0):
@testcg3000dv2.k1 = internal global i32 0
@testcg3000dv2.cg3000dv2 = internal global i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0)
@.str = [10 x i8] c"CG3000DV2\00"
@.str.1 = [19 x i8] c"CG3000DV2%04X%c%c\0A\00"
define void @testcg3000dv2(i32* %0, i32 %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 11
br i1 %8, label %9, label %10
9: ; preds = %3
br label %47
10: ; preds = %3
%11 = load i32*, i32** %6
%12 = load i8*, i8** @testcg3000dv2.cg3000dv2
%13 = call i64 @memcmp(i32* %11, i8* %12, i32 9)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %47
16: ; preds = %10
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 9
%19 = load i32, i32* %18
%20 = call i32 @isxdigit(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i32*, i32** %6
%24 = getelementptr inbounds i32, i32* %23, i64 10
%25 = load i32, i32* %24
%26 = call i32 @isxdigit(i32 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %22, %16
br label %47
29: ; preds = %22
store i32 0, i32* @testcg3000dv2.k1
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* @testcg3000dv2.k1
%32 = icmp slt i32 %31, 65536
br i1 %32, label %33, label %46
33: ; preds = %30
%34 = load i32*, i32** %4
%35 = load i32, i32* @testcg3000dv2.k1
%36 = load i32*, i32** %6
%37 = getelementptr inbounds i32, i32* %36, i64 9
%38 = load i32, i32* %37
%39 = load i32*, i32** %6
%40 = getelementptr inbounds i32, i32* %39, i64 10
%41 = load i32, i32* %40
%42 = call i32 @fprintf(i32* %34, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %38, i32 %41)
br label %43
43: ; preds = %33
%44 = load i32, i32* @testcg3000dv2.k1
%45 = add nsw i32 %44, 1
store i32 %45, i32* @testcg3000dv2.k1
br label %30
46: ; preds = %30
br label %47
47: ; preds = %46, %28, %15, %9
ret void
}

LLVM IR (-O2):
@testcg3000dv2.k1 = internal unnamed_addr global i32 0
@.str = [10 x i8] c"CG3000DV2\00"
@.str.1 = [19 x i8] c"CG3000DV2%04X%c%c\0A\00"
define void @testcg3000dv2(i32* nocapture %0, i32 %1, i32* %2) {
%4 = icmp slt i32 %1, 11
br i1 %4, label %31, label %5
5: ; preds = %3
%6 = tail call i64 @memcmp(i32* %2, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %31
8: ; preds = %5
%9 = getelementptr inbounds i32, i32* %2, i64 9
%10 = load i32, i32* %9
%11 = tail call i32 @isxdigit(i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %31, label %13
13: ; preds = %8
%14 = getelementptr inbounds i32, i32* %2, i64 10
%15 = load i32, i32* %14
%16 = tail call i32 @isxdigit(i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %31, label %18
18: ; preds = %13
store i32 0, i32* @testcg3000dv2.k1
%19 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 %10, i32 %15)
%20 = load i32, i32* @testcg3000dv2.k1
%21 = add nsw i32 %20, 1
store i32 %21, i32* @testcg3000dv2.k1
%22 = icmp slt i32 %20, 65535
br i1 %22, label %23, label %31
23: ; preds = %18, %23
%24 = phi i32 [ %29, %23 ], [ %21, %18 ]
%25 = load i32, i32* %9
%26 = load i32, i32* %14
%27 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* @testcg3000dv2.k1
%29 = add nsw i32 %28, 1
store i32 %29, i32* @testcg3000dv2.k1
%30 = icmp slt i32 %28, 65535
br i1 %30, label %23, label %31
31: ; preds = %23, %18, %8, %13, %5, %3
ret void
}