#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 */
char *make_lower_temp(char const *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
void remove_nickname(const char *nickname, char *src, char *dst) {
  char tmp[512];
  char srclo[512];
  int n;
  strcpy(tmp, make_lower_temp(nickname));
  strcpy(srclo, make_lower_temp(src));
  strcat(tmp, "_");
  n = strlen(tmp);
  if (!strncmp(tmp, srclo, n)) {
    strcpy(dst, &(src[n]));
  } else {
    strcpy(dst, src);
  }
}


x86 assembly (clang, -O0):
<remove_nickname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x438(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <make_lower_temp@plt>
mov    -0x438(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <make_lower_temp@plt>
mov    -0x430(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    -0x220(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x424(%rbp)
lea    -0x220(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x424(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1216 <remove_nickname+0xc6>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x424(%rbp),%rax
add    %rax,%rsi
call   1040 <strcpy@plt>
jmp    1223 <remove_nickname+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcpy@plt>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_nickname>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x400,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
call   1070 <make_lower_temp@plt>
lea    0x200(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1070 <make_lower_temp@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
cmove  %ebp,%ecx
movslq %ecx,%rsi
add    %r15,%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
add    $0x400,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"_\00"
define void @remove_nickname(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [512 x i8]
%8 = alloca [512 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %4
%12 = call i8* @make_lower_temp(i8* %11)
%13 = call i32 @strcpy(i8* %10, i8* %12)
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%15 = load i8*, i8** %5
%16 = call i8* @make_lower_temp(i8* %15)
%17 = call i32 @strcpy(i8* %14, i8* %16)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%19 = call i32 @strcat(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
store i32 %21, i32* %9
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%24 = load i32, i32* %9
%25 = call i32 @strncmp(i8* %22, i8* %23, i32 %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %3
%28 = load i8*, i8** %6
%29 = load i8*, i8** %5
%30 = load i32, i32* %9
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = call i32 @strcpy(i8* %28, i8* %32)
br label %38
34: ; preds = %3
%35 = load i8*, i8** %6
%36 = load i8*, i8** %5
%37 = call i32 @strcpy(i8* %35, i8* %36)
br label %38
38: ; preds = %34, %27
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
define void @remove_nickname(i8* %0, i8* %1, i8* %2) {
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%8 = tail call i8* @make_lower_temp(i8* %0)
%9 = call i32 @strcpy(i8* %6, i8* %8)
%10 = call i8* @make_lower_temp(i8* %1)
%11 = call i32 @strcpy(i8* %7, i8* %10)
%12 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @strlen(i8* %6)
%14 = call i32 @strncmp(i8* %6, i8* %7, i32 %13)
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 %13, i32 0
%17 = sext i32 %16 to i64
%18 = getelementptr i8, i8* %1, i64 %17
%19 = call i32 @strcpy(i8* %2, i8* %18)
ret void
}