#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 */

/* Variables and functions */
int _bssid_escape(char const *, char *);
int /*<<< orphan*/ assert(int);
int snprintf(char *, int, char *, char *);
int _bssid_quote(const char *in, char *out) {
  int r;
  if (*in == '-') {
    r = snprintf(out, (6 * (sizeof "\\x00" - 1)) + 3, "%s", "BSSID_ANY");
    assert(r >= 0);
    assert((size_t)r < (6 * (sizeof "\\x00" - 1)) + 3);
    return r;
  }
  r = _bssid_escape(in, out + 1);
  if (r == -1)
    return -1;
  *out = '"';
  *(out + r) = '"';
  *(out + r + 1) = '\0';
  return r + 3;
}


x86 assembly (clang, -O0):
<_bssid_quote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11a0 <_bssid_quote+0x70>
mov    -0x18(%rbp),%rdi
mov    $0x1b,%esi
lea    0xea0(%rip),%rdx
lea    0xe9c(%rip),%rcx
call   1030 <snprintf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movslq -0x1c(%rbp),%rax
cmp    $0x1b,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f3 <_bssid_quote+0xc3>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1050 <_bssid_escape@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    11ca <_bssid_quote+0x9a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f3 <_bssid_quote+0xc3>
mov    -0x18(%rbp),%rax
movb   $0x22,(%rax)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x22,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_bssid_quote>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmpb   $0x2d,(%rdi)
jne    1175 <_bssid_quote+0x45>
lea    0xebd(%rip),%rdx
lea    0xeb9(%rip),%rcx
mov    %r14,%rdi
mov    $0x1b,%esi
call   1030 <snprintf@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1040 <assert@plt>
xor    %edi,%edi
cmp    $0x1b,%ebx
setb   %dil
call   1040 <assert@plt>
jmp    119c <_bssid_quote+0x6c>
lea    0x1(%r14),%rsi
call   1050 <_bssid_escape@plt>
cmp    $0xffffffff,%eax
je     1197 <_bssid_quote+0x67>
mov    %eax,%ebx
movb   $0x22,(%r14)
cltq
movw   $0x22,(%r14,%rax,1)
add    $0x3,%ebx
jmp    119c <_bssid_quote+0x6c>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"BSSID_ANY\00"
define i32 @_bssid_quote(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 45
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = call i32 @snprintf(i8* %12, i32 27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp sge i32 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = icmp ult i64 %19, 27
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %6
store i32 %23, i32* %3
br label %45
24: ; preds = %2
%25 = load i8*, i8** %4
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i32 @_bssid_escape(i8* %25, i8* %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %32
31: ; preds = %24
store i32 -1, i32* %3
br label %45
32: ; preds = %24
%33 = load i8*, i8** %5
store i8 34, i8* %33
%34 = load i8*, i8** %5
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 34, i8* %37
%38 = load i8*, i8** %5
%39 = load i32, i32* %6
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 1
store i8 0, i8* %42
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 3
store i32 %44, i32* %3
br label %45
45: ; preds = %32, %31, %11
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [10 x i8] c"BSSID_ANY\00"
define i32 @_bssid_quote(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 45
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 @snprintf(i8* %1, i32 27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%7 = xor i32 %6, -1
%8 = lshr i32 %7, 31
%9 = tail call i32 @assert(i32 %8)
%10 = icmp ult i32 %6, 27
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
br label %22
13: ; preds = %2
%14 = getelementptr inbounds i8, i8* %1, i64 1
%15 = tail call i32 @_bssid_escape(i8* %0, i8* %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %22, label %17
17: ; preds = %13
store i8 34, i8* %1
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
store i8 34, i8* %19
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %20
%21 = add nsw i32 %15, 3
br label %22
22: ; preds = %13, %17, %5
%23 = phi i32 [ %6, %5 ], [ %21, %17 ], [ -1, %13 ]
ret i32 %23
}