#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*/ sprintf(char *, char *, int);
scalar_t__ strchr(char *, unsigned char);
int /*<<< orphan*/ strlen(char *);
char *seq_name(char *seq, int len) {
  static char buf[20 * 4];
  char *p = buf;
  while (len--) {
    unsigned char c = *seq++;
    if (c == '^' || (c && strchr("{}();\"=", c)))
      *(p++) = '\\';
    if (c < ' ') {
      *(p++) = '^';
      *(p++) = c | '@';
    } else if (c == 0x7f) {
      *(p++) = '^';
      *(p++) = '?';
    } else if (c & 0x80) {
      sprintf(p, "\\%03o", (int)c);
      p += strlen(p);
    } else
      *(p++) = c;
  }
  *p = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<seq_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0x2f0a(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1293 <seq_name+0x163>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x5e,%eax
je     11a6 <seq_name+0x76>
movzbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     11b8 <seq_name+0x88>
lea    0xe6d(%rip),%rdi
movzbl -0x19(%rbp),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11b8 <seq_name+0x88>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5c,(%rax)
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jge    11f6 <seq_name+0xc6>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5e,(%rax)
movzbl -0x19(%rbp),%eax
or     $0x40,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    128e <seq_name+0x15e>
movzbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
jne    122c <seq_name+0xfc>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5e,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x3f,(%rax)
jmp    1289 <seq_name+0x159>
movzbl -0x19(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1270 <seq_name+0x140>
mov    -0x18(%rbp),%rdi
movzbl -0x19(%rbp),%edx
lea    0xdbb(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    1284 <seq_name+0x154>
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1289 <seq_name+0x159>
jmp    128e <seq_name+0x15e>
jmp    114a <seq_name+0x1a>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2daf(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<seq_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
je     11e1 <seq_name+0xb1>
mov    %rdi,%r14
mov    %esi,%r13d
lea    0x2f00(%rip),%rbx
xor    %r15d,%r15d
lea    0xea6(%rip),%r12
jmp    1178 <seq_name+0x48>
nopl   0x0(%rax)
movb   $0x5e,(%rbx)
or     $0x40,%bpl
mov    %bpl,0x1(%rbx)
add    $0x2,%rbx
add    $0x1,%r15
cmp    %r15d,%r13d
je     11e8 <seq_name+0xb8>
movzbl (%r14,%r15,1),%ebp
test   %ebp,%ebp
je     1160 <seq_name+0x30>
cmp    $0x5e,%bpl
je     1198 <seq_name+0x68>
movzbl %bpl,%esi
mov    %r12,%rdi
call   1040 <strchr@plt>
test   %rax,%rax
je     119f <seq_name+0x6f>
movb   $0x5c,(%rbx)
add    $0x1,%rbx
cmp    $0x1f,%bpl
jbe    1160 <seq_name+0x30>
cmp    $0x7f,%bpl
jne    11b2 <seq_name+0x82>
movw   $0x3f5e,(%rbx)
jmp    116b <seq_name+0x3b>
test   $0x80,%bpl
jne    11c1 <seq_name+0x91>
mov    %bpl,(%rbx)
add    $0x1,%rbx
jmp    116f <seq_name+0x3f>
mov    %rbx,%rdi
lea    0xe3d(%rip),%rsi
mov    %ebp,%edx
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
add    %rax,%rbx
jmp    116f <seq_name+0x3f>
lea    0x2e68(%rip),%rbx
movb   $0x0,(%rbx)
lea    0x2e5e(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@seq_name.buf = internal global [80 x i8] zeroinitializer
@.str = [8 x i8] c"{}();\22=\00"
@.str.1 = [6 x i8] c"\\%03o\00"
define i8* @seq_name(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seq_name.buf, i64 0, i64 0), i8** %5
br label %7
7: ; preds = %72, %2
%8 = load i32, i32* %4
%9 = add nsw i32 %8, -1
store i32 %9, i32* %4
%10 = icmp ne i32 %8, 0
br i1 %10, label %11, label %73
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %3
%14 = load i8, i8* %12
store i8 %14, i8* %6
%15 = load i8, i8* %6
%16 = zext i8 %15 to i32
%17 = icmp eq i32 %16, 94
br i1 %17, label %26, label %18
18: ; preds = %11
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %29
22: ; preds = %18
%23 = load i8, i8* %6
%24 = call i64 @strchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22, %11
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
store i8 92, i8* %27
br label %29
29: ; preds = %26, %22, %18
%30 = load i8, i8* %6
%31 = zext i8 %30 to i32
%32 = icmp slt i32 %31, 32
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %5
store i8 94, i8* %34
%36 = load i8, i8* %6
%37 = zext i8 %36 to i32
%38 = or i32 %37, 64
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
store i8 %39, i8* %40
br label %72
42: ; preds = %29
%43 = load i8, i8* %6
%44 = zext i8 %43 to i32
%45 = icmp eq i32 %44, 127
br i1 %45, label %46, label %51
46: ; preds = %42
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %5
store i8 94, i8* %47
%49 = load i8*, i8** %5
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %5
store i8 63, i8* %49
br label %71
51: ; preds = %42
%52 = load i8, i8* %6
%53 = zext i8 %52 to i32
%54 = and i32 %53, 128
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %66
56: ; preds = %51
%57 = load i8*, i8** %5
%58 = load i8, i8* %6
%59 = zext i8 %58 to i32
%60 = call i32 @sprintf(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %59)
%61 = load i8*, i8** %5
%62 = call i32 @strlen(i8* %61)
%63 = load i8*, i8** %5
%64 = sext i32 %62 to i64
%65 = getelementptr inbounds i8, i8* %63, i64 %64
store i8* %65, i8** %5
br label %70
66: ; preds = %51
%67 = load i8, i8* %6
%68 = load i8*, i8** %5
%69 = getelementptr inbounds i8, i8* %68, i32 1
store i8* %69, i8** %5
store i8 %67, i8* %68
br label %70
70: ; preds = %66, %56
br label %71
71: ; preds = %70, %46
br label %72
72: ; preds = %71, %33
br label %7
73: ; preds = %7
%74 = load i8*, i8** %5
store i8 0, i8* %74
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seq_name.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@seq_name.buf = internal global [80 x i8] zeroinitializer
@.str = [8 x i8] c"{}();\22=\00"
@.str.1 = [6 x i8] c"\\%03o\00"
define i8* @seq_name(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %43, label %4
4: ; preds = %2, %40
%5 = phi i32 [ %8, %40 ], [ %1, %2 ]
%6 = phi i8* [ %9, %40 ], [ %0, %2 ]
%7 = phi i8* [ %41, %40 ], [ getelementptr inbounds ([80 x i8], [80 x i8]* @seq_name.buf, i64 0, i64 0), %2 ]
%8 = add nsw i32 %5, -1
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %6
%11 = zext i8 %10 to i32
switch i8 %10, label %12 [
i8 94, label %15
i8 0, label %20
]
12: ; preds = %4
%13 = tail call i64 @strchr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %4, %12
%16 = getelementptr inbounds i8, i8* %7, i64 1
store i8 92, i8* %7
br label %17
17: ; preds = %15, %12
%18 = phi i8* [ %16, %15 ], [ %7, %12 ]
%19 = icmp ult i8 %10, 32
br i1 %19, label %20, label %25
20: ; preds = %4, %17
%21 = phi i8* [ %18, %17 ], [ %7, %4 ]
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8 94, i8* %21
%23 = or i8 %10, 64
%24 = getelementptr inbounds i8, i8* %21, i64 2
store i8 %23, i8* %22
br label %40
25: ; preds = %17
%26 = icmp eq i8 %10, 127
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = getelementptr inbounds i8, i8* %18, i64 1
store i8 94, i8* %18
%29 = getelementptr inbounds i8, i8* %18, i64 2
store i8 63, i8* %28
br label %40
30: ; preds = %25
%31 = and i32 %11, 128
%32 = icmp eq i32 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %30
%34 = tail call i32 @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%35 = tail call i32 @strlen(i8* %18)
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %18, i64 %36
br label %40
38: ; preds = %30
%39 = getelementptr inbounds i8, i8* %18, i64 1
store i8 %10, i8* %18
br label %40
40: ; preds = %27, %38, %33, %20
%41 = phi i8* [ %24, %20 ], [ %29, %27 ], [ %37, %33 ], [ %39, %38 ]
%42 = icmp eq i32 %8, 0
br i1 %42, label %43, label %4
43: ; preds = %40, %2
%44 = phi i8* [ getelementptr inbounds ([80 x i8], [80 x i8]* @seq_name.buf, i64 0, i64 0), %2 ], [ %41, %40 ]
store i8 0, i8* %44
ret i8* getelementptr inbounds ([80 x i8], [80 x i8]* @seq_name.buf, i64 0, i64 0)
}