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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ symchar(char);
void print_symbol(FILE *f, char *name) {
  int i, escape = 0, charescape = 0;
  if (name[0] == '\0') {
    fprintf(f, "||");
    return;
  }
  if (name[0] == '.' && name[1] == '\0') {
    fprintf(f, "|.|");
    return;
  }
  if (name[0] == '#')
    escape = 1;
  i = 0;
  while (name[i]) {
    if (!symchar(name[i])) {
      escape = 1;
      if (name[i] == '|' || name[i] == '\\') {
        charescape = 1;
        break;
      }
    }
    i++;
  }
  if (escape) {
    if (charescape) {
      fprintf(f, "|");
      i = 0;
      while (name[i]) {
        if (name[i] == '|' || name[i] == '\\')
          fprintf(f, "\\%c", name[i]);
        else
          fprintf(f, "%c", name[i]);
        i++;
      }
      fprintf(f, "|");
    } else {
      fprintf(f, "|%s|", name);
    }
  } else {
    fprintf(f, "%s", name);
  }
}


x86 assembly (clang, -O0):
<print_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1165 <print_symbol+0x45>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1337 <print_symbol+0x217>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    119d <print_symbol+0x7d>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    119d <print_symbol+0x7d>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1337 <print_symbol+0x217>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11b4 <print_symbol+0x94>
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1237 <print_symbol+0x117>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <symchar@plt>
cmp    $0x0,%eax
jne    1229 <print_symbol+0x109>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7c,%eax
je     1218 <print_symbol+0xf8>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    1224 <print_symbol+0x104>
movl   $0x1,-0x1c(%rbp)
jmp    1237 <print_symbol+0x117>
jmp    1229 <print_symbol+0x109>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bb <print_symbol+0x9b>
cmpl   $0x0,-0x18(%rbp)
je     1321 <print_symbol+0x201>
cmpl   $0x0,-0x1c(%rbp)
je     1306 <print_symbol+0x1e6>
mov    -0x8(%rbp),%rdi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     12ef <print_symbol+0x1cf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7c,%eax
je     12a0 <print_symbol+0x180>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
jne    12c3 <print_symbol+0x1a3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    12e1 <print_symbol+0x1c1>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xd2e(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1264 <print_symbol+0x144>
mov    -0x8(%rbp),%rdi
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    131c <print_symbol+0x1fc>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xcf6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1337 <print_symbol+0x217>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_symbol>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rsi),%al
cmp    $0x2e,%al
je     1179 <print_symbol+0x29>
cmp    $0x23,%al
je     11a5 <print_symbol+0x55>
test   %al,%al
jne    11ad <print_symbol+0x5d>
lea    0xe8e(%rip),%rdi
mov    $0x2,%esi
jmp    118e <print_symbol+0x3e>
xor    %r15d,%r15d
cmpb   $0x0,0x1(%rbx)
jne    11b0 <print_symbol+0x60>
lea    0xe7a(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <fwrite@plt>
mov    $0x1,%r15d
jmp    11b0 <print_symbol+0x60>
xor    %r15d,%r15d
lea    0x1(%rbx),%rbp
jmp    11cc <print_symbol+0x7c>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     123f <print_symbol+0xef>
movsbl %al,%edi
call   1030 <symchar@plt>
test   %eax,%eax
jne    11c0 <print_symbol+0x70>
movzbl -0x1(%rbp),%eax
mov    $0x1,%r15d
or     $0x20,%al
cmp    $0x7c,%al
jne    11c0 <print_symbol+0x70>
mov    $0x7c,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
mov    (%rbx),%al
test   %al,%al
je     1262 <print_symbol+0x112>
add    $0x1,%rbx
lea    0xe01(%rip),%r15
jmp    1225 <print_symbol+0xd5>
nopl   0x0(%rax,%rax,1)
mov    %edx,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1262 <print_symbol+0x112>
movsbl %al,%edx
mov    %edx,%eax
or     $0x20,%al
cmp    $0x7c,%al
jne    1210 <print_symbol+0xc0>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    121a <print_symbol+0xca>
test   %r15d,%r15d
je     1279 <print_symbol+0x129>
lea    0xdc0(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
mov    $0x7c,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fputc@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fputs@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"||\00"
@.str.1 = [4 x i8] c"|.|\00"
@.str.2 = [2 x i8] c"|\00"
@.str.3 = [4 x i8] c"\\%c\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [5 x i8] c"|%s|\00"
@.str.6 = [3 x i8] c"%s\00"
define void @print_symbol(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %6
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** %3
%15 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %140
16: ; preds = %2
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 46
br i1 %21, label %22, label %31
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i32*, i32** %3
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %140
31: ; preds = %22, %16
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 35
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %6
br label %38
38: ; preds = %37, %31
store i32 0, i32* %5
br label %39
39: ; preds = %72, %38
%40 = load i8*, i8** %4
%41 = load i32, i32* %5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %46, label %75
46: ; preds = %39
%47 = load i8*, i8** %4
%48 = load i32, i32* %5
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = call i32 @symchar(i8 signext %51)
%53 = icmp ne i32 %52, 0
br i1 %53, label %72, label %54
54: ; preds = %46
store i32 1, i32* %6
%55 = load i8*, i8** %4
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 124
br i1 %61, label %70, label %62
62: ; preds = %54
%63 = load i8*, i8** %4
%64 = load i32, i32* %5
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 92
br i1 %69, label %70, label %71
70: ; preds = %62, %54
store i32 1, i32* %7
br label %75
71: ; preds = %62
br label %72
72: ; preds = %71, %46
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %39
75: ; preds = %70, %39
%76 = load i32, i32* %6
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %136
78: ; preds = %75
%79 = load i32, i32* %7
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %131
81: ; preds = %78
%82 = load i32*, i32** %3
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %5
br label %84
84: ; preds = %125, %81
%85 = load i8*, i8** %4
%86 = load i32, i32* %5
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = icmp ne i8 %89, 0
br i1 %90, label %91, label %128
91: ; preds = %84
%92 = load i8*, i8** %4
%93 = load i32, i32* %5
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i8, i8* %92, i64 %94
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp eq i32 %97, 124
br i1 %98, label %107, label %99
99: ; preds = %91
%100 = load i8*, i8** %4
%101 = load i32, i32* %5
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8, i8* %100, i64 %102
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp eq i32 %105, 92
br i1 %106, label %107, label %116
107: ; preds = %99, %91
%108 = load i32*, i32** %3
%109 = load i8*, i8** %4
%110 = load i32, i32* %5
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8, i8* %109, i64 %111
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = call i32 (i32*, i8*, ...) @fprintf(i32* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %114)
br label %125
116: ; preds = %99
%117 = load i32*, i32** %3
%118 = load i8*, i8** %4
%119 = load i32, i32* %5
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds i8, i8* %118, i64 %120
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = call i32 (i32*, i8*, ...) @fprintf(i32* %117, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %123)
br label %125
125: ; preds = %116, %107
%126 = load i32, i32* %5
%127 = add nsw i32 %126, 1
store i32 %127, i32* %5
br label %84
128: ; preds = %84
%129 = load i32*, i32** %3
%130 = call i32 (i32*, i8*, ...) @fprintf(i32* %129, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %135
131: ; preds = %78
%132 = load i32*, i32** %3
%133 = load i8*, i8** %4
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %132, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %133)
br label %135
135: ; preds = %131, %128
br label %140
136: ; preds = %75
%137 = load i32*, i32** %3
%138 = load i8*, i8** %4
%139 = call i32 (i32*, i8*, ...) @fprintf(i32* %137, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %138)
br label %140
140: ; preds = %13, %28, %136, %135
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"||\00"
@.str.1 = [4 x i8] c"|.|\00"
@.str.3 = [4 x i8] c"\\%c\00"
@.str.5 = [5 x i8] c"|%s|\00"
define void @print_symbol(i32* nocapture %0, i8* %1) {
%3 = load i8, i8* %1
switch i8 %3, label %12 [
i8 0, label %4
i8 46, label %6
i8 35, label %13
]
4: ; preds = %2
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %55
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 3, i64 1, i32* %0)
br label %55
12: ; preds = %2
br label %13
13: ; preds = %2, %6, %12
%14 = phi i32 [ 0, %12 ], [ 0, %6 ], [ 1, %2 ]
br label %15
15: ; preds = %13, %24
%16 = phi i64 [ %26, %24 ], [ 0, %13 ]
%17 = phi i8 [ %28, %24 ], [ %3, %13 ]
%18 = phi i8* [ %27, %24 ], [ %1, %13 ]
%19 = phi i32 [ %25, %24 ], [ %14, %13 ]
%20 = tail call i32 @symchar(i8 signext %17)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = load i8, i8* %18
switch i8 %23, label %24 [
i8 124, label %32
i8 92, label %32
]
24: ; preds = %22, %15
%25 = phi i32 [ %19, %15 ], [ 1, %22 ]
%26 = add nuw i64 %16, 1
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %15
30: ; preds = %24
%31 = icmp eq i32 %25, 0
br i1 %31, label %53, label %51
32: ; preds = %22, %22
%33 = tail call i32 @fputc(i32 124, i32* %0)
%34 = load i8, i8* %1
%35 = icmp eq i8 %34, 0
br i1 %35, label %49, label %36
36: ; preds = %32, %44
%37 = phi i64 [ %45, %44 ], [ 0, %32 ]
%38 = phi i8 [ %47, %44 ], [ %34, %32 ]
%39 = sext i8 %38 to i32
switch i8 %38, label %42 [
i8 124, label %40
i8 92, label %40
]
40: ; preds = %36, %36
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %44
42: ; preds = %36
%43 = tail call i32 @fputc(i32 %39, i32* %0)
br label %44
44: ; preds = %42, %40
%45 = add nuw i64 %37, 1
%46 = getelementptr inbounds i8, i8* %1, i64 %45
%47 = load i8, i8* %46
%48 = icmp eq i8 %47, 0
br i1 %48, label %49, label %36
49: ; preds = %44, %32
%50 = tail call i32 @fputc(i32 124, i32* %0)
br label %55
51: ; preds = %30
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %55
53: ; preds = %30
%54 = tail call i32 @fputs(i8* %1, i32* %0)
br label %55
55: ; preds = %53, %51, %49, %10, %4
ret void
}