#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*/ sprintf(char *, char *, char *);
char *strdup(char *);
char *email_sendmail_string(char *from_address, char *to_address, char *subject,
                            char *message, char *reply_to,
                            char *self_full_name) {
  char sendmail_string[65536];
  char *ptr = sendmail_string;
  *ptr = '\0';
  if (to_address && *to_address) {
    ptr += sprintf(ptr, "To: %s\n", to_address);
  }
  if (from_address && *from_address) {
    ptr += sprintf(ptr, "Email: %s\n", from_address);
  }
  if (reply_to && *reply_to) {
    ptr += sprintf(ptr, "Reply-To: %s\n", reply_to);
  }
  if (subject && *subject) {
    ptr += sprintf(ptr, "Subject: %s\n", subject);
  }
  if (self_full_name && *self_full_name) {
    ptr += sprintf(ptr, "From: %s\n", self_full_name);
  }
  if (message && *message) {
    ptr += sprintf(ptr, "%s\n", message);
  }
  return strdup(sendmail_string);
}


x86 assembly (clang, -O0):
<email_sendmail_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
lea    -0x10030(%rbp),%rax
mov    %rax,-0x10038(%rbp)
mov    -0x10038(%rbp),%rax
movb   $0x0,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     11a3 <email_sendmail_string+0x83>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a3 <email_sendmail_string+0x83>
mov    -0x10038(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe89(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11eb <email_sendmail_string+0xcb>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11eb <email_sendmail_string+0xcb>
mov    -0x10038(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe30(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1233 <email_sendmail_string+0x113>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1233 <email_sendmail_string+0x113>
mov    -0x10038(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdf3(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     127b <email_sendmail_string+0x15b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     127b <email_sendmail_string+0x15b>
mov    -0x10038(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdb9(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12c3 <email_sendmail_string+0x1a3>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12c3 <email_sendmail_string+0x1a3>
mov    -0x10038(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd7e(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     130b <email_sendmail_string+0x1eb>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     130b <email_sendmail_string+0x1eb>
mov    -0x10038(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd17(%rip),%rsi
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x10038(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10038(%rbp)
lea    -0x10030(%rbp),%rdi
call   1040 <strdup@plt>
add    $0x10040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<email_sendmail_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10008,%rsp
mov    %r9,%r15
mov    %r8,%r13
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rdi,%rbp
mov    %rsp,%rbx
movb   $0x0,(%rsp)
test   %rsi,%rsi
je     1169 <email_sendmail_string+0x49>
mov    %rsi,%rdx
cmpb   $0x0,(%rsi)
je     1169 <email_sendmail_string+0x49>
lea    0xeb6(%rip),%rsi
mov    %rsp,%rdi
call   1030 <sprintf@plt>
cltq
lea    (%rsp,%rax,1),%rbx
test   %rbp,%rbp
je     118b <email_sendmail_string+0x6b>
cmpb   $0x0,0x0(%rbp)
je     118b <email_sendmail_string+0x6b>
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
test   %r13,%r13
je     11ae <email_sendmail_string+0x8e>
cmpb   $0x0,0x0(%r13)
je     11ae <email_sendmail_string+0x8e>
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
mov    %r13,%rdx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
test   %r12,%r12
je     11d1 <email_sendmail_string+0xb1>
cmpb   $0x0,(%r12)
je     11d1 <email_sendmail_string+0xb1>
lea    0xe58(%rip),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
test   %r15,%r15
je     11f3 <email_sendmail_string+0xd3>
cmpb   $0x0,(%r15)
je     11f3 <email_sendmail_string+0xd3>
lea    0xe43(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
test   %r14,%r14
je     1210 <email_sendmail_string+0xf0>
cmpb   $0x0,(%r14)
je     1210 <email_sendmail_string+0xf0>
lea    0xe02(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <sprintf@plt>
mov    %rsp,%rdi
call   1040 <strdup@plt>
add    $0x10008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"To: %s\0A\00"
@.str.1 = [11 x i8] c"Email: %s\0A\00"
@.str.2 = [14 x i8] c"Reply-To: %s\0A\00"
@.str.3 = [13 x i8] c"Subject: %s\0A\00"
@.str.4 = [10 x i8] c"From: %s\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i8* @email_sendmail_string(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca [65536 x i8]
%14 = alloca i8*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%15 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
store i8* %15, i8** %14
%16 = load i8*, i8** %14
store i8 0, i8* %16
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %31
19: ; preds = %6
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %19
%25 = load i8*, i8** %14
%26 = load i8*, i8** %8
%27 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %14
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %14
br label %31
31: ; preds = %24, %19, %6
%32 = load i8*, i8** %7
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %46
34: ; preds = %31
%35 = load i8*, i8** %7
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %34
%40 = load i8*, i8** %14
%41 = load i8*, i8** %7
%42 = call i32 @sprintf(i8* %40, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = load i8*, i8** %14
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i8, i8* %43, i64 %44
store i8* %45, i8** %14
br label %46
46: ; preds = %39, %34, %31
%47 = load i8*, i8** %11
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i8*, i8** %11
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %61
54: ; preds = %49
%55 = load i8*, i8** %14
%56 = load i8*, i8** %11
%57 = call i32 @sprintf(i8* %55, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %56)
%58 = load i8*, i8** %14
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds i8, i8* %58, i64 %59
store i8* %60, i8** %14
br label %61
61: ; preds = %54, %49, %46
%62 = load i8*, i8** %9
%63 = icmp ne i8* %62, null
br i1 %63, label %64, label %76
64: ; preds = %61
%65 = load i8*, i8** %9
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %76
69: ; preds = %64
%70 = load i8*, i8** %14
%71 = load i8*, i8** %9
%72 = call i32 @sprintf(i8* %70, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** %14
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds i8, i8* %73, i64 %74
store i8* %75, i8** %14
br label %76
76: ; preds = %69, %64, %61
%77 = load i8*, i8** %12
%78 = icmp ne i8* %77, null
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = load i8*, i8** %12
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %79
%85 = load i8*, i8** %14
%86 = load i8*, i8** %12
%87 = call i32 @sprintf(i8* %85, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %86)
%88 = load i8*, i8** %14
%89 = sext i32 %87 to i64
%90 = getelementptr inbounds i8, i8* %88, i64 %89
store i8* %90, i8** %14
br label %91
91: ; preds = %84, %79, %76
%92 = load i8*, i8** %10
%93 = icmp ne i8* %92, null
br i1 %93, label %94, label %106
94: ; preds = %91
%95 = load i8*, i8** %10
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %106
99: ; preds = %94
%100 = load i8*, i8** %14
%101 = load i8*, i8** %10
%102 = call i32 @sprintf(i8* %100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %101)
%103 = load i8*, i8** %14
%104 = sext i32 %102 to i64
%105 = getelementptr inbounds i8, i8* %103, i64 %104
store i8* %105, i8** %14
br label %106
106: ; preds = %99, %94, %91
%107 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
%108 = call i8* @strdup(i8* %107)
ret i8* %108
}

LLVM IR (-O2):
@.str = [8 x i8] c"To: %s\0A\00"
@.str.1 = [11 x i8] c"Email: %s\0A\00"
@.str.2 = [14 x i8] c"Reply-To: %s\0A\00"
@.str.3 = [13 x i8] c"Subject: %s\0A\00"
@.str.4 = [10 x i8] c"From: %s\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define noalias i8* @email_sendmail_string(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca [65536 x i8]
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 0
store i8 0, i8* %8
%9 = icmp eq i8* %1, null
br i1 %9, label %17, label %10
10: ; preds = %6
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [65536 x i8], [65536 x i8]* %7, i64 0, i64 %15
br label %17
17: ; preds = %13, %10, %6
%18 = phi i8* [ %16, %13 ], [ %8, %10 ], [ %8, %6 ]
%19 = icmp eq i8* %0, null
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = load i8, i8* %0
%22 = icmp eq i8 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = call i32 @sprintf(i8* dereferenceable(1) %18, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %18, i64 %25
br label %27
27: ; preds = %23, %20, %17
%28 = phi i8* [ %26, %23 ], [ %18, %20 ], [ %18, %17 ]
%29 = icmp eq i8* %4, null
br i1 %29, label %37, label %30
30: ; preds = %27
%31 = load i8, i8* %4
%32 = icmp eq i8 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %30
%34 = call i32 @sprintf(i8* dereferenceable(1) %28, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %28, i64 %35
br label %37
37: ; preds = %33, %30, %27
%38 = phi i8* [ %36, %33 ], [ %28, %30 ], [ %28, %27 ]
%39 = icmp eq i8* %2, null
br i1 %39, label %47, label %40
40: ; preds = %37
%41 = load i8, i8* %2
%42 = icmp eq i8 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %40
%44 = call i32 @sprintf(i8* dereferenceable(1) %38, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %38, i64 %45
br label %47
47: ; preds = %43, %40, %37
%48 = phi i8* [ %46, %43 ], [ %38, %40 ], [ %38, %37 ]
%49 = icmp eq i8* %5, null
br i1 %49, label %57, label %50
50: ; preds = %47
%51 = load i8, i8* %5
%52 = icmp eq i8 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %50
%54 = call i32 @sprintf(i8* dereferenceable(1) %48, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %48, i64 %55
br label %57
57: ; preds = %53, %50, %47
%58 = phi i8* [ %56, %53 ], [ %48, %50 ], [ %48, %47 ]
%59 = icmp eq i8* %3, null
br i1 %59, label %65, label %60
60: ; preds = %57
%61 = load i8, i8* %3
%62 = icmp eq i8 %61, 0
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = call i32 @sprintf(i8* dereferenceable(1) %58, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %3)
br label %65
65: ; preds = %63, %60, %57
%66 = call i8* @strdup(i8* %8)
ret i8* %66
}