#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 /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int isasciistring(int, unsigned char *);
void fwriteessidstrnoret(uint8_t len, unsigned char *essidstr, FILE *fhd) {
  int p;
  if (isasciistring(len, essidstr) != false) {
    fwrite(essidstr, len, 1, fhd);
    fprintf(fhd, ":");
  } else {
    fprintf(fhd, "$HEX[");
    for (p = 0; p < len; p++) {
      fprintf(fhd, "%02x", essidstr[p]);
    }
    fprintf(fhd, "]:");
  }
  return;
}


x86 assembly (clang, -O0):
<fwriteessidstrnoret>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <isasciistring@plt>
cmp    $0x0,%eax
je     1184 <fwriteessidstrnoret+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x18(%rbp),%rcx
mov    $0x1,%edx
call   1050 <fwrite@plt>
mov    -0x18(%rbp),%rdi
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    11e7 <fwriteessidstrnoret+0xb7>
mov    -0x18(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d5 <fwriteessidstrnoret+0xa5>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119d <fwriteessidstrnoret+0x6d>
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fwriteessidstrnoret>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%ebp
call   1040 <isasciistring@plt>
test   %eax,%eax
je     1169 <fwriteessidstrnoret+0x39>
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
lea    0xeaa(%rip),%rdi
mov    $0x1,%esi
jmp    11c7 <fwriteessidstrnoret+0x97>
lea    0xe90(%rip),%rdi
mov    $0x5,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fwrite@plt>
test   %ebp,%ebp
jle    11bb <fwriteessidstrnoret+0x8b>
mov    %ebp,%ebp
lea    0xe77(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%r12,%rbx,1),%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <fwriteessidstrnoret+0x70>
lea    0xe49(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
@.str.1 = [6 x i8] c"$HEX[\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [3 x i8] c"]:\00"
define void @fwriteessidstrnoret(i32 %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = call i32 @isasciistring(i32 %8, i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i32, i32* %4
%15 = load i32*, i32** %6
%16 = call i32 @fwrite(i8* %13, i32 %14, i32 1, i32* %15)
%17 = load i32*, i32** %6
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %41
19: ; preds = %3
%20 = load i32*, i32** %6
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %22
22: ; preds = %35, %19
%23 = load i32, i32* %7
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = load i32*, i32** %6
%28 = load i8*, i8** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %26
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %22
38: ; preds = %22
%39 = load i32*, i32** %6
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %38, %12
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [6 x i8] c"$HEX[\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [3 x i8] c"]:\00"
define void @fwriteessidstrnoret(i32 %0, i8* %1, i32* %2) {
%4 = tail call i32 @isasciistring(i32 %0, i8* %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = tail call i32 @fwrite(i8* %1, i32 %0, i32 1, i32* %2)
%8 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i64 1, i64 1, i32* %2)
br label %24
9: ; preds = %3
%10 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 5, i64 1, i32* %2)
%11 = icmp sgt i32 %0, 0
br i1 %11, label %12, label %22
12: ; preds = %9
%13 = zext i32 %0 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 0, %12 ], [ %20, %14 ]
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, %13
br i1 %21, label %22, label %14
22: ; preds = %14, %9
%23 = tail call i64 bitcast (i32 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 2, i64 1, i32* %2)
br label %24
24: ; preds = %22, %6
ret void
}