#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*/ free(char *);
char *strdup(char const *);
char *strstr(char *, char *);
int RemoveHotmail(const char *src, char **dst) {
  char *temp;
  char *ptr;
  *dst = NULL;
  if (src == NULL)
    return -1;
  temp = strdup(src);
  ptr = strstr(temp, "@hotmail.com");
  if (ptr == NULL)
    *dst = strdup(src);
  else {
    *ptr = '\0';
    *dst = strdup(temp);
  }
  free(temp);
  return 0;
}


x86 assembly (clang, -O0):
<RemoveHotmail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    1162 <RemoveHotmail+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d0 <RemoveHotmail+0xa0>
mov    -0x10(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe86(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a6 <RemoveHotmail+0x76>
mov    -0x10(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11c0 <RemoveHotmail+0x90>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RemoveHotmail>:
push   %r15
push   %r14
push   %rbx
movq   $0x0,(%rsi)
test   %rdi,%rdi
je     116b <RemoveHotmail+0x3b>
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strdup@plt>
mov    %rax,%r14
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1050 <strstr@plt>
test   %rax,%rax
je     1172 <RemoveHotmail+0x42>
movb   $0x0,(%rax)
mov    %r14,%rdi
jmp    1175 <RemoveHotmail+0x45>
mov    $0xffffffff,%eax
jmp    1187 <RemoveHotmail+0x57>
mov    %rbx,%rdi
call   1040 <strdup@plt>
mov    %rax,(%r15)
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [13 x i8] c"@hotmail.com\00"
define i32 @RemoveHotmail(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
store i8* null, i8** %8
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %31
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i8* @strdup(i8* %13)
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = call i8* @strstr(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = call i8* @strdup(i8* %20)
%22 = load i8**, i8*** %5
store i8* %21, i8** %22
br label %28
23: ; preds = %12
%24 = load i8*, i8** %7
store i8 0, i8* %24
%25 = load i8*, i8** %6
%26 = call i8* @strdup(i8* %25)
%27 = load i8**, i8*** %5
store i8* %26, i8** %27
br label %28
28: ; preds = %23, %19
%29 = load i8*, i8** %6
%30 = call i32 @free(i8* %29)
store i32 0, i32* %3
br label %31
31: ; preds = %28, %11
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@.str = [13 x i8] c"@hotmail.com\00"
define i32 @RemoveHotmail(i8* %0, i8** nocapture writeonly %1) {
store i8* null, i8** %1
%3 = icmp eq i8* %0, null
br i1 %3, label %15, label %4
4: ; preds = %2
%5 = tail call i8* @strdup(i8* %0)
%6 = tail call i8* @strstr(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i8* @strdup(i8* %0)
br label %12
10: ; preds = %4
store i8 0, i8* %6
%11 = tail call i8* @strdup(i8* %5)
br label %12
12: ; preds = %10, %8
%13 = phi i8* [ %11, %10 ], [ %9, %8 ]
store i8* %13, i8** %1
%14 = tail call i32 @free(i8* %5)
br label %15
15: ; preds = %2, %12
%16 = phi i32 [ 0, %12 ], [ -1, %2 ]
ret i32 %16
}