#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 */
scalar_t__ malloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
int /*<<< orphan*/ *strchr(char const *, char);
char *strdup(char const *);
scalar_t__ strlen(char const *);
int AddHotmail(const char *src, char **dst) {
  *dst = NULL;
  if (src == NULL)
    return -1;
  if (strchr(src, '@') == NULL) {
    *dst = (char *)malloc(strlen(src) + strlen("@hotmail.com") + 1);
    sprintf(*dst, "%s@hotmail.com", src);
  } else
    *dst = strdup(src);
  return 0;
}


x86 assembly (clang, -O0):
<AddHotmail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
jne    1182 <AddHotmail+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1203 <AddHotmail+0xb3>
mov    -0x10(%rbp),%rdi
mov    $0x40,%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
jne    11e9 <AddHotmail+0x99>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
lea    0xe54(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe21(%rip),%rsi
call   1060 <sprintf@plt>
jmp    11fc <AddHotmail+0xac>
mov    -0x10(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddHotmail>:
push   %r14
push   %rbx
push   %rax
movq   $0x0,(%rsi)
test   %rdi,%rdi
je     1182 <AddHotmail+0x32>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x40,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1189 <AddHotmail+0x39>
mov    %rbx,%rdi
call   1070 <strdup@plt>
mov    %rax,(%r14)
jmp    11af <AddHotmail+0x5f>
mov    $0xffffffff,%eax
jmp    11b1 <AddHotmail+0x61>
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xd(%rax),%rdi
call   1050 <malloc@plt>
mov    %rax,(%r14)
lea    0xe5c(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
call   1060 <sprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.1 = [15 x i8] c"%s@hotmail.com\00"
define i32 @AddHotmail(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 i32* @strchr(i8* %0, i8 signext 64)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %13
7: ; preds = %4
%8 = tail call i64 @strlen(i8* %0)
%9 = add nsw i64 %8, 13
%10 = tail call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %1
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %15
13: ; preds = %4
%14 = tail call i8* @strdup(i8* %0)
store i8* %14, i8** %1
br label %15
15: ; preds = %7, %13, %2
%16 = phi i32 [ -1, %2 ], [ 0, %13 ], [ 0, %7 ]
ret i32 %16
}