#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*/ bzero(char *, int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
size_t strcspn(char *, char *);
int strlen(char *);
char *remove_nickname(char *nick) {
  int final, flag = 1, i = 0;
  while (flag) {
    if (nick[i] == ':') {
      flag = 0;
    }
    i++;
  }
  final = strlen(nick) - i;
  char mensagem[final];
  memcpy(mensagem, &nick[i], final);
  bzero(nick, 256);
  strcpy(nick, mensagem);
  nick[strcspn(nick, "\n")] = 0;
  return nick;
}


x86 assembly (clang, -O0):
<remove_nickname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     119e <remove_nickname+0x4e>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    1190 <remove_nickname+0x40>
movl   $0x0,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <remove_nickname+0x1a>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x14(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0xc(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdea(%rip),%rsi
call   1050 <strcspn@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_nickname>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
xor    %ebx,%ebx
nop
cmpb   $0x3a,(%r15,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1160 <remove_nickname+0x10>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%edx
sub    %rbx,%rdx
mov    %edx,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %ebx,%esi
add    %r15,%rsi
mov    %r14,%rdi
call   1060 <memcpy@plt>
mov    %r15,%rdi
mov    $0x100,%esi
call   1070 <bzero@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    0xe49(%rip),%rsi
mov    %r15,%rdi
call   1050 <strcspn@plt>
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
define i8* @remove_nickname(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %2
store i32 1, i32* %4
store i32 0, i32* %5
br label %8
8: ; preds = %20, %1
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %8
%12 = load i8*, i8** %2
%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, 58
br i1 %18, label %19, label %20
19: ; preds = %11
store i32 0, i32* %4
br label %20
20: ; preds = %19, %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %8
23: ; preds = %8
%24 = load i8*, i8** %2
%25 = call i32 @strlen(i8* %24)
%26 = load i32, i32* %5
%27 = sub nsw i32 %25, %26
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %6
%31 = alloca i8, i64 %29
store i64 %29, i64* %7
%32 = load i8*, i8** %2
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i32, i32* %3
%37 = call i32 @memcpy(i8* %31, i8* %35, i32 %36)
%38 = load i8*, i8** %2
%39 = call i32 @bzero(i8* %38, i32 256)
%40 = load i8*, i8** %2
%41 = call i32 @strcpy(i8* %40, i8* %31)
%42 = load i8*, i8** %2
%43 = load i8*, i8** %2
%44 = call i64 @strcspn(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 0, i8* %45
%46 = load i8*, i8** %2
%47 = load i8*, i8** %6
ret i8* %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
define i8* @remove_nickname(i8* returned %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i64 [ 0, %1 ], [ %7, %2 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 58
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = trunc i64 %7 to i32
%10 = tail call i32 @strlen(i8* %0)
%11 = sub nsw i32 %10, %9
%12 = zext i32 %11 to i64
%13 = alloca i8, i64 %12
%14 = and i64 %7, 4294967295
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = call i32 @memcpy(i8* %13, i8* %15, i32 %11)
%17 = call i32 @bzero(i8* %0, i32 256)
%18 = call i32 @strcpy(i8* %0, i8* %13)
%19 = call i64 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = getelementptr inbounds i8, i8* %0, i64 %19
store i8 0, i8* %20
ret i8* %0
}