#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*/ assert(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
scalar_t__ valid_email(char *);
void test_email() {
  char email_address[512];
  printf("test_email...");
  sprintf(email_address, "%s", "Bob <user@domainname.com>");
  assert(valid_email(email_address) != 0);
  sprintf(email_address, "%s", "Bob<user@domainname.com>");
  assert(valid_email(email_address) == 0);
  sprintf(email_address, "%s", "Bob <user@domainname>");
  assert(valid_email(email_address) == 0);
  sprintf(email_address, "%s", "user@domainname.com");
  assert(valid_email(email_address) == 0);
  sprintf(email_address, "%s", "user");
  assert(valid_email(email_address) == 0);
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_email>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200,%rsp
lea    0xeae(%rip),%rdi
call   1040 <printf@plt>
lea    -0x200(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    0xea5(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <valid_email@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe72(%rip),%rsi
lea    0xe88(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <valid_email@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe3b(%rip),%rsi
lea    0xe6a(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <valid_email@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xe04(%rip),%rsi
lea    0xe49(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <valid_email@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    -0x200(%rbp),%rdi
lea    0xdcd(%rip),%rsi
lea    0xe26(%rip),%rdx
call   1060 <sprintf@plt>
lea    -0x200(%rbp),%rdi
call   1030 <valid_email@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe02(%rip),%rdi
call   1040 <printf@plt>
add    $0x200,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_email>:
push   %rbx
sub    $0x200,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
movups 0xeb3(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xeb2(%rip),%xmm0
movups %xmm0,0xa(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <valid_email@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
movups 0xe9d(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xe9b(%rip),%xmm0
movups %xmm0,0x9(%rsp)
mov    %rbx,%rdi
call   1040 <valid_email@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
movabs $0x3e656d616e6e69,%rax
mov    %rax,0xe(%rsp)
movups 0xe7a(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rbx,%rdi
call   1040 <valid_email@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
movups 0xe6f(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x6d6f63,0x10(%rsp)
mov    %rbx,%rdi
call   1040 <valid_email@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
movl   $0x72657375,(%rsp)
movb   $0x0,0x4(%rsp)
mov    %rbx,%rdi
call   1040 <valid_email@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1060 <assert@plt>
lea    0xe3d(%rip),%rdi
call   1030 <puts@plt>
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"test_email...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"Bob <user@domainname.com>\00"
@.str.3 = [25 x i8] c"Bob<user@domainname.com>\00"
@.str.4 = [22 x i8] c"Bob <user@domainname>\00"
@.str.5 = [20 x i8] c"user@domainname.com\00"
@.str.6 = [5 x i8] c"user\00"
@.str.7 = [4 x i8] c"Ok\0A\00"
define void @test_email() {
%1 = alloca [512 x i8]
%2 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%4 = call i32 @sprintf(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%6 = call i64 @valid_email(i8* %5)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%13 = call i64 @valid_email(i8* %12)
%14 = icmp eq i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%18 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%20 = call i64 @valid_email(i8* %19)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%25 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%27 = call i64 @valid_email(i8* %26)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%32 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%34 = call i64 @valid_email(i8* %33)
%35 = icmp eq i64 %34, 0
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"test_email...\00"
@.str.2 = [26 x i8] c"Bob <user@domainname.com>\00"
@.str.3 = [25 x i8] c"Bob<user@domainname.com>\00"
@.str.4 = [22 x i8] c"Bob <user@domainname>\00"
@.str.5 = [20 x i8] c"user@domainname.com\00"
@.str.6 = [5 x i8] c"user\00"
@str = [3 x i8] c"Ok\00"
define void @test_email() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = call i64 @valid_email(i8* %2)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = call i64 @valid_email(i8* %2)
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i64 @valid_email(i8* %2)
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i64 @valid_email(i8* %2)
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i64 @valid_email(i8* %2)
%21 = icmp eq i64 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}