#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*/ memcmp(char *, char const *, int);
int strlen(char const *);
void cut_export_token(char *sym) {
  const char *token = "_EXPORTEDSYM_";
  int sizetoken = strlen(token);
  char *src, *fin;
  fin = sym + strlen(sym) - sizetoken;
  for (; sym <= fin; sym++) {
    if (!memcmp(sym, token, sizetoken)) {
      for (src = sym + strlen(token); *src; src++, sym++)
        *sym = *src;
      *sym = 0;
      return;
    }
  }
}


x86 assembly (clang, -O0):
<cut_export_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x28(%rbp),%rax
ja     1210 <cut_export_token+0xf0>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
jne    11fa <cut_export_token+0xda>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11ee <cut_export_token+0xce>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b8 <cut_export_token+0x98>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
jmp    1210 <cut_export_token+0xf0>
jmp    11ff <cut_export_token+0xdf>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1170 <cut_export_token+0x50>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cut_export_token>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbp
add    %rbx,%rbp
movslq %r15d,%rax
sub    %rax,%rbp
cmp    %rbx,%rbp
jb     11b2 <cut_export_token+0x92>
lea    0xea7(%rip),%r14
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     117d <cut_export_token+0x5d>
add    $0x1,%rbx
cmp    %rbp,%rbx
jbe    1160 <cut_export_token+0x40>
jmp    11b2 <cut_export_token+0x92>
lea    0xe7c(%rip),%rdi
call   1030 <strlen@plt>
cltq
mov    (%rbx,%rax,1),%cl
test   %cl,%cl
je     11af <cut_export_token+0x8f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %cl,(%rbx)
movzbl 0x1(%rbx,%rax,1),%ecx
add    $0x1,%rbx
test   %cl,%cl
jne    11a0 <cut_export_token+0x80>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [14 x i8] c"_EXPORTEDSYM_\00"
define void @cut_export_token(i8* %0) {
%2 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @strlen(i8* %0)
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = sext i32 %2 to i64
%7 = sub nsw i64 0, %6
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = icmp ult i8* %8, %0
br i1 %9, label %33, label %10
10: ; preds = %1, %30
%11 = phi i8* [ %31, %30 ], [ %0, %1 ]
%12 = tail call i32 @memcmp(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %30
14: ; preds = %10
%15 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %11, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %14, %20
%21 = phi i8 [ %26, %20 ], [ %18, %14 ]
%22 = phi i8* [ %25, %20 ], [ %11, %14 ]
%23 = phi i8* [ %24, %20 ], [ %17, %14 ]
store i8 %21, i8* %22
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = getelementptr inbounds i8, i8* %22, i64 1
%26 = load i8, i8* %24
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %20
28: ; preds = %20, %14
%29 = phi i8* [ %11, %14 ], [ %25, %20 ]
store i8 0, i8* %29
br label %33
30: ; preds = %10
%31 = getelementptr inbounds i8, i8* %11, i64 1
%32 = icmp ugt i8* %31, %8
br i1 %32, label %33, label %10
33: ; preds = %30, %1, %28
ret void
}