#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 strlen(char const *);
void gen_basic_name(FILE *F, const char *str) {
  int i;
  for (i = 0; i < strlen(str); i++) {
    if (str[i] == '[') {
      fprintf(F, "Z");
    } else if (str[i] == ']') {
      fprintf(F, "Z");
    } else if (str[i] == '-') {
      fprintf(F, "_");
    } else if (str[i] == '>') {
      fprintf(F, "X");
    } else {
      fprintf(F, "%c", str[i]);
    }
  }
}


x86 assembly (clang, -O0):
<gen_basic_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1243 <gen_basic_name+0x123>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jne    117f <gen_basic_name+0x5f>
mov    -0x8(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1230 <gen_basic_name+0x110>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5d,%eax
jne    11ab <gen_basic_name+0x8b>
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    122b <gen_basic_name+0x10b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    11d7 <gen_basic_name+0xb7>
mov    -0x8(%rbp),%rdi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1226 <gen_basic_name+0x106>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3e,%eax
jne    1203 <gen_basic_name+0xe3>
mov    -0x8(%rbp),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1221 <gen_basic_name+0x101>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    1226 <gen_basic_name+0x106>
jmp    122b <gen_basic_name+0x10b>
jmp    1230 <gen_basic_name+0x110>
jmp    1235 <gen_basic_name+0x115>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1137 <gen_basic_name+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_basic_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a1 <gen_basic_name+0x81>
xor    %ebx,%ebx
jmp    116b <gen_basic_name+0x4b>
nopl   0x0(%rax,%rax,1)
mov    $0x5f,%edi
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11a1 <gen_basic_name+0x81>
movsbl (%r15,%rbx,1),%eax
cmp    $0x5a,%eax
jg     1190 <gen_basic_name+0x70>
cmp    $0x2d,%al
je     1140 <gen_basic_name+0x20>
cmp    $0x3e,%al
jne    119d <gen_basic_name+0x7d>
mov    $0x58,%edi
jmp    1150 <gen_basic_name+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x5a,%edi
cmp    $0x5b,%al
je     1150 <gen_basic_name+0x30>
cmp    $0x5d,%al
je     1150 <gen_basic_name+0x30>
mov    %eax,%edi
jmp    1150 <gen_basic_name+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"Z\00"
@.str.1 = [2 x i8] c"_\00"
@.str.2 = [2 x i8] c"X\00"
@.str.3 = [3 x i8] c"%c\00"
define void @gen_basic_name(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %68, %2
%7 = load i32, i32* %5
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %71
11: ; preds = %6
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 91
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = load i32*, i32** %3
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %67
22: ; preds = %11
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 93
br i1 %29, label %30, label %33
30: ; preds = %22
%31 = load i32*, i32** %3
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %66
33: ; preds = %22
%34 = load i8*, i8** %4
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp eq i32 %39, 45
br i1 %40, label %41, label %44
41: ; preds = %33
%42 = load i32*, i32** %3
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %65
44: ; preds = %33
%45 = load i8*, i8** %4
%46 = load i32, i32* %5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 62
br i1 %51, label %52, label %55
52: ; preds = %44
%53 = load i32*, i32** %3
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %64
55: ; preds = %44
%56 = load i32*, i32** %3
%57 = load i8*, i8** %4
%58 = load i32, i32* %5
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
%61 = load i8, i8* %60
%62 = sext i8 %61 to i32
%63 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %62)
br label %64
64: ; preds = %55, %52
br label %65
65: ; preds = %64, %41
br label %66
66: ; preds = %65, %30
br label %67
67: ; preds = %66, %19
br label %68
68: ; preds = %67
%69 = load i32, i32* %5
%70 = add nsw i32 %69, 1
store i32 %70, i32* %5
br label %6
71: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @gen_basic_name(i32* nocapture %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2, %13
%6 = phi i64 [ %16, %13 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
switch i8 %8, label %11 [
i8 91, label %13
i8 93, label %13
i8 45, label %9
i8 62, label %10
]
9: ; preds = %5
br label %13
10: ; preds = %5
br label %13
11: ; preds = %5
%12 = sext i8 %8 to i32
br label %13
13: ; preds = %5, %5, %9, %11, %10
%14 = phi i32 [ 95, %9 ], [ %12, %11 ], [ 88, %10 ], [ 90, %5 ], [ 90, %5 ]
%15 = tail call i32 @fputc(i32 %14, i32* %0)
%16 = add nuw nsw i64 %6, 1
%17 = tail call i32 @strlen(i8* %1)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %5, label %20
20: ; preds = %13, %2
ret void
}