#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 /*<<< orphan*/ writepsk(int /*<<< orphan*/ *, char *);
void testalcatellinkzone(FILE *fhout, uint8_t essidlen, uint8_t *essid) {
  static int k1;
  static char *ali = "Alcatel LINKZONE ";
  static char essidtmp[64] = {};
  if (essidlen != 21)
    return;
  if (memcmp(essid, ali, 17) != 0)
    return;
  if ((!isdigit(essid[17])) || (!isdigit(essid[18])) || (!isdigit(essid[19])) ||
      (!isdigit(essid[20])))
    return;
  for (k1 = 0; k1 < 10000; k1++) {
    snprintf(essidtmp, 64, "%04d%c%c%c%c", k1, essid[17], essid[18], essid[19],
             essid[20]);
    writepsk(fhout, essidtmp);
  }
  return;
}


x86 assembly (clang, -O0):
<testalcatellinkzone>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x15,-0xc(%rbp)
je     1162 <testalcatellinkzone+0x22>
jmp    1267 <testalcatellinkzone+0x127>
mov    -0x18(%rbp),%rdi
mov    0x2ed3(%rip),%rsi
mov    $0x11,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1186 <testalcatellinkzone+0x46>
jmp    1267 <testalcatellinkzone+0x127>
mov    -0x18(%rbp),%rax
mov    0x44(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11da <testalcatellinkzone+0x9a>
mov    -0x18(%rbp),%rax
mov    0x48(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11da <testalcatellinkzone+0x9a>
mov    -0x18(%rbp),%rax
mov    0x4c(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
je     11da <testalcatellinkzone+0x9a>
mov    -0x18(%rbp),%rax
mov    0x50(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11df <testalcatellinkzone+0x9f>
jmp    1267 <testalcatellinkzone+0x127>
movl   $0x0,0x2e77(%rip)
cmpl   $0x2710,0x2e6d(%rip)
jge    1262 <testalcatellinkzone+0x122>
mov    0x2e61(%rip),%ecx
mov    -0x18(%rbp),%rax
mov    0x44(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    0x48(%rax),%r9d
mov    -0x18(%rbp),%rax
mov    0x4c(%rax),%r10d
mov    -0x18(%rbp),%rax
mov    0x50(%rax),%eax
lea    0x2e4b(%rip),%rdi
mov    $0x40,%esi
lea    0xde1(%rip),%rdx
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0x2e27(%rip),%rsi
call   1050 <writepsk@plt>
mov    0x2e0c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e03(%rip)
jmp    11e9 <testalcatellinkzone+0xa9>
jmp    1267 <testalcatellinkzone+0x127>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testalcatellinkzone>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmp    $0x15,%esi
jne    1209 <testalcatellinkzone+0xd9>
mov    %rdx,%rbx
mov    %rdi,%r14
lea    0xeb2(%rip),%rsi
mov    %rdx,%rdi
mov    $0x11,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    1209 <testalcatellinkzone+0xd9>
mov    0x44(%rbx),%r8d
lea    -0x30(%r8),%eax
cmp    $0x9,%eax
ja     1209 <testalcatellinkzone+0xd9>
mov    0x48(%rbx),%r9d
lea    -0x30(%r9),%eax
cmp    $0x9,%eax
ja     1209 <testalcatellinkzone+0xd9>
mov    0x4c(%rbx),%r10d
lea    -0x30(%r10),%eax
cmp    $0x9,%eax
ja     1209 <testalcatellinkzone+0xd9>
mov    0x50(%rbx),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%ecx
ja     1209 <testalcatellinkzone+0xd9>
movl   $0x0,0x2ea8(%rip)
xor    %ecx,%ecx
lea    0x2eaf(%rip),%r15
lea    0xe5a(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x40,%esi
mov    %r12,%rdx
push   %rax
push   %r10
call   1030 <snprintf@plt>
add    $0x10,%rsp
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <writepsk@plt>
mov    0x2e68(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2e5f(%rip)
cmp    $0x270e,%eax
jg     1209 <testalcatellinkzone+0xd9>
mov    0x44(%rbx),%r8d
mov    0x48(%rbx),%r9d
mov    0x4c(%rbx),%r10d
mov    0x50(%rbx),%eax
jmp    11c0 <testalcatellinkzone+0x90>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@testalcatellinkzone.k1 = internal global i32 0
@testalcatellinkzone.ali = internal global i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i32 0, i32 0)
@.str = [18 x i8] c"Alcatel LINKZONE \00"
@testalcatellinkzone.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [13 x i8] c"%04d%c%c%c%c\00"
define void @testalcatellinkzone(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, 21
br i1 %8, label %9, label %10
9: ; preds = %3
br label %66
10: ; preds = %3
%11 = load i32*, i32** %6
%12 = load i8*, i8** @testalcatellinkzone.ali
%13 = call i64 @memcmp(i32* %11, i8* %12, i32 17)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %66
16: ; preds = %10
%17 = load i32*, i32** %6
%18 = getelementptr inbounds i32, i32* %17, i64 17
%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 18
%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 19
%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 20
%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 %66
41: ; preds = %34
store i32 0, i32* @testalcatellinkzone.k1
br label %42
42: ; preds = %62, %41
%43 = load i32, i32* @testalcatellinkzone.k1
%44 = icmp slt i32 %43, 10000
br i1 %44, label %45, label %65
45: ; preds = %42
%46 = load i32, i32* @testalcatellinkzone.k1
%47 = load i32*, i32** %6
%48 = getelementptr inbounds i32, i32* %47, i64 17
%49 = load i32, i32* %48
%50 = load i32*, i32** %6
%51 = getelementptr inbounds i32, i32* %50, i64 18
%52 = load i32, i32* %51
%53 = load i32*, i32** %6
%54 = getelementptr inbounds i32, i32* %53, i64 19
%55 = load i32, i32* %54
%56 = load i32*, i32** %6
%57 = getelementptr inbounds i32, i32* %56, i64 20
%58 = load i32, i32* %57
%59 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testalcatellinkzone.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %46, i32 %49, i32 %52, i32 %55, i32 %58)
%60 = load i32*, i32** %4
%61 = call i32 @writepsk(i32* %60, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testalcatellinkzone.essidtmp, i64 0, i64 0))
br label %62
62: ; preds = %45
%63 = load i32, i32* @testalcatellinkzone.k1
%64 = add nsw i32 %63, 1
store i32 %64, i32* @testalcatellinkzone.k1
br label %42
65: ; preds = %42
br label %66
66: ; preds = %65, %40, %15, %9
ret void
}

LLVM IR (-O2):
@testalcatellinkzone.k1 = internal unnamed_addr global i32 0
@.str = [18 x i8] c"Alcatel LINKZONE \00"
@testalcatellinkzone.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [13 x i8] c"%04d%c%c%c%c\00"
define void @testalcatellinkzone(i32* %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, 21
br i1 %4, label %5, label %45
5: ; preds = %3
%6 = tail call i64 @memcmp(i32* %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 17)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %45
8: ; preds = %5
%9 = getelementptr inbounds i32, i32* %2, i64 17
%10 = load i32, i32* %9
%11 = add i32 %10, -48
%12 = icmp ult i32 %11, 10
br i1 %12, label %13, label %45
13: ; preds = %8
%14 = getelementptr inbounds i32, i32* %2, i64 18
%15 = load i32, i32* %14
%16 = add i32 %15, -48
%17 = icmp ult i32 %16, 10
br i1 %17, label %18, label %45
18: ; preds = %13
%19 = getelementptr inbounds i32, i32* %2, i64 19
%20 = load i32, i32* %19
%21 = add i32 %20, -48
%22 = icmp ult i32 %21, 10
br i1 %22, label %23, label %45
23: ; preds = %18
%24 = getelementptr inbounds i32, i32* %2, i64 20
%25 = load i32, i32* %24
%26 = add i32 %25, -48
%27 = icmp ult i32 %26, 10
br i1 %27, label %28, label %45
28: ; preds = %23
store i32 0, i32* @testalcatellinkzone.k1
br label %29
29: ; preds = %40, %28
%30 = phi i32 [ %25, %28 ], [ %44, %40 ]
%31 = phi i32 [ %20, %28 ], [ %43, %40 ]
%32 = phi i32 [ %15, %28 ], [ %42, %40 ]
%33 = phi i32 [ %10, %28 ], [ %41, %40 ]
%34 = phi i32 [ 0, %28 ], [ %38, %40 ]
%35 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testalcatellinkzone.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %34, i32 %33, i32 %32, i32 %31, i32 %30)
%36 = tail call i32 @writepsk(i32* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testalcatellinkzone.essidtmp, i64 0, i64 0))
%37 = load i32, i32* @testalcatellinkzone.k1
%38 = add nsw i32 %37, 1
store i32 %38, i32* @testalcatellinkzone.k1
%39 = icmp slt i32 %37, 9999
br i1 %39, label %40, label %45
40: ; preds = %29
%41 = load i32, i32* %9
%42 = load i32, i32* %14
%43 = load i32, i32* %19
%44 = load i32, i32* %24
br label %29
45: ; preds = %29, %8, %13, %18, %23, %5, %3
ret void
}