#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*/ fatal(int /*<<< orphan*/);
int /*<<< orphan*/ lp_from_address();
int smtp_end_mail(int);
int /*<<< orphan*/ smtp_error();
int smtp_start_mail(char *, char *, char *, char *, char *, scalar_t__);
int /*<<< orphan*/ smtp_write(int, char *, ...);
int /*<<< orphan*/ smtp_write_data(int, char *);
scalar_t__ strlen(char *);
void send_mail(char *from, char *to, char *cc, char *bcc, char *subject,
               char *body, char *sig) {
  int fd;
  fd = smtp_start_mail(from, to, cc, bcc, subject, strlen(body) + 2000);
  if (fd == -1)
    fatal(smtp_error());
  if (subject) {
    smtp_write(fd, "X-Loop: %s\n", lp_from_address());
    smtp_write(fd, "\n");
  }
  smtp_write_data(fd, body);
  if (sig)
    smtp_write_data(fd, sig);
  if (smtp_end_mail(fd) == -1)
    fatal(smtp_error());
}


x86 assembly (clang, -O0):
<send_mail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    -0x40(%rbp),%r8
mov    %rax,%r9
add    $0x7d0,%r9
call   1090 <smtp_start_mail@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1213 <send_mail+0x93>
mov    $0x0,%al
call   1030 <smtp_error@plt>
mov    %eax,%edi
call   10a0 <fatal@plt>
cmpq   $0x0,-0x28(%rbp)
je     124f <send_mail+0xcf>
mov    -0x34(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    $0x0,%al
call   1040 <lp_from_address@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%edx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1050 <smtp_write@plt>
mov    -0x34(%rbp),%edi
lea    0xdc2(%rip),%rsi
mov    $0x0,%al
call   1050 <smtp_write@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1070 <smtp_write_data@plt>
cmpq   $0x0,0x10(%rbp)
je     1272 <send_mail+0xf2>
mov    -0x34(%rbp),%edi
mov    0x10(%rbp),%rsi
call   1070 <smtp_write_data@plt>
mov    -0x34(%rbp),%edi
call   1080 <smtp_end_mail@plt>
cmp    $0xffffffff,%eax
jne    1291 <send_mail+0x111>
mov    $0x0,%al
call   1030 <smtp_error@plt>
mov    %eax,%edi
call   10a0 <fatal@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_mail>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,%r14
mov    0x40(%rsp),%rax
mov    %rax,(%rsp)
mov    %r9,%rdi
call   1060 <strlen@plt>
lea    0x7d0(%rax),%r9
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r12,%r8
call   1090 <smtp_start_mail@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1233 <send_mail+0xb3>
test   %r12,%r12
je     11fe <send_mail+0x7e>
xor    %eax,%eax
call   1040 <lp_from_address@plt>
lea    0xe1d(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <smtp_write@plt>
lea    0xe15(%rip),%rsi
mov    %ebp,%edi
xor    %eax,%eax
call   1050 <smtp_write@plt>
mov    %ebp,%edi
mov    %r15,%rsi
call   1070 <smtp_write_data@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     1218 <send_mail+0x98>
mov    %ebp,%edi
call   1070 <smtp_write_data@plt>
mov    %ebp,%edi
call   1080 <smtp_end_mail@plt>
cmp    $0xffffffff,%eax
je     1248 <send_mail+0xc8>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1030 <smtp_error@plt>
mov    %eax,%edi
call   10a0 <fatal@plt>
test   %r12,%r12
jne    11d5 <send_mail+0x55>
jmp    11fe <send_mail+0x7e>
xor    %eax,%eax
call   1030 <smtp_error@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <fatal@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"X-Loop: %s\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @send_mail(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
store i8* %6, i8** %14
%16 = load i8*, i8** %8
%17 = load i8*, i8** %9
%18 = load i8*, i8** %10
%19 = load i8*, i8** %11
%20 = load i8*, i8** %12
%21 = load i8*, i8** %13
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %22, 2000
%24 = call i32 @smtp_start_mail(i8* %16, i8* %17, i8* %18, i8* %19, i8* %20, i64 %23)
store i32 %24, i32* %15
%25 = load i32, i32* %15
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %7
%28 = call i32 (...) @smtp_error()
%29 = call i32 @fatal(i32 %28)
br label %30
30: ; preds = %27, %7
%31 = load i8*, i8** %12
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %39
33: ; preds = %30
%34 = load i32, i32* %15
%35 = call i32 (...) @lp_from_address()
%36 = call i32 (i32, i8*, ...) @smtp_write(i32 %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %15
%38 = call i32 (i32, i8*, ...) @smtp_write(i32 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %33, %30
%40 = load i32, i32* %15
%41 = load i8*, i8** %13
%42 = call i32 @smtp_write_data(i32 %40, i8* %41)
%43 = load i8*, i8** %14
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %49
45: ; preds = %39
%46 = load i32, i32* %15
%47 = load i8*, i8** %14
%48 = call i32 @smtp_write_data(i32 %46, i8* %47)
br label %49
49: ; preds = %45, %39
%50 = load i32, i32* %15
%51 = call i32 @smtp_end_mail(i32 %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 (...) @smtp_error()
%55 = call i32 @fatal(i32 %54)
br label %56
56: ; preds = %53, %49
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"X-Loop: %s\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @send_mail(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6) {
%8 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%9 = add nsw i64 %8, 2000
%10 = tail call i32 @smtp_start_mail(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i64 %9)
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = tail call i32 (...) @smtp_error()
%14 = tail call i32 @fatal(i32 %13)
br label %15
15: ; preds = %12, %7
%16 = icmp eq i8* %4, null
br i1 %16, label %21, label %17
17: ; preds = %15
%18 = tail call i32 (...) @lp_from_address()
%19 = tail call i32 (i32, i8*, ...) @smtp_write(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = tail call i32 (i32, i8*, ...) @smtp_write(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %17, %15
%22 = tail call i32 @smtp_write_data(i32 %10, i8* %5)
%23 = icmp eq i8* %6, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @smtp_write_data(i32 %10, i8* %6)
br label %26
26: ; preds = %24, %21
%27 = tail call i32 @smtp_end_mail(i32 %10)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = tail call i32 (...) @smtp_error()
%31 = tail call i32 @fatal(i32 %30)
br label %32
32: ; preds = %29, %26
ret void
}