#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 */
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *getMailserver(char *);
scalar_t__ getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ smtp_parseResponse(int, int);
int /*<<< orphan*/ smtp_sendData(int);
int /*<<< orphan*/ smtp_sendDataRequest(int);
int /*<<< orphan*/ smtp_sendFrom(int, char *);
int /*<<< orphan*/ smtp_sendGreeting(int);
int /*<<< orphan*/ smtp_sendRecipient(int, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  int sfd;
  char *mailserver, *domain, *rcpt, *from;
  struct addrinfo hints;
  struct addrinfo *result;
  if (argc != 3) {
    fprintf(stderr, "USAGE: %s FROM RECIPIENT\n", argv[0]);
    return EXIT_FAILURE;
  }
  from = argv[1];
  rcpt = argv[2];
  domain = strrchr(rcpt, '@');
  if (domain == NULL) {
    fprintf(stderr, "%s: incorrect recipient mail address\n", argv[0]);
    return EXIT_FAILURE;
  }
  domain++;
  mailserver = getMailserver(domain);
  if (mailserver == NULL) {
    fprintf(stderr, "%s: couldn't get mailserver for recipient address\n",
            argv[0]);
    mailserver = domain;
  }
  memset(&hints, 0, sizeof(struct addrinfo));
  hints.ai_socktype = SOCK_STREAM;
  if (getaddrinfo(mailserver, "smtp", &hints, &result) != 0) {
    fprintf(stderr, "%s: non resolvable mail server address\n", argv[0]);
    return EXIT_FAILURE;
  }
  if ((sfd = socket(result->ai_family, result->ai_socktype,
                    result->ai_protocol)) == -1) {
    fprintf(stderr, "%s: couldn't open socket\n", argv[0]);
    return EXIT_FAILURE;
  }
  if (connect(sfd, result->ai_addr, result->ai_addrlen) == -1) {
    fprintf(stderr, "%s: couldn't connect to mail exchange\n", argv[0]);
    return EXIT_FAILURE;
  }
  smtp_parseResponse(sfd, 1);
  smtp_sendGreeting(sfd);
  smtp_parseResponse(sfd, 0);
  smtp_sendFrom(sfd, from);
  smtp_parseResponse(sfd, 0);
  smtp_sendRecipient(sfd, rcpt);
  smtp_parseResponse(sfd, 0);
  smtp_sendDataRequest(sfd);
  smtp_parseResponse(sfd, 0);
  smtp_sendData(sfd);
  smtp_parseResponse(sfd, 1);
  close(sfd);
  if (mailserver != domain) {
    free(mailserver);
  }
  freeaddrinfo(result);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     124d <main+0x4d>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc9(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14a6 <main+0x2a6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    $0x40,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12af <main+0xaf>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd81(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14a6 <main+0x2a6>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <getMailserver@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12f7 <main+0xf7>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd56(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
mov    0x2cca(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd55(%rip),%rsi
lea    -0x50(%rbp),%rdx
lea    -0x58(%rbp),%rcx
call   1100 <getaddrinfo@plt>
cmp    $0x0,%rax
je     1362 <main+0x162>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd2c(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2c78(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14a6 <main+0x2a6>
mov    -0x58(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x58(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    13b5 <main+0x1b5>
mov    0x2c51(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd01(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2c25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14a6 <main+0x2a6>
mov    -0x14(%rbp),%edi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x58(%rbp),%rax
mov    (%rax),%edx
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1400 <main+0x200>
mov    0x2c06(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xcd0(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    14a6 <main+0x2a6>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
call   1030 <smtp_sendGreeting@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   10c0 <smtp_sendFrom@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
call   1060 <smtp_sendRecipient@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
call   10e0 <smtp_sendDataRequest@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
call   10d0 <smtp_sendData@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <smtp_parseResponse@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1491 <main+0x291>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x58(%rbp),%rdi
call   1110 <freeaddrinfo@plt>
mov    0x2b27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    12bc <main+0xbc>
mov    0x8(%rbx),%r13
mov    0x10(%rbx),%r15
mov    %r15,%rdi
mov    $0x40,%esi
call   1070 <strrchr@plt>
test   %rax,%rax
je     12d1 <main+0xd1>
mov    %rax,%r12
add    $0x1,%r12
mov    %r12,%rdi
call   1080 <getMailserver@plt>
mov    %rax,%r14
test   %rax,%rax
jne    126a <main+0x6a>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdde(%rip),%rsi
call   10b0 <fprintf@plt>
mov    %r12,%r14
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1090 <memset@plt>
mov    0x2d53(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
lea    0xde1(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %r14,%rdi
mov    %rbp,%rdx
call   1100 <getaddrinfo@plt>
test   %rax,%rax
je     1301 <main+0x101>
mov    0x2d32(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdbe(%rip),%rsi
jmp    12e4 <main+0xe4>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd31(%rip),%rsi
jmp    12e4 <main+0xe4>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd36(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2ce0(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   1120 <socket@plt>
cmp    $0xffffffff,%eax
je     13c8 <main+0x1c8>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebp,%edi
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
je     13e0 <main+0x1e0>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
call   1030 <smtp_sendGreeting@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
mov    %r13,%rsi
call   10c0 <smtp_sendFrom@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
mov    %r15,%rsi
call   1060 <smtp_sendRecipient@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
call   10e0 <smtp_sendDataRequest@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
call   10d0 <smtp_sendData@plt>
mov    %ebp,%edi
mov    $0x1,%esi
call   1050 <smtp_parseResponse@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
cmp    %r12,%r14
je     13b2 <main+0x1b2>
mov    %r14,%rdi
call   1040 <free@plt>
mov    0x8(%rsp),%rdi
call   1110 <freeaddrinfo@plt>
mov    0x2c05(%rip),%rax
jmp    12f0 <main+0xf0>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xcc5(%rip),%rsi
jmp    12e4 <main+0xe4>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xcc7(%rip),%rsi
jmp    12e4 <main+0xe4>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [26 x i8] c"USAGE: %s FROM RECIPIENT\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [38 x i8] c"%s: incorrect recipient mail address\0A\00"
@.str.2 = [51 x i8] c"%s: couldn't get mailserver for recipient address\0A\00"
@SOCK_STREAM = global i32 0
@.str.3 = [5 x i8] c"smtp\00"
@.str.4 = [40 x i8] c"%s: non resolvable mail server address\0A\00"
@.str.5 = [26 x i8] c"%s: couldn't open socket\0A\00"
@.str.6 = [39 x i8] c"%s: couldn't connect to mail exchange\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca %struct.addrinfo
%12 = alloca %struct.addrinfo*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %22
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %141
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %10
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
store i8* %28, i8** %9
%29 = load i8*, i8** %9
%30 = call i8* @strrchr(i8* %29, i8 signext 64)
store i8* %30, i8** %8
%31 = load i8*, i8** %8
%32 = icmp eq i8* %31, null
br i1 %32, label %33, label %40
33: ; preds = %22
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = load i32, i32* @EXIT_FAILURE
store i32 %39, i32* %3
br label %141
40: ; preds = %22
%41 = load i8*, i8** %8
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %8
%43 = load i8*, i8** %8
%44 = call i8* @getMailserver(i8* %43)
store i8* %44, i8** %7
%45 = load i8*, i8** %7
%46 = icmp eq i8* %45, null
br i1 %46, label %47, label %54
47: ; preds = %40
%48 = load i32, i32* @stderr
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %51)
%53 = load i8*, i8** %8
store i8* %53, i8** %7
br label %54
54: ; preds = %47, %40
%55 = call i32 @memset(%struct.addrinfo* %11, i32 0, i32 20)
%56 = load i32, i32* @SOCK_STREAM
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i32 0, i32 3
store i32 %56, i32* %57
%58 = load i8*, i8** %7
%59 = call i64 @getaddrinfo(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %struct.addrinfo* %11, %struct.addrinfo** %12)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %54
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %65)
%67 = load i32, i32* @EXIT_FAILURE
store i32 %67, i32* %3
br label %141
68: ; preds = %54
%69 = load %struct.addrinfo*, %struct.addrinfo** %12
%70 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %69, i32 0, i32 4
%71 = load i32, i32* %70
%72 = load %struct.addrinfo*, %struct.addrinfo** %12
%73 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %72, i32 0, i32 3
%74 = load i32, i32* %73
%75 = load %struct.addrinfo*, %struct.addrinfo** %12
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i32 0, i32 2
%77 = load i32, i32* %76
%78 = call i32 @socket(i32 %71, i32 %74, i32 %77)
store i32 %78, i32* %6
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %87
80: ; preds = %68
%81 = load i32, i32* @stderr
%82 = load i8**, i8*** %5
%83 = getelementptr inbounds i8*, i8** %82, i64 0
%84 = load i8*, i8** %83
%85 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %84)
%86 = load i32, i32* @EXIT_FAILURE
store i32 %86, i32* %3
br label %141
87: ; preds = %68
%88 = load i32, i32* %6
%89 = load %struct.addrinfo*, %struct.addrinfo** %12
%90 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %89, i32 0, i32 1
%91 = load i32, i32* %90
%92 = load %struct.addrinfo*, %struct.addrinfo** %12
%93 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i32 @connect(i32 %88, i32 %91, i32 %94)
%96 = icmp eq i32 %95, -1
br i1 %96, label %97, label %104
97: ; preds = %87
%98 = load i32, i32* @stderr
%99 = load i8**, i8*** %5
%100 = getelementptr inbounds i8*, i8** %99, i64 0
%101 = load i8*, i8** %100
%102 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %101)
%103 = load i32, i32* @EXIT_FAILURE
store i32 %103, i32* %3
br label %141
104: ; preds = %87
%105 = load i32, i32* %6
%106 = call i32 @smtp_parseResponse(i32 %105, i32 1)
%107 = load i32, i32* %6
%108 = call i32 @smtp_sendGreeting(i32 %107)
%109 = load i32, i32* %6
%110 = call i32 @smtp_parseResponse(i32 %109, i32 0)
%111 = load i32, i32* %6
%112 = load i8*, i8** %10
%113 = call i32 @smtp_sendFrom(i32 %111, i8* %112)
%114 = load i32, i32* %6
%115 = call i32 @smtp_parseResponse(i32 %114, i32 0)
%116 = load i32, i32* %6
%117 = load i8*, i8** %9
%118 = call i32 @smtp_sendRecipient(i32 %116, i8* %117)
%119 = load i32, i32* %6
%120 = call i32 @smtp_parseResponse(i32 %119, i32 0)
%121 = load i32, i32* %6
%122 = call i32 @smtp_sendDataRequest(i32 %121)
%123 = load i32, i32* %6
%124 = call i32 @smtp_parseResponse(i32 %123, i32 0)
%125 = load i32, i32* %6
%126 = call i32 @smtp_sendData(i32 %125)
%127 = load i32, i32* %6
%128 = call i32 @smtp_parseResponse(i32 %127, i32 1)
%129 = load i32, i32* %6
%130 = call i32 @close(i32 %129)
%131 = load i8*, i8** %7
%132 = load i8*, i8** %8
%133 = icmp ne i8* %131, %132
br i1 %133, label %134, label %137
134: ; preds = %104
%135 = load i8*, i8** %7
%136 = call i32 @free(i8* %135)
br label %137
137: ; preds = %134, %104
%138 = load %struct.addrinfo*, %struct.addrinfo** %12
%139 = call i32 @freeaddrinfo(%struct.addrinfo* %138)
%140 = load i32, i32* @EXIT_SUCCESS
store i32 %140, i32* %3
br label %141
141: ; preds = %137, %97, %80, %61, %33, %15
%142 = load i32, i32* %3
ret i32 %142
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [26 x i8] c"USAGE: %s FROM RECIPIENT\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [38 x i8] c"%s: incorrect recipient mail address\0A\00"
@.str.2 = [51 x i8] c"%s: couldn't get mailserver for recipient address\0A\00"
@SOCK_STREAM = global i32 0
@.str.3 = [5 x i8] c"smtp\00"
@.str.4 = [40 x i8] c"%s: non resolvable mail server address\0A\00"
@.str.5 = [26 x i8] c"%s: couldn't open socket\0A\00"
@.str.6 = [39 x i8] c"%s: couldn't connect to mail exchange\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.addrinfo
%4 = alloca %struct.addrinfo*
%5 = bitcast %struct.addrinfo* %3 to i8*
%6 = bitcast %struct.addrinfo** %4 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %87
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i8* @strrchr(i8* dereferenceable(1) %16, i8 signext 64)
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %23
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %87
23: ; preds = %12
%24 = getelementptr inbounds i8, i8* %17, i64 1
%25 = tail call i8* @getMailserver(i8* %24)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %1
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %23
%32 = phi i8* [ %24, %27 ], [ %25, %23 ]
%33 = call i32 @memset(%struct.addrinfo* %3, i32 0, i32 20)
%34 = load i32, i32* @SOCK_STREAM
%35 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %3, i64 0, i32 3
store i32 %34, i32* %35
%36 = call i64 @getaddrinfo(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %struct.addrinfo* %3, %struct.addrinfo** %4)
%37 = icmp eq i64 %36, 0
br i1 %37, label %42, label %38
38: ; preds = %31
%39 = load i32, i32* @stderr
%40 = load i8*, i8** %1
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i8* %40)
br label %87
42: ; preds = %31
%43 = load %struct.addrinfo*, %struct.addrinfo** %4
%44 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 4
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 3
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %43, i64 0, i32 2
%49 = load i32, i32* %48
%50 = call i32 @socket(i32 %45, i32 %47, i32 %49)
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %56
52: ; preds = %42
%53 = load i32, i32* @stderr
%54 = load i8*, i8** %1
%55 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %54)
br label %87
56: ; preds = %42
%57 = load %struct.addrinfo*, %struct.addrinfo** %4
%58 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i64 0, i32 1
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %57, i64 0, i32 0
%61 = load i32, i32* %60
%62 = call i32 @connect(i32 %50, i32 %59, i32 %61)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %68
64: ; preds = %56
%65 = load i32, i32* @stderr
%66 = load i8*, i8** %1
%67 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %66)
br label %87
68: ; preds = %56
%69 = call i32 @smtp_parseResponse(i32 %50, i32 1)
%70 = call i32 @smtp_sendGreeting(i32 %50)
%71 = call i32 @smtp_parseResponse(i32 %50, i32 0)
%72 = call i32 @smtp_sendFrom(i32 %50, i8* %14)
%73 = call i32 @smtp_parseResponse(i32 %50, i32 0)
%74 = call i32 @smtp_sendRecipient(i32 %50, i8* %16)
%75 = call i32 @smtp_parseResponse(i32 %50, i32 0)
%76 = call i32 @smtp_sendDataRequest(i32 %50)
%77 = call i32 @smtp_parseResponse(i32 %50, i32 0)
%78 = call i32 @smtp_sendData(i32 %50)
%79 = call i32 @smtp_parseResponse(i32 %50, i32 1)
%80 = call i32 @close(i32 %50)
%81 = icmp eq i8* %32, %24
br i1 %81, label %84, label %82
82: ; preds = %68
%83 = call i32 @free(i8* %32)
br label %84
84: ; preds = %82, %68
%85 = load %struct.addrinfo*, %struct.addrinfo** %4
%86 = call i32 @freeaddrinfo(%struct.addrinfo* %85)
br label %87
87: ; preds = %84, %64, %52, %38, %19, %8
%88 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_FAILURE, %19 ], [ @EXIT_FAILURE, %38 ], [ @EXIT_FAILURE, %52 ], [ @EXIT_FAILURE, %64 ], [ @EXIT_SUCCESS, %84 ]
%89 = load i32, i32* %88
ret i32 %89
}