#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*/ strcpy(char *, char *);
int strlen(char *);
int strextract_name(char *out, char *in) {
  int i;
  for (i = 0; i < strlen(in); i++) {
    if (in[i] == '@') {
      out[i] = 0;
      return strlen(out);
    }
    out[i] = in[i];
  }
  strcpy(out, "");
  return -1;
}


x86 assembly (clang, -O0):
<strextract_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11a9 <strextract_name+0x89>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x40,%eax
jne    1185 <strextract_name+0x65>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4(%rbp)
jmp    11c0 <strextract_name+0xa0>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <strextract_name+0x17>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strextract_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1160 <strextract_name+0x40>
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
cmp    $0x40,%al
je     117a <strextract_name+0x5a>
mov    %al,(%r14,%rbx,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1140 <strextract_name+0x20>
lea    0xe99(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <strlen@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i32 @strextract_name(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %37, %2
%8 = load i32, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %40
12: ; preds = %7
%13 = load i8*, i8** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 64
br i1 %19, label %20, label %27
20: ; preds = %12
%21 = load i8*, i8** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 0, i8* %24
%25 = load i8*, i8** %4
%26 = call i32 @strlen(i8* %25)
store i32 %26, i32* %3
br label %43
27: ; preds = %12
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i8*, i8** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
store i8 %32, i8* %36
br label %37
37: ; preds = %27
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %7
40: ; preds = %7
%41 = load i8*, i8** %4
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %43
43: ; preds = %40, %20
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i32 @strextract_name(i8* %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, %14
%6 = phi i64 [ %16, %14 ], [ 0, %2 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 64
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = and i64 %6, 4294967295
%12 = getelementptr inbounds i8, i8* %0, i64 %11
store i8 0, i8* %12
%13 = tail call i32 @strlen(i8* %0)
br label %22
14: ; preds = %5
%15 = getelementptr inbounds i8, i8* %0, i64 %6
store i8 %8, i8* %15
%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 = %14, %2
%21 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %10
%23 = phi i32 [ %13, %10 ], [ -1, %20 ]
ret i32 %23
}