#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 */
scalar_t__ memcmp(int *, char const *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ writepsk(int /*<<< orphan*/ *, char *);
void testmywifi(FILE *fhout, uint8_t essidlen, uint8_t *essid) {
  static int k1;
  static const char *mywifi = "MY WIFI ";
  static char essidtmp[64] = {};
  if (essidlen != 12)
    return;
  if (memcmp(essid, mywifi, 8) != 0)
    return;
  for (k1 = 0; k1 < 10000; k1++) {
    snprintf(essidtmp, 64, "MYWIFI%04d", k1);
    writepsk(fhout, essidtmp);
  }
  return;
}


x86 assembly (clang, -O0):
<testmywifi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0xc,-0xc(%rbp)
je     1152 <testmywifi+0x22>
jmp    11d7 <testmywifi+0xa7>
mov    -0x18(%rbp),%rdi
mov    0x2edb(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     1176 <testmywifi+0x46>
jmp    11d7 <testmywifi+0xa7>
movl   $0x0,0x2ed0(%rip)
cmpl   $0x2710,0x2ec6(%rip)
jge    11d2 <testmywifi+0xa2>
mov    0x2eba(%rip),%ecx
lea    0x2ec3(%rip),%rdi
mov    $0x40,%esi
lea    0xe60(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0x2ea7(%rip),%rsi
call   1040 <writepsk@plt>
mov    0x2e8c(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e83(%rip)
jmp    1180 <testmywifi+0x50>
jmp    11d7 <testmywifi+0xa7>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testmywifi>:
push   %r15
push   %r14
push   %rbx
cmp    $0xc,%esi
jne    11a1 <testmywifi+0x71>
mov    %rdi,%r14
lea    0xebc(%rip),%rsi
mov    %rdx,%rdi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11a1 <testmywifi+0x71>
movl   $0x0,0x2ef0(%rip)
xor    %ecx,%ecx
lea    0x2ef7(%rip),%rbx
lea    0xe99(%rip),%r15
mov    %rbx,%rdi
mov    $0x40,%esi
mov    %r15,%rdx
call   1030 <snprintf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <writepsk@plt>
mov    0x2ebf(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2eb6(%rip)
cmp    $0x270f,%eax
jl     1170 <testmywifi+0x40>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@testmywifi.k1 = internal global i32 0
@testmywifi.mywifi = internal global i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0)
@.str = [9 x i8] c"MY WIFI \00"
@testmywifi.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [11 x i8] c"MYWIFI%04d\00"
define void @testmywifi(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, 12
br i1 %8, label %9, label %10
9: ; preds = %3
br label %29
10: ; preds = %3
%11 = load i32*, i32** %6
%12 = load i8*, i8** @testmywifi.mywifi
%13 = call i64 @memcmp(i32* %11, i8* %12, i32 8)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %29
16: ; preds = %10
store i32 0, i32* @testmywifi.k1
br label %17
17: ; preds = %25, %16
%18 = load i32, i32* @testmywifi.k1
%19 = icmp slt i32 %18, 10000
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32, i32* @testmywifi.k1
%22 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testmywifi.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32*, i32** %4
%24 = call i32 @writepsk(i32* %23, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testmywifi.essidtmp, i64 0, i64 0))
br label %25
25: ; preds = %20
%26 = load i32, i32* @testmywifi.k1
%27 = add nsw i32 %26, 1
store i32 %27, i32* @testmywifi.k1
br label %17
28: ; preds = %17
br label %29
29: ; preds = %28, %15, %9
ret void
}

LLVM IR (-O2):
@testmywifi.k1 = internal unnamed_addr global i32 0
@.str = [9 x i8] c"MY WIFI \00"
@testmywifi.essidtmp = internal global [64 x i8] zeroinitializer
@.str.1 = [11 x i8] c"MYWIFI%04d\00"
define void @testmywifi(i32* %0, i32 %1, i32* %2) {
%4 = icmp eq i32 %1, 12
br i1 %4, label %5, label %16
5: ; preds = %3
%6 = tail call i64 @memcmp(i32* %2, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %16
8: ; preds = %5
store i32 0, i32* @testmywifi.k1
br label %9
9: ; preds = %8, %9
%10 = phi i32 [ 0, %8 ], [ %14, %9 ]
%11 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testmywifi.essidtmp, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = tail call i32 @writepsk(i32* %0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @testmywifi.essidtmp, i64 0, i64 0))
%13 = load i32, i32* @testmywifi.k1
%14 = add nsw i32 %13, 1
store i32 %14, i32* @testmywifi.k1
%15 = icmp slt i32 %13, 9999
br i1 %15, label %9, label %16
16: ; preds = %9, %5, %3
ret void
}