#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__ isalnum(char);
int strlen(char *);
int valididateEmailAddress(char *email) {
  if (!email)
    return 0;
  int at_sign = 0;
  int i;
  for (i = 0; i < strlen(email); i++) {
    if (email[i] == '@')
      at_sign++;
    else if (!(isalnum(email[i]) || email[i] == '.' || email[i] == '_' ||
               email[i] == '-'))
      return 0;
  }
  return at_sign == 1;
}


x86 assembly (clang, -O0):
<valididateEmailAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <valididateEmailAddress+0x23>
movl   $0x0,-0x4(%rbp)
jmp    121d <valididateEmailAddress+0xfd>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    120e <valididateEmailAddress+0xee>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x40,%eax
jne    1190 <valididateEmailAddress+0x70>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11fb <valididateEmailAddress+0xdb>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%rax
jne    11f6 <valididateEmailAddress+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     11f6 <valididateEmailAddress+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11f6 <valididateEmailAddress+0xd6>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11f6 <valididateEmailAddress+0xd6>
movl   $0x0,-0x4(%rbp)
jmp    121d <valididateEmailAddress+0xfd>
jmp    11fb <valididateEmailAddress+0xdb>
jmp    1200 <valididateEmailAddress+0xe0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <valididateEmailAddress+0x31>
cmpl   $0x1,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<valididateEmailAddress>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     118f <valididateEmailAddress+0x6f>
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    1193 <valididateEmailAddress+0x73>
xor    %ebp,%ebp
movabs $0x4000000000003,%r15
xor    %r14d,%r14d
jmp    1167 <valididateEmailAddress+0x47>
nopl   0x0(%rax)
add    $0x1,%r14d
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jge    1196 <valididateEmailAddress+0x76>
movzbl (%rbx,%rbp,1),%eax
cmp    $0x40,%al
je     1150 <valididateEmailAddress+0x30>
movsbl %al,%edi
call   1040 <isalnum@plt>
test   %rax,%rax
jne    1154 <valididateEmailAddress+0x34>
movzbl (%rbx,%rbp,1),%eax
add    $0xd3,%al
cmp    $0x32,%al
ja     118f <valididateEmailAddress+0x6f>
movzbl %al,%eax
bt     %rax,%r15
jb     1154 <valididateEmailAddress+0x34>
xor    %eax,%eax
jmp    119f <valididateEmailAddress+0x7f>
xor    %r14d,%r14d
xor    %eax,%eax
cmp    $0x1,%r14d
sete   %al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @valididateEmailAddress(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %68
9: ; preds = %1
store i32 0, i32* %4
store i32 0, i32* %5
br label %10
10: ; preds = %61, %9
%11 = load i32, i32* %5
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %64
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 64
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %60
26: ; preds = %15
%27 = load i8*, i8** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = call i64 @isalnum(i8 signext %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %59, label %34
34: ; preds = %26
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 46
br i1 %41, label %59, label %42
42: ; preds = %34
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 95
br i1 %49, label %59, label %50
50: ; preds = %42
%51 = load i8*, i8** %3
%52 = load i32, i32* %5
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 45
br i1 %57, label %59, label %58
58: ; preds = %50
store i32 0, i32* %2
br label %68
59: ; preds = %50, %42, %34, %26
br label %60
60: ; preds = %59, %23
br label %61
61: ; preds = %60
%62 = load i32, i32* %5
%63 = add nsw i32 %62, 1
store i32 %63, i32* %5
br label %10
64: ; preds = %10
%65 = load i32, i32* %4
%66 = icmp eq i32 %65, 1
%67 = zext i1 %66 to i32
store i32 %67, i32* %2
br label %68
68: ; preds = %64, %58, %8
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
define i32 @valididateEmailAddress(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %29, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %25
6: ; preds = %3, %19
%7 = phi i64 [ %21, %19 ], [ 0, %3 ]
%8 = phi i32 [ %20, %19 ], [ 0, %3 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 64
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = add nsw i32 %8, 1
br label %19
14: ; preds = %6
%15 = tail call i64 @isalnum(i8 signext %10)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = load i8, i8* %9
switch i8 %18, label %29 [
i8 46, label %19
i8 95, label %19
i8 45, label %19
]
19: ; preds = %17, %17, %17, %12, %14
%20 = phi i32 [ %13, %12 ], [ %8, %14 ], [ %8, %17 ], [ %8, %17 ], [ %8, %17 ]
%21 = add nuw nsw i64 %7, 1
%22 = tail call i32 @strlen(i8* %0)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %6, label %25
25: ; preds = %19, %3
%26 = phi i32 [ 0, %3 ], [ %20, %19 ]
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
br label %29
29: ; preds = %17, %25, %1
%30 = phi i32 [ 0, %1 ], [ %28, %25 ], [ 0, %17 ]
ret i32 %30
}