#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*/ free(char *);
char *new_str_copy(char *);
scalar_t__ quote_char(char);
char *sn_to_str(int);
int str_to_sn(char *, int /*<<< orphan*/);
int strlen(char *);
char *process_quoted_symbol(char *str) {
  if (quote_char(*str)) {
    int sn;
    char *str2 = new_str_copy(str);
    str2[strlen(str2) - 1] = '\0';
    str2 = str2 + 1;
    sn = str_to_sn(str2, 0);
    free(str2 - 1);
    str2 = sn_to_str(sn);
    return str2;
  } else
    return str;
}


x86 assembly (clang, -O0):
<process_quoted_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1060 <quote_char@plt>
cmp    $0x0,%rax
je     11f0 <process_quoted_symbol+0x90>
mov    -0x10(%rbp),%rdi
call   1050 <new_str_copy@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
call   1080 <str_to_sn@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1070 <sn_to_str@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11f8 <process_quoted_symbol+0x98>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_quoted_symbol>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1060 <quote_char@plt>
test   %rax,%rax
je     11af <process_quoted_symbol+0x4f>
mov    %rbx,%rdi
call   1050 <new_str_copy@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
lea    0x1(%rbx),%rdi
xor    %esi,%esi
call   1080 <str_to_sn@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <sn_to_str@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @process_quoted_symbol(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = call i64 @quote_char(i8 signext %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @new_str_copy(i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = load i8*, i8** %5
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %13, i64 %17
store i8 0, i8* %18
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = call i32 @str_to_sn(i8* %21, i32 0)
store i32 %22, i32* %4
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 -1
%25 = call i32 @free(i8* %24)
%26 = load i32, i32* %4
%27 = call i8* @sn_to_str(i32 %26)
store i8* %27, i8** %5
%28 = load i8*, i8** %5
store i8* %28, i8** %2
br label %31
29: ; preds = %1
%30 = load i8*, i8** %3
store i8* %30, i8** %2
br label %31
31: ; preds = %29, %10
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
define i8* @process_quoted_symbol(i8* %0) {
%2 = load i8, i8* %0
%3 = tail call i64 @quote_char(i8 signext %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = tail call i8* @new_str_copy(i8* %0)
%7 = tail call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %6, i64 %9
store i8 0, i8* %10
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = tail call i32 @str_to_sn(i8* %11, i32 0)
%13 = tail call i32 @free(i8* %6)
%14 = tail call i8* @sn_to_str(i32 %12)
br label %15
15: ; preds = %1, %5
%16 = phi i8* [ %14, %5 ], [ %0, %1 ]
ret i8* %16
}