#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*/ memcpy(int **, int *, int);
int /*<<< orphan*/ memset(int **, int /*<<< orphan*/, int);
int /*<<< orphan*/ writeessidremoved(int /*<<< orphan*/ *, int, int *);
void writeessidsweeped(FILE *fhout, uint8_t essidlen, uint8_t *essid) {
  static int l1, l2;
  static uint8_t sweepstring[64] = {};
  for (l1 = 2; l1 <= essidlen; l1++) {
    for (l2 = 0; l2 <= essidlen - l1; l2++) {
      memset(&sweepstring, 0, 64);
      memcpy(&sweepstring, &essid[l2], l1);
      writeessidremoved(fhout, l1, sweepstring);
    }
  }
  return;
}


x86 assembly (clang, -O0):
<writeessidsweeped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x2,0x2f03(%rip)
mov    0x2efd(%rip),%eax
cmp    -0xc(%rbp),%eax
jg     11f7 <writeessidsweeped+0xc7>
movl   $0x0,0x2eee(%rip)
mov    0x2ee8(%rip),%eax
mov    -0xc(%rbp),%ecx
sub    0x2edb(%rip),%ecx
cmp    %ecx,%eax
jg     11de <writeessidsweeped+0xae>
lea    0x2edc(%rip),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
mov    -0x18(%rbp),%rsi
movslq 0x2eb9(%rip),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    0x2ea8(%rip),%edx
lea    0x2eb1(%rip),%rdi
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e92(%rip),%esi
lea    0x2e9b(%rip),%rdx
call   1030 <writeessidremoved@plt>
mov    0x2e84(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e7b(%rip)
jmp    1166 <writeessidsweeped+0x36>
jmp    11e3 <writeessidsweeped+0xb3>
mov    0x2e67(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2e5e(%rip)
jmp    114d <writeessidsweeped+0x1d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeessidsweeped>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movl   $0x2,0x2f0f(%rip)
cmp    $0x2,%esi
jge    1151 <writeessidsweeped+0x21>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x2,%eax
lea    0x2efb(%rip),%rbx
jmp    117f <writeessidsweeped+0x4f>
nopw   0x0(%rax,%rax,1)
lea    0x1(%rax),%ecx
mov    %ecx,0x2ed7(%rip)
cmp    %ebp,%eax
mov    %ecx,%eax
jge    1146 <writeessidsweeped+0x16>
movl   $0x0,0x2ecb(%rip)
cmp    %ebp,%eax
jg     1170 <writeessidsweeped+0x40>
nopl   (%rax)
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1040 <memset@plt>
movslq 0x2eae(%rip),%rax
lea    (%r14,%rax,4),%rsi
mov    0x2ea0(%rip),%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    0x2e92(%rip),%esi
mov    %r15,%rdi
mov    %rbx,%rdx
call   1030 <writeessidremoved@plt>
mov    0x2e85(%rip),%ecx
lea    0x1(%rcx),%eax
mov    %eax,0x2e7c(%rip)
mov    0x2e72(%rip),%eax
mov    %ebp,%edx
sub    %eax,%edx
cmp    %edx,%ecx
jl     1190 <writeessidsweeped+0x60>
jmp    1170 <writeessidsweeped+0x40>

LLVM IR (-O0):
@writeessidsweeped.l1 = internal global i32 0
@writeessidsweeped.l2 = internal global i32 0
@writeessidsweeped.sweepstring = internal global [64 x i32] zeroinitializer
define void @writeessidsweeped(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
store i32 2, i32* @writeessidsweeped.l1
br label %7
7: ; preds = %33, %3
%8 = load i32, i32* @writeessidsweeped.l1
%9 = load i32, i32* %5
%10 = icmp sle i32 %8, %9
br i1 %10, label %11, label %36
11: ; preds = %7
store i32 0, i32* @writeessidsweeped.l2
br label %12
12: ; preds = %29, %11
%13 = load i32, i32* @writeessidsweeped.l2
%14 = load i32, i32* %5
%15 = load i32, i32* @writeessidsweeped.l1
%16 = sub nsw i32 %14, %15
%17 = icmp sle i32 %13, %16
br i1 %17, label %18, label %32
18: ; preds = %12
%19 = call i32 @memset(i32** bitcast ([64 x i32]* @writeessidsweeped.sweepstring to i32**), i32 0, i32 64)
%20 = load i32*, i32** %6
%21 = load i32, i32* @writeessidsweeped.l2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = load i32, i32* @writeessidsweeped.l1
%25 = call i32 @memcpy(i32** bitcast ([64 x i32]* @writeessidsweeped.sweepstring to i32**), i32* %23, i32 %24)
%26 = load i32*, i32** %4
%27 = load i32, i32* @writeessidsweeped.l1
%28 = call i32 @writeessidremoved(i32* %26, i32 %27, i32* getelementptr inbounds ([64 x i32], [64 x i32]* @writeessidsweeped.sweepstring, i64 0, i64 0))
br label %29
29: ; preds = %18
%30 = load i32, i32* @writeessidsweeped.l2
%31 = add nsw i32 %30, 1
store i32 %31, i32* @writeessidsweeped.l2
br label %12
32: ; preds = %12
br label %33
33: ; preds = %32
%34 = load i32, i32* @writeessidsweeped.l1
%35 = add nsw i32 %34, 1
store i32 %35, i32* @writeessidsweeped.l1
br label %7
36: ; preds = %7
ret void
}

LLVM IR (-O2):
@writeessidsweeped.l1 = internal unnamed_addr global i32 0
@writeessidsweeped.l2 = internal unnamed_addr global i32 0
@writeessidsweeped.sweepstring = internal global [64 x i32] zeroinitializer
define void @writeessidsweeped(i32* %0, i32 %1, i32* %2) {
store i32 2, i32* @writeessidsweeped.l1
%4 = icmp slt i32 %1, 2
br i1 %4, label %26, label %5
5: ; preds = %3, %22
%6 = phi i32 [ %24, %22 ], [ 2, %3 ]
store i32 0, i32* @writeessidsweeped.l2
%7 = icmp sgt i32 %6, %1
br i1 %7, label %22, label %8
8: ; preds = %5, %8
%9 = tail call i32 @memset(i32** bitcast ([64 x i32]* @writeessidsweeped.sweepstring to i32**), i32 0, i32 64)
%10 = load i32, i32* @writeessidsweeped.l2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %2, i64 %11
%13 = load i32, i32* @writeessidsweeped.l1
%14 = tail call i32 @memcpy(i32** bitcast ([64 x i32]* @writeessidsweeped.sweepstring to i32**), i32* %12, i32 %13)
%15 = load i32, i32* @writeessidsweeped.l1
%16 = tail call i32 @writeessidremoved(i32* %0, i32 %15, i32* getelementptr inbounds ([64 x i32], [64 x i32]* @writeessidsweeped.sweepstring, i64 0, i64 0))
%17 = load i32, i32* @writeessidsweeped.l2
%18 = add nsw i32 %17, 1
store i32 %18, i32* @writeessidsweeped.l2
%19 = load i32, i32* @writeessidsweeped.l1
%20 = sub nsw i32 %1, %19
%21 = icmp slt i32 %17, %20
br i1 %21, label %8, label %22
22: ; preds = %8, %5
%23 = phi i32 [ %6, %5 ], [ %19, %8 ]
%24 = add nsw i32 %23, 1
store i32 %24, i32* @writeessidsweeped.l1
%25 = icmp slt i32 %23, %1
br i1 %25, label %5, label %26
26: ; preds = %22, %3
ret void
}