#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 /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
int strnlen(char const *, int);
int make_symbol(char *buf, int len, int color, int bold,
                const char *l_delimiter, const char *r_delimiter,
                const char *content, const char *fmt) {
  int actual_len = 0;
  actual_len =
      strnlen(content, 32) + strnlen(l_delimiter, 4) + strnlen(r_delimiter, 4);
  if (!buf)
    return actual_len;
  if (actual_len > len)
    return -1;
  char fmt_buf[32];
  snprintf(fmt_buf, 32, "%%s%s%%s", fmt);
  snprintf(buf, len, fmt_buf, l_delimiter, content, r_delimiter);
  return actual_len;
}


x86 assembly (clang, -O0):
<make_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strnlen@plt>
mov    %eax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x4,%esi
call   1040 <strnlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1040 <strnlen@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11a3 <make_symbol+0x83>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11fa <make_symbol+0xda>
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11bb <make_symbol+0x9b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fa <make_symbol+0xda>
lea    -0x60(%rbp),%rdi
mov    0x18(%rbp),%rcx
mov    $0x20,%esi
lea    0xe31(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x60(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x10(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    $0x0,%al
call   1030 <snprintf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_symbol>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,%r14
mov    %r8,%r13
mov    %esi,%r12d
mov    %rdi,%rbp
mov    0x60(%rsp),%rdi
mov    $0x20,%esi
call   1040 <strnlen@plt>
mov    %eax,%ebx
mov    %r13,%rdi
mov    $0x4,%esi
call   1040 <strnlen@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r14,%rdi
mov    $0x4,%esi
call   1040 <strnlen@plt>
mov    %eax,%ebx
add    %r15d,%ebx
test   %rbp,%rbp
je     11b8 <make_symbol+0x98>
mov    $0xffffffff,%eax
cmp    %r12d,%ebx
jg     11ba <make_symbol+0x9a>
mov    0x68(%rsp),%rcx
lea    0xe75(%rip),%rdx
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
mov    %r13,%rcx
mov    0x60(%rsp),%r8
mov    %r14,%r9
xor    %eax,%eax
call   1030 <snprintf@plt>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"%%s%s%%s\00"
define i32 @make_symbol(i8* %0, i32 %1, i32 %2, i32 %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca [32 x i8]
%10 = tail call i32 @strnlen(i8* %6, i32 32)
%11 = tail call i32 @strnlen(i8* %4, i32 4)
%12 = add nsw i32 %11, %10
%13 = tail call i32 @strnlen(i8* %5, i32 4)
%14 = add nsw i32 %12, %13
%15 = icmp eq i8* %0, null
br i1 %15, label %22, label %16
16: ; preds = %8
%17 = icmp sgt i32 %14, %1
br i1 %17, label %22, label %18
18: ; preds = %16
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%20 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %19, i32 32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %7)
%21 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %0, i32 %1, i8* %19, i8* %4, i8* %6, i8* %5)
br label %22
22: ; preds = %16, %8, %18
%23 = phi i32 [ %14, %18 ], [ %14, %8 ], [ -1, %16 ]
ret i32 %23
}