#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 /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
char *format_ssid(char *ssid) {
  static char buf[32 + 3];
  if (ssid && ssid[0])
    snprintf(buf, sizeof(buf), "\"%s\"", ssid);
  else
    snprintf(buf, sizeof(buf), "unknown");
  return buf;
}


x86 assembly (clang, -O0):
<format_ssid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     115a <format_ssid+0x4a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     115a <format_ssid+0x4a>
mov    -0x8(%rbp),%rcx
lea    0x2efe(%rip),%rdi
mov    $0x23,%esi
lea    0xeb2(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1174 <format_ssid+0x64>
lea    0x2edf(%rip),%rdi
mov    $0x23,%esi
lea    0xe98(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
lea    0x2ec5(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_ssid>:
push   %rax
test   %rdi,%rdi
je     113a <format_ssid+0x2a>
mov    %rdi,%rcx
cmpb   $0x0,(%rdi)
je     113a <format_ssid+0x2a>
lea    0x2f1b(%rip),%rdi
lea    0xed4(%rip),%rdx
mov    $0x23,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
jmp    1154 <format_ssid+0x44>
lea    0x2eff(%rip),%rdi
lea    0xebd(%rip),%rdx
mov    $0x23,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
lea    0x2ee5(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@format_ssid.buf = internal global [35 x i8] zeroinitializer
@.str = [5 x i8] c"\22%s\22\00"
@.str.1 = [8 x i8] c"unknown\00"
define i8* @format_ssid(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %14
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %16
14: ; preds = %5, %1
%15 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
ret i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@format_ssid.buf = internal global [35 x i8] zeroinitializer
@.str = [5 x i8] c"\22%s\22\00"
@.str.1 = [8 x i8] c"unknown\00"
define i8* @format_ssid(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %10
8: ; preds = %3, %1
%9 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0), i32 35, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
ret i8* getelementptr inbounds ([35 x i8], [35 x i8]* @format_ssid.buf, i64 0, i64 0)
}