#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 *);
char *strstr(char *, char *);
char *strtok(char *, char *);
int getsender(char *s) {
  char *p = strstr(s, "@");
  if (!p) {
    p = strtok(s, " (");
    if (p == 0)
      p = "";
    strcpy(s, p);
    return 0;
  }
  p = strstr(s, "<");
  if (p == 0)
    p = s;
  else {
    p++;
    char *p2 = strstr(p, ">");
    if (p2 != 0)
      *p2 = 0;
  }
  if (strstr(p, "@nkbbs.org") || strstr(p, "@localhost")) {
    char *p3 = strstr(p, "@");
    *p3 = 0;
    strcpy(s, p);
    return 0;
  }
  strcpy(s, p);
  return 1;
}


x86 assembly (clang, -O0):
<getsender>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119e <getsender+0x6e>
mov    -0x10(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1185 <getsender+0x55>
lea    0xe83(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    127d <getsender+0x14d>
mov    -0x10(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ca <getsender+0x9a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1201 <getsender+0xd1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11fc <getsender+0xcc>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    1201 <getsender+0xd1>
mov    -0x18(%rbp),%rdi
lea    0xdfd(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
jne    1235 <getsender+0x105>
mov    -0x18(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     1269 <getsender+0x139>
mov    -0x18(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x4(%rbp)
jmp    127d <getsender+0x14d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getsender>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x40,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c5 <getsender+0x85>
mov    %r14,%rdi
mov    $0x3c,%esi
call   1040 <strchr@plt>
mov    %r14,%r15
test   %rax,%rax
je     118b <getsender+0x4b>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x3e,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1188 <getsender+0x48>
movb   $0x0,(%rax)
mov    %rbx,%r15
lea    0xe71(%rip),%rsi
mov    %r15,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
jne    11b3 <getsender+0x73>
lea    0xe68(%rip),%rsi
mov    %r15,%rdi
call   1060 <strstr@plt>
test   %rax,%rax
je     11f7 <getsender+0xb7>
mov    %r15,%rdi
mov    $0x40,%esi
call   1040 <strchr@plt>
movb   $0x0,(%rax)
jmp    11e2 <getsender+0xa2>
lea    0xe34(%rip),%rsi
mov    %r14,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
lea    0xe24(%rip),%r15
cmovne %rax,%r15
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%ebx
jmp    11e4 <getsender+0xa4>

LLVM IR (-O0):
@.str = [2 x i8] c"@\00"
@.str.1 = [3 x i8] c" (\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c"<\00"
@.str.4 = [2 x i8] c">\00"
@.str.5 = [11 x i8] c"@nkbbs.org\00"
@.str.6 = [11 x i8] c"@localhost\00"
define i32 @getsender(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @strstr(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %8, i8** %4
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %21, label %11
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %17
16: ; preds = %11
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %17
17: ; preds = %16, %11
%18 = load i8*, i8** %3
%19 = load i8*, i8** %4
%20 = call i32 @strcpy(i8* %18, i8* %19)
store i32 0, i32* %2
br label %57
21: ; preds = %1
%22 = load i8*, i8** %3
%23 = call i8* @strstr(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %28
26: ; preds = %21
%27 = load i8*, i8** %3
store i8* %27, i8** %4
br label %38
28: ; preds = %21
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
%31 = load i8*, i8** %4
%32 = call i8* @strstr(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %32, i8** %5
%33 = load i8*, i8** %5
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %28
%36 = load i8*, i8** %5
store i8 0, i8* %36
br label %37
37: ; preds = %35, %28
br label %38
38: ; preds = %37, %26
%39 = load i8*, i8** %4
%40 = call i8* @strstr(i8* %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%41 = icmp ne i8* %40, null
br i1 %41, label %46, label %42
42: ; preds = %38
%43 = load i8*, i8** %4
%44 = call i8* @strstr(i8* %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %53
46: ; preds = %42, %38
%47 = load i8*, i8** %4
%48 = call i8* @strstr(i8* %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %48, i8** %6
%49 = load i8*, i8** %6
store i8 0, i8* %49
%50 = load i8*, i8** %3
%51 = load i8*, i8** %4
%52 = call i32 @strcpy(i8* %50, i8* %51)
store i32 0, i32* %2
br label %57
53: ; preds = %42
%54 = load i8*, i8** %3
%55 = load i8*, i8** %4
%56 = call i32 @strcpy(i8* %54, i8* %55)
store i32 1, i32* %2
br label %57
57: ; preds = %53, %46, %17
%58 = load i32, i32* %2
ret i32 %58
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c" (\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.5 = [11 x i8] c"@nkbbs.org\00"
@.str.6 = [11 x i8] c"@localhost\00"
define i32 @getsender(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 64)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* %5
br label %25
8: ; preds = %1
%9 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 60)
%10 = icmp eq i8* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = tail call i8* @strchr(i8* %12, i32 62)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %11
store i8 0, i8* %13
br label %16
16: ; preds = %11, %15, %8
%17 = phi i8* [ %0, %8 ], [ %12, %15 ], [ %12, %11 ]
%18 = tail call i8* @strstr(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = tail call i8* @strstr(i8* dereferenceable(1) %17, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %25, label %23
23: ; preds = %20, %16
%24 = tail call i8* @strchr(i8* dereferenceable(1) %17, i32 64)
store i8 0, i8* %24
br label %25
25: ; preds = %20, %23, %4
%26 = phi i8* [ %17, %23 ], [ %7, %4 ], [ %17, %20 ]
%27 = phi i32 [ 0, %23 ], [ 0, %4 ], [ 1, %20 ]
%28 = tail call i32 @strcpy(i8* %0, i8* %26)
ret i32 %27
}