#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*/ isdigit(int);
scalar_t__ memcmp(int *, char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int,
                            int, int);
int /*<<< orphan*/ writepsk(int /*<<< orphan*/ *, char *);
void testattwifi(FILE *fhout, uint8_t essidlen, uint8_t *essid) {
  static int k1, k2, k3, k4;
  static char *attwifi = "ATT-WIFI-";
  static char essidtmp[64] = {};
  if (essidlen != 13)
    return;
  if (memcmp(essid, attwifi, 9) != 0)
    return;
  if ((!isdigit(essid[9])) || (!isdigit(essid[10])) || (!isdigit(essid[11])) ||
      (!isdigit(essid[12])))
    return;
  for (k1 = 0; k1 < 10; k1++)
    for (k2 = 0; k2 < 10; k2++)
      for (k3 = 0; k3 < 10; k3++)
        for (k4 = 0; k4 < 10; k4++) {
          snprintf(essidtmp, 64, "%d%c%d%c%d%c%d%c", k1, essid[9], k2,
                   essid[10], k3, essid[12], k4, essid[11]);
          writepsk(fhout, essidtmp);
        }
  return;
}


x86 assembly (clang, -O0):
<testattwifi>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rdi,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
mov    %rdx,-0x28(%rbp)
cmpl   $0xd,-0x1c(%rbp)
je     1165 <testattwifi+0x25>
jmp    1319 <testattwifi+0x1d9>
mov    -0x28(%rbp),%rdi
mov    0x2ed0(%rip),%rsi
mov    $0x9,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1189 <testattwifi+0x49>
jmp    1319 <testattwifi+0x1d9>
mov    -0x28(%rbp),%rax
mov    0x24(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11dd <testattwifi+0x9d>
mov    -0x28(%rbp),%rax
mov    0x28(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11dd <testattwifi+0x9d>
mov    -0x28(%rbp),%rax
mov    0x2c(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11dd <testattwifi+0x9d>
mov    -0x28(%rbp),%rax
mov    0x30(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11e2 <testattwifi+0xa2>
jmp    1319 <testattwifi+0x1d9>
movl   $0x0,0x2e74(%rip)
cmpl   $0xa,0x2e6d(%rip)
jge    1314 <testattwifi+0x1d4>
movl   $0x0,0x2e61(%rip)
cmpl   $0xa,0x2e5a(%rip)
jge    12fb <testattwifi+0x1bb>
movl   $0x0,0x2e4e(%rip)
cmpl   $0xa,0x2e47(%rip)
jge    12e2 <testattwifi+0x1a2>
movl   $0x0,0x2e3b(%rip)
cmpl   $0xa,0x2e34(%rip)
jge    12c9 <testattwifi+0x189>
mov    0x2e1c(%rip),%ecx
mov    -0x28(%rbp),%rax
mov    0x24(%rax),%r8d
mov    0x2e11(%rip),%r9d
mov    -0x28(%rbp),%rax
mov    0x28(%rax),%r14d
mov    0x2e07(%rip),%ebx
mov    -0x28(%rbp),%rax
mov    0x30(%rax),%r11d
mov    0x2dfc(%rip),%r10d
mov    -0x28(%rbp),%rax
mov    0x2c(%rax),%eax
lea    0x2df2(%rip),%rdi
mov    $0x40,%esi
lea    0xd80(%rip),%rdx
mov    %r14d,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
mov    %r10d,0x18(%rsp)
mov    %eax,0x20(%rsp)
call   1040 <snprintf@plt>
mov    -0x18(%rbp),%rdi
lea    0x2dc0(%rip),%rsi
call   1050 <writepsk@plt>
mov    0x2db1(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2da8(%rip)
jmp    1231 <testattwifi+0xf1>
jmp    12ce <testattwifi+0x18e>
mov    0x2d94(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d8b(%rip)
jmp    121a <testattwifi+0xda>
jmp    12e7 <testattwifi+0x1a7>
mov    0x2d77(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d6e(%rip)
jmp    1203 <testattwifi+0xc3>
jmp    1300 <testattwifi+0x1c0>
mov    0x2d5a(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d51(%rip)
jmp    11ec <testattwifi+0xac>
jmp    1319 <testattwifi+0x1d9>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<testattwifi>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0xd,%esi
jne    1295 <testattwifi+0x165>
mov    %rdx,%r13
mov    %rdi,%r14
lea    0xeaf(%rip),%rsi
mov    %rdx,%rdi
mov    $0x9,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1295 <testattwifi+0x165>
mov    0x24(%r13),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1295 <testattwifi+0x165>
mov    0x28(%r13),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1295 <testattwifi+0x165>
mov    0x2c(%r13),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1295 <testattwifi+0x165>
mov    0x30(%r13),%eax
add    $0xffffffd0,%eax
cmp    $0x9,%eax
ja     1295 <testattwifi+0x165>
movl   $0x0,0x2e9f(%rip)
lea    0x2ea8(%rip),%r15
lea    0xe4b(%rip),%r12
nop
movl   $0x0,0x2e8a(%rip)
nopw   0x0(%rax,%rax,1)
movl   $0x0,0x2e7e(%rip)
xor    %eax,%eax
nopl   0x0(%rax)
movl   $0x0,0x2e72(%rip)
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x2e5a(%rip),%ecx
mov    0x2e57(%rip),%r9d
mov    0x24(%r13),%r8d
mov    0x28(%r13),%r10d
mov    0x30(%r13),%r11d
mov    0x2c(%r13),%ebp
sub    $0x8,%rsp
mov    %r15,%rdi
mov    $0x40,%esi
mov    %r12,%rdx
push   %rbp
push   %rbx
push   %r11
push   %rax
push   %r10
call   1030 <snprintf@plt>
add    $0x30,%rsp
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <writepsk@plt>
mov    0x2e1f(%rip),%ecx
lea    0x1(%rcx),%ebx
mov    %ebx,0x2e16(%rip)
mov    0x2e0c(%rip),%eax
cmp    $0x9,%ecx
jl     11f0 <testattwifi+0xc0>
lea    0x1(%rax),%ecx
mov    %ecx,0x2dfe(%rip)
cmp    $0x9,%eax
mov    %ecx,%eax
jl     11e0 <testattwifi+0xb0>
mov    0x2de9(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2de0(%rip)
cmp    $0x9,%eax
jl     11d0 <testattwifi+0xa0>
mov    0x2dcd(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2dc4(%rip)
cmp    $0x9,%eax
jl     11c0 <testattwifi+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@testattwifi.k1 = internal global i32 0
@testattwifi.k2 = internal global i32 0
@testattwifi.k3 = internal global i32 0
@testattwifi.k4 = internal global i32 0
@testattwifi.attwifi = internal global i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i32 0, i32 0)
@.str = [10 x i8] c"ATT-WIFI-\00"
@testattwifi.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [17 x i8] c"%d%c%d%c%d%c%d%c\00"
define void @testattwifi(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 ne i32 %7, 13
br i1 %8, label %9, label %10
9: ; preds = %3
br label %93
10: ; preds = %3
%11 = load i32*, i32** %6
%12 = load i8*, i8** @testattwifi.attwifi
%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 %93
16: ; preds = %10
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 9
%19 = load i32, i32* %18
%20 = call i32 @isdigit(i32 %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %40
22: ; preds = %16
%23 = load i32*, i32** %6
%24 = getelementptr inbounds i32, i32* %23, i64 10
%25 = load i32, i32* %24
%26 = call i32 @isdigit(i32 %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %40
28: ; preds = %22
%29 = load i32*, i32** %6
%30 = getelementptr inbounds i32, i32* %29, i64 11
%31 = load i32, i32* %30
%32 = call i32 @isdigit(i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load i32*, i32** %6
%36 = getelementptr inbounds i32, i32* %35, i64 12
%37 = load i32, i32* %36
%38 = call i32 @isdigit(i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %34, %28, %22, %16
br label %93
41: ; preds = %34
store i32 0, i32* @testattwifi.k1
br label %42
42: ; preds = %89, %41
%43 = load i32, i32* @testattwifi.k1
%44 = icmp slt i32 %43, 10
br i1 %44, label %45, label %92
45: ; preds = %42
store i32 0, i32* @testattwifi.k2
br label %46
46: ; preds = %85, %45
%47 = load i32, i32* @testattwifi.k2
%48 = icmp slt i32 %47, 10
br i1 %48, label %49, label %88
49: ; preds = %46
store i32 0, i32* @testattwifi.k3
br label %50
50: ; preds = %81, %49
%51 = load i32, i32* @testattwifi.k3
%52 = icmp slt i32 %51, 10
br i1 %52, label %53, label %84
53: ; preds = %50
store i32 0, i32* @testattwifi.k4
br label %54
54: ; preds = %77, %53
%55 = load i32, i32* @testattwifi.k4
%56 = icmp slt i32 %55, 10
br i1 %56, label %57, label %80
57: ; preds = %54
%58 = load i32, i32* @testattwifi.k1
%59 = load i32*, i32** %6
%60 = getelementptr inbounds i32, i32* %59, i64 9
%61 = load i32, i32* %60
%62 = load i32, i32* @testattwifi.k2
%63 = load i32*, i32** %6
%64 = getelementptr inbounds i32, i32* %63, i64 10
%65 = load i32, i32* %64
%66 = load i32, i32* @testattwifi.k3
%67 = load i32*, i32** %6
%68 = getelementptr inbounds i32, i32* %67, i64 12
%69 = load i32, i32* %68
%70 = load i32, i32* @testattwifi.k4
%71 = load i32*, i32** %6
%72 = getelementptr inbounds i32, i32* %71, i64 11
%73 = load i32, i32* %72
%74 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testattwifi.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %58, i32 %61, i32 %62, i32 %65, i32 %66, i32 %69, i32 %70, i32 %73)
%75 = load i32*, i32** %4
%76 = call i32 @writepsk(i32* %75, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testattwifi.essidtmp, i64 0, i64 0))
br label %77
77: ; preds = %57
%78 = load i32, i32* @testattwifi.k4
%79 = add nsw i32 %78, 1
store i32 %79, i32* @testattwifi.k4
br label %54
80: ; preds = %54
br label %81
81: ; preds = %80
%82 = load i32, i32* @testattwifi.k3
%83 = add nsw i32 %82, 1
store i32 %83, i32* @testattwifi.k3
br label %50
84: ; preds = %50
br label %85
85: ; preds = %84
%86 = load i32, i32* @testattwifi.k2
%87 = add nsw i32 %86, 1
store i32 %87, i32* @testattwifi.k2
br label %46
88: ; preds = %46
br label %89
89: ; preds = %88
%90 = load i32, i32* @testattwifi.k1
%91 = add nsw i32 %90, 1
store i32 %91, i32* @testattwifi.k1
br label %42
92: ; preds = %42
br label %93
93: ; preds = %92, %40, %15, %9
ret void
}

LLVM IR (-O2):
@testattwifi.k1 = internal unnamed_addr global i32 0
@testattwifi.k2 = internal unnamed_addr global i32 0
@testattwifi.k3 = internal unnamed_addr global i32 0
@testattwifi.k4 = internal unnamed_addr global i32 0
@.str = [10 x i8] c"ATT-WIFI-\00"
@testattwifi.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [17 x i8] c"%d%c%d%c%d%c%d%c\00"
define void @testattwifi(i32* %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, 13
br i1 %4, label %5, label %59
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 %59
8: ; preds = %5
%9 = getelementptr inbounds i32, i32* %2, i64 9
%10 = load i32, i32* %9
%11 = add i32 %10, -48
%12 = icmp ult i32 %11, 10
br i1 %12, label %13, label %59
13: ; preds = %8
%14 = getelementptr inbounds i32, i32* %2, i64 10
%15 = load i32, i32* %14
%16 = add i32 %15, -48
%17 = icmp ult i32 %16, 10
br i1 %17, label %18, label %59
18: ; preds = %13
%19 = getelementptr inbounds i32, i32* %2, i64 11
%20 = load i32, i32* %19
%21 = add i32 %20, -48
%22 = icmp ult i32 %21, 10
br i1 %22, label %23, label %59
23: ; preds = %18
%24 = getelementptr inbounds i32, i32* %2, i64 12
%25 = load i32, i32* %24
%26 = add i32 %25, -48
%27 = icmp ult i32 %26, 10
br i1 %27, label %28, label %59
28: ; preds = %23
store i32 0, i32* @testattwifi.k1
br label %29
29: ; preds = %28, %55
store i32 0, i32* @testattwifi.k2
br label %30
30: ; preds = %29, %51
store i32 0, i32* @testattwifi.k3
br label %31
31: ; preds = %30, %48
%32 = phi i32 [ 0, %30 ], [ %49, %48 ]
store i32 0, i32* @testattwifi.k4
br label %33
33: ; preds = %33, %31
%34 = phi i32 [ %32, %31 ], [ %47, %33 ]
%35 = phi i32 [ 0, %31 ], [ %45, %33 ]
%36 = load i32, i32* @testattwifi.k1
%37 = load i32, i32* %9
%38 = load i32, i32* @testattwifi.k2
%39 = load i32, i32* %14
%40 = load i32, i32* %24
%41 = load i32, i32* %19
%42 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testattwifi.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37, i32 %38, i32 %39, i32 %34, i32 %40, i32 %35, i32 %41)
%43 = tail call i32 @writepsk(i32* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testattwifi.essidtmp, i64 0, i64 0))
%44 = load i32, i32* @testattwifi.k4
%45 = add nsw i32 %44, 1
store i32 %45, i32* @testattwifi.k4
%46 = icmp slt i32 %44, 9
%47 = load i32, i32* @testattwifi.k3
br i1 %46, label %33, label %48
48: ; preds = %33
%49 = add nsw i32 %47, 1
store i32 %49, i32* @testattwifi.k3
%50 = icmp slt i32 %47, 9
br i1 %50, label %31, label %51
51: ; preds = %48
%52 = load i32, i32* @testattwifi.k2
%53 = add nsw i32 %52, 1
store i32 %53, i32* @testattwifi.k2
%54 = icmp slt i32 %52, 9
br i1 %54, label %30, label %55
55: ; preds = %51
%56 = load i32, i32* @testattwifi.k1
%57 = add nsw i32 %56, 1
store i32 %57, i32* @testattwifi.k1
%58 = icmp slt i32 %56, 9
br i1 %58, label %29, label %59
59: ; preds = %55, %8, %13, %18, %23, %5, %3
ret void
}