#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 */
typedef int /*<<< orphan*/ encode_buf;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int base64_encode(char *, int, char *, int);
int /*<<< orphan*/ close(int);
int connect_MailServer();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_socket(int);
int /*<<< orphan*/ send_socket(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
int sendmail(const char *mailto, const char *subject, const char *content,
             const char *attachmentPath) {
  int sockfd = -1;
  char buf[4096] = {'\0'};
  char encode_buf[(((4096 + 2) / 3) * 4 + 1)] = {'\0'};
  FILE *fp = NULL;
  sockfd = connect_MailServer();
  if (sockfd == -1) {
    printf("failed to connect_MailServer\n");
    return -1;
  }
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "HELO %s\r\n", "freeswitch123@163.com");
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "AUTH LOGIN\r\n");
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  memset(encode_buf, 0, sizeof(encode_buf));
  base64_encode("freeswitch123@163.com", strlen("freeswitch123@163.com"),
                encode_buf, sizeof(encode_buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "%s\r\n", encode_buf);
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  memset(encode_buf, 0, sizeof(encode_buf));
  base64_encode("asd123", strlen("asd123"), encode_buf, sizeof(encode_buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "%s\r\n", encode_buf);
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "MAIL FROM <%s>\r\n", "freeswitch123@163.com");
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "RCPT TO <%s>\r\n", mailto);
  send_socket(sockfd, buf, strlen(buf));
  read_socket(sockfd);
  send_socket(sockfd, "DATA\r\n", strlen("DATA\r\n"));
  read_socket(sockfd);
  memset(buf, 0, sizeof(buf));
  sprintf(buf,
          "SUBJECT:%s\r\nMIME-VERSION: 1.0\r\nCONTENT-TYPE: "
          "MULTIPART/MIXED;BOUNDARY=\"#BOUNDARY#\"\r\n\r\n",
          subject);
  send_socket(sockfd, buf, strlen(buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf, "--#BOUNDARY#\r\nCONTENT-TYPE: TEXT/HTML\r\n\r\n%s\r\n\r\n",
          content);
  send_socket(sockfd, buf, strlen(buf));
  memset(buf, 0, sizeof(buf));
  sprintf(buf,
          "--#BOUNDARY#\r\nCONTENT-TYPE:APPLICATION/MSWORD; "
          "NAME=%s\r\nCONTENT-DISPOSITION: ATTACHMENT; "
          "FILENAME=%s\r\nCONTENT-TRANSFER-ENCODING:BASE64\r\n\r\n",
          attachmentPath, attachmentPath);
  send_socket(sockfd, buf, strlen(buf));
  fp = fopen(attachmentPath, "rb");
  if (NULL == fp) {
    perror("fopen");
    return -1;
  }
  fseek(fp, 0L, SEEK_END);
  int length = ftell(fp);
  fseek(fp, 0L, SEEK_SET);
  int count = 0L;
  int ret = 0;
  int tmp_ret;
  while (count < length) {
    ret = fread(buf, 1, 4096, fp);
    tmp_ret = base64_encode(buf, ret, encode_buf, (((4096 + 2) / 3) * 4 + 1));
    if (-1 == tmp_ret) {
      perror("base64_encode");
      return -1;
    }
    send_socket(sockfd, encode_buf, tmp_ret);
    count += ret;
  }
  fclose(fp);
  send_socket(sockfd, "\r\n.\r\n", -1);
  read_socket(sockfd);
  send_socket(sockfd, "QUIT\r\n", sizeof("QUIT\r\n"));
  read_socket(sockfd);
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<sendmail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2640,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x2590(%rbp),%rdi
xor    %esi,%esi
mov    $0x1559,%edx
call   1080 <memset@plt>
movq   $0x0,-0x2598(%rbp)
mov    $0x0,%al
call   10e0 <connect_MailServer@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    126f <sendmail+0x7f>
lea    0xda2(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1860 <sendmail+0x670>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
lea    0xd8e(%rip),%rsi
lea    0xd91(%rip),%rdx
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x2634(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2630(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2634(%rbp),%edi
mov    -0x2630(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
lea    0xd40(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x2624(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2620(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2624(%rbp),%edi
mov    -0x2620(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x2590(%rbp),%rdi
xor    %esi,%esi
mov    $0x1559,%edx
call   1080 <memset@plt>
lea    0xcca(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
lea    -0x2590(%rbp),%rdx
lea    0xcb5(%rip),%rdi
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
lea    -0x2590(%rbp),%rdx
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x2614(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2610(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2614(%rbp),%edi
mov    -0x2610(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x2590(%rbp),%rdi
xor    %esi,%esi
mov    $0x1559,%edx
call   1080 <memset@plt>
lea    0xc46(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
lea    -0x2590(%rbp),%rdx
lea    0xc31(%rip),%rdi
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
lea    -0x2590(%rbp),%rdx
lea    0xbd7(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x2604(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x2600(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2604(%rbp),%edi
mov    -0x2600(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
lea    0xb9f(%rip),%rsi
lea    0xb6e(%rip),%rdx
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25f4(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x25f0(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x25f4(%rbp),%edi
mov    -0x25f0(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xb3e(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25e4(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x25e0(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x25e4(%rbp),%edi
mov    -0x25e0(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25d8(%rbp)
lea    0xaf7(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x25d8(%rbp),%edi
mov    %eax,%edx
lea    0xae3(%rip),%rsi
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xab8(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25d4(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x25d0(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x25d4(%rbp),%edi
mov    -0x25d0(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xaac(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25c4(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x25c0(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x25c4(%rbp),%edi
mov    -0x25c0(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
lea    -0x1030(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    -0x1030(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xa75(%rip),%rsi
mov    $0x0,%al
call   1110 <sprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x25b4(%rbp)
lea    -0x1030(%rbp),%rax
mov    %rax,-0x25b0(%rbp)
lea    -0x1030(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x25b4(%rbp),%edi
mov    -0x25b0(%rbp),%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    -0x28(%rbp),%rdi
lea    0xab7(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x2598(%rbp)
xor    %eax,%eax
cmp    -0x2598(%rbp),%rax
jne    1707 <sendmail+0x517>
lea    0xa98(%rip),%rdi
call   1100 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1860 <sendmail+0x670>
mov    -0x2598(%rbp),%rdi
mov    0x28d3(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <fseek@plt>
mov    -0x2598(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %eax,-0x259c(%rbp)
mov    -0x2598(%rbp),%rdi
mov    0x2898(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <fseek@plt>
movl   $0x0,-0x25a0(%rbp)
movl   $0x0,-0x25a4(%rbp)
mov    -0x25a0(%rbp),%eax
cmp    -0x259c(%rbp),%eax
jge    180d <sendmail+0x61d>
lea    -0x1030(%rbp),%rdi
mov    -0x2598(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %eax,-0x25a4(%rbp)
lea    -0x1030(%rbp),%rdi
mov    -0x25a4(%rbp),%esi
lea    -0x2590(%rbp),%rdx
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
mov    %eax,-0x25a8(%rbp)
mov    $0xffffffff,%eax
cmp    -0x25a8(%rbp),%eax
jne    17e1 <sendmail+0x5f1>
lea    0x9c4(%rip),%rdi
call   1100 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1860 <sendmail+0x670>
mov    -0x2c(%rbp),%edi
lea    -0x2590(%rbp),%rsi
mov    -0x25a8(%rbp),%edx
call   10d0 <send_socket@plt>
mov    -0x25a4(%rbp),%eax
add    -0x25a0(%rbp),%eax
mov    %eax,-0x25a0(%rbp)
jmp    175f <sendmail+0x56f>
mov    -0x2598(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x2c(%rbp),%edi
lea    0x97f(%rip),%rsi
mov    $0xffffffff,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
mov    -0x2c(%rbp),%edi
lea    0x969(%rip),%rsi
mov    $0x7,%edx
call   10d0 <send_socket@plt>
mov    -0x2c(%rbp),%edi
call   1070 <read_socket@plt>
mov    -0x2c(%rbp),%edi
call   1090 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendmail>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2588,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
lea    0x20(%rsp),%rdi
mov    $0x1000,%edx
xor    %esi,%esi
call   1080 <memset@plt>
lea    0x1020(%rsp),%rdi
mov    $0x1559,%edx
xor    %esi,%esi
call   1080 <memset@plt>
xor    %eax,%eax
call   10e0 <connect_MailServer@plt>
cmp    $0xffffffff,%eax
je     1614 <sendmail+0x424>
mov    %eax,%ebp
mov    %rbx,0x18(%rsp)
lea    0x20(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xd9a(%rip),%rsi
lea    0xd9d(%rip),%rdx
mov    %r15,%rdi
mov    %rdx,%rbx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
movabs $0x474f4c2048545541,%rax
4c 4f 47
mov    %rax,0x20(%rsp)
movabs $0xa0d4e49474f4c,%rax
mov    %rax,0x25(%rsp)
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
lea    0x1020(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x1559,%edx
call   1080 <memset@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
mov    %r14,0x10(%rsp)
lea    0xcdc(%rip),%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x1559,%edx
call   1080 <memset@plt>
lea    0xcc3(%rip),%r14
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r13,%rdx
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xc60(%rip),%rsi
mov    %r15,%rdi
lea    0xc2c(%rip),%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xc2f(%rip),%rsi
mov    %r15,%rdi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
lea    0xc0d(%rip),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %ebp,%edi
call   1070 <read_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xbe3(%rip),%rsi
mov    %r15,%rdi
mov    0x8(%rsp),%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xc01(%rip),%rsi
mov    %r15,%rdi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1080 <memset@plt>
lea    0xbf8(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1110 <sprintf@plt>
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
lea    0xc58(%rip),%rsi
mov    %r12,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     1637 <sendmail+0x447>
mov    %rax,%r15
mov    %ebp,0x8(%rsp)
mov    0x2ab4(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    %r15,%rdi
call   10a0 <ftell@plt>
mov    %eax,%r13d
mov    0x2a86(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <fseek@plt>
test   %r13d,%r13d
jle    15c9 <sendmail+0x3d9>
xor    %r12d,%r12d
lea    0x20(%rsp),%rbp
lea    0x1020(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
mov    $0x1559,%ecx
call   10b0 <base64_encode@plt>
cmp    $0xffffffff,%eax
je     1640 <sendmail+0x450>
mov    0x8(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   10d0 <send_socket@plt>
add    %r14d,%r12d
cmp    %r13d,%r12d
jl     1580 <sendmail+0x390>
mov    %r15,%rdi
call   1050 <fclose@plt>
lea    0xbac(%rip),%rsi
mov    0x8(%rsp),%ebx
mov    %ebx,%edi
mov    $0xffffffff,%edx
call   10d0 <send_socket@plt>
mov    %ebx,%edi
call   1070 <read_socket@plt>
lea    0xb94(%rip),%rsi
mov    %ebx,%edi
mov    $0x7,%edx
call   10d0 <send_socket@plt>
mov    %ebx,%edi
call   1070 <read_socket@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %eax,%eax
jmp    1625 <sendmail+0x435>
lea    0xb76(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x2588,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb32(%rip),%rdi
jmp    1647 <sendmail+0x457>
lea    0xb2f(%rip),%rdi
call   1100 <perror@plt>
jmp    1620 <sendmail+0x430>

LLVM IR (-O0):
@.str = [30 x i8] c"failed to connect_MailServer\0A\00"
@.str.1 = [10 x i8] c"HELO %s\0D\0A\00"
@.str.2 = [22 x i8] c"freeswitch123@163.com\00"
@.str.3 = [13 x i8] c"AUTH LOGIN\0D\0A\00"
@.str.4 = [5 x i8] c"%s\0D\0A\00"
@.str.5 = [7 x i8] c"asd123\00"
@.str.6 = [17 x i8] c"MAIL FROM <%s>\0D\0A\00"
@.str.7 = [15 x i8] c"RCPT TO <%s>\0D\0A\00"
@.str.8 = [7 x i8] c"DATA\0D\0A\00"
@.str.9 = [87 x i8] c"SUBJECT:%s\0D\0AMIME-VERSION: 1.0\0D\0ACONTENT-TYPE: MULTIPART/MIXED;BOUNDARY=\22#BOUNDARY#\22\0D\0A\0D\0A\00"
@.str.10 = [48 x i8] c"--#BOUNDARY#\0D\0ACONTENT-TYPE: TEXT/HTML\0D\0A\0D\0A%s\0D\0A\0D\0A\00"
@.str.11 = [139 x i8] c"--#BOUNDARY#\0D\0ACONTENT-TYPE:APPLICATION/MSWORD; NAME=%s\0D\0ACONTENT-DISPOSITION: ATTACHMENT; FILENAME=%s\0D\0ACONTENT-TRANSFER-ENCODING:BASE64\0D\0A\0D\0A\00"
@.str.12 = [3 x i8] c"rb\00"
@.str.13 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.14 = [14 x i8] c"base64_encode\00"
@.str.15 = [6 x i8] c"\0D\0A.\0D\0A\00"
@.str.16 = [7 x i8] c"QUIT\0D\0A\00"
define i32 @sendmail(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca [4096 x i8]
%12 = alloca [5465 x i8]
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 -1, i32* %10
%18 = bitcast [4096 x i8]* %11 to i8*
%19 = bitcast [5465 x i8]* %12 to i8*
store i32* null, i32** %13
%20 = call i32 (...) @connect_MailServer()
store i32 %20, i32* %10
%21 = load i32, i32* %10
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %4
%24 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %193
25: ; preds = %4
%26 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 0, i32 4096)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%29 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* %10
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = call i32 @send_socket(i32 %30, i8* %31, i32 %33)
%35 = load i32, i32* %10
%36 = call i32 @read_socket(i32 %35)
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%38 = call i32 @memset(i8* %37, i32 0, i32 4096)
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* %10
%42 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = call i32 @send_socket(i32 %41, i8* %42, i32 %44)
%46 = load i32, i32* %10
%47 = call i32 @read_socket(i32 %46)
%48 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%49 = call i32 @memset(i8* %48, i32 0, i32 5465)
%50 = call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%51 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%52 = call i32 @base64_encode(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %50, i8* %51, i32 5465)
%53 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%54 = call i32 @memset(i8* %53, i32 0, i32 4096)
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%56 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %55, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %56)
%58 = load i32, i32* %10
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = call i32 @send_socket(i32 %58, i8* %59, i32 %61)
%63 = load i32, i32* %10
%64 = call i32 @read_socket(i32 %63)
%65 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%66 = call i32 @memset(i8* %65, i32 0, i32 5465)
%67 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%68 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%69 = call i32 @base64_encode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %67, i8* %68, i32 5465)
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%71 = call i32 @memset(i8* %70, i32 0, i32 4096)
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%73 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%74 = call i32 (i8*, i8*, ...) @sprintf(i8* %72, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %73)
%75 = load i32, i32* %10
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%78 = call i32 @strlen(i8* %77)
%79 = call i32 @send_socket(i32 %75, i8* %76, i32 %78)
%80 = load i32, i32* %10
%81 = call i32 @read_socket(i32 %80)
%82 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%83 = call i32 @memset(i8* %82, i32 0, i32 4096)
%84 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%85 = call i32 (i8*, i8*, ...) @sprintf(i8* %84, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%86 = load i32, i32* %10
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%88 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%89 = call i32 @strlen(i8* %88)
%90 = call i32 @send_socket(i32 %86, i8* %87, i32 %89)
%91 = load i32, i32* %10
%92 = call i32 @read_socket(i32 %91)
%93 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%94 = call i32 @memset(i8* %93, i32 0, i32 4096)
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%96 = load i8*, i8** %6
%97 = call i32 (i8*, i8*, ...) @sprintf(i8* %95, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %96)
%98 = load i32, i32* %10
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%101 = call i32 @strlen(i8* %100)
%102 = call i32 @send_socket(i32 %98, i8* %99, i32 %101)
%103 = load i32, i32* %10
%104 = call i32 @read_socket(i32 %103)
%105 = load i32, i32* %10
%106 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%107 = call i32 @send_socket(i32 %105, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %106)
%108 = load i32, i32* %10
%109 = call i32 @read_socket(i32 %108)
%110 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%111 = call i32 @memset(i8* %110, i32 0, i32 4096)
%112 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%113 = load i8*, i8** %7
%114 = call i32 (i8*, i8*, ...) @sprintf(i8* %112, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.9, i64 0, i64 0), i8* %113)
%115 = load i32, i32* %10
%116 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%117 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%118 = call i32 @strlen(i8* %117)
%119 = call i32 @send_socket(i32 %115, i8* %116, i32 %118)
%120 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%121 = call i32 @memset(i8* %120, i32 0, i32 4096)
%122 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%123 = load i8*, i8** %8
%124 = call i32 (i8*, i8*, ...) @sprintf(i8* %122, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %123)
%125 = load i32, i32* %10
%126 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%127 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%128 = call i32 @strlen(i8* %127)
%129 = call i32 @send_socket(i32 %125, i8* %126, i32 %128)
%130 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%131 = call i32 @memset(i8* %130, i32 0, i32 4096)
%132 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%133 = load i8*, i8** %9
%134 = load i8*, i8** %9
%135 = call i32 (i8*, i8*, ...) @sprintf(i8* %132, i8* getelementptr inbounds ([139 x i8], [139 x i8]* @.str.11, i64 0, i64 0), i8* %133, i8* %134)
%136 = load i32, i32* %10
%137 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%138 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%139 = call i32 @strlen(i8* %138)
%140 = call i32 @send_socket(i32 %136, i8* %137, i32 %139)
%141 = load i8*, i8** %9
%142 = call i32* @fopen(i8* %141, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
store i32* %142, i32** %13
%143 = load i32*, i32** %13
%144 = icmp eq i32* null, %143
br i1 %144, label %145, label %147
145: ; preds = %25
%146 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
store i32 -1, i32* %5
br label %193
147: ; preds = %25
%148 = load i32*, i32** %13
%149 = load i32, i32* @SEEK_END
%150 = call i32 @fseek(i32* %148, i64 0, i32 %149)
%151 = load i32*, i32** %13
%152 = call i32 @ftell(i32* %151)
store i32 %152, i32* %14
%153 = load i32*, i32** %13
%154 = load i32, i32* @SEEK_SET
%155 = call i32 @fseek(i32* %153, i64 0, i32 %154)
store i32 0, i32* %15
store i32 0, i32* %16
br label %156
156: ; preds = %172, %147
%157 = load i32, i32* %15
%158 = load i32, i32* %14
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %180
160: ; preds = %156
%161 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%162 = load i32*, i32** %13
%163 = call i32 @fread(i8* %161, i32 1, i32 4096, i32* %162)
store i32 %163, i32* %16
%164 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%165 = load i32, i32* %16
%166 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%167 = call i32 @base64_encode(i8* %164, i32 %165, i8* %166, i32 5465)
store i32 %167, i32* %17
%168 = load i32, i32* %17
%169 = icmp eq i32 -1, %168
br i1 %169, label %170, label %172
170: ; preds = %160
%171 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
store i32 -1, i32* %5
br label %193
172: ; preds = %160
%173 = load i32, i32* %10
%174 = getelementptr inbounds [5465 x i8], [5465 x i8]* %12, i64 0, i64 0
%175 = load i32, i32* %17
%176 = call i32 @send_socket(i32 %173, i8* %174, i32 %175)
%177 = load i32, i32* %16
%178 = load i32, i32* %15
%179 = add nsw i32 %178, %177
store i32 %179, i32* %15
br label %156
180: ; preds = %156
%181 = load i32*, i32** %13
%182 = call i32 @fclose(i32* %181)
%183 = load i32, i32* %10
%184 = call i32 @send_socket(i32 %183, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 -1)
%185 = load i32, i32* %10
%186 = call i32 @read_socket(i32 %185)
%187 = load i32, i32* %10
%188 = call i32 @send_socket(i32 %187, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32 7)
%189 = load i32, i32* %10
%190 = call i32 @read_socket(i32 %189)
%191 = load i32, i32* %10
%192 = call i32 @close(i32 %191)
store i32 0, i32* %5
br label %193
193: ; preds = %180, %170, %145, %23
%194 = load i32, i32* %5
ret i32 %194
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"HELO %s\0D\0A\00"
@.str.2 = [22 x i8] c"freeswitch123@163.com\00"
@.str.3 = [13 x i8] c"AUTH LOGIN\0D\0A\00"
@.str.4 = [5 x i8] c"%s\0D\0A\00"
@.str.5 = [7 x i8] c"asd123\00"
@.str.6 = [17 x i8] c"MAIL FROM <%s>\0D\0A\00"
@.str.7 = [15 x i8] c"RCPT TO <%s>\0D\0A\00"
@.str.8 = [7 x i8] c"DATA\0D\0A\00"
@.str.9 = [87 x i8] c"SUBJECT:%s\0D\0AMIME-VERSION: 1.0\0D\0ACONTENT-TYPE: MULTIPART/MIXED;BOUNDARY=\22#BOUNDARY#\22\0D\0A\0D\0A\00"
@.str.10 = [48 x i8] c"--#BOUNDARY#\0D\0ACONTENT-TYPE: TEXT/HTML\0D\0A\0D\0A%s\0D\0A\0D\0A\00"
@.str.11 = [139 x i8] c"--#BOUNDARY#\0D\0ACONTENT-TYPE:APPLICATION/MSWORD; NAME=%s\0D\0ACONTENT-DISPOSITION: ATTACHMENT; FILENAME=%s\0D\0ACONTENT-TRANSFER-ENCODING:BASE64\0D\0A\0D\0A\00"
@.str.12 = [3 x i8] c"rb\00"
@.str.13 = [6 x i8] c"fopen\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.14 = [14 x i8] c"base64_encode\00"
@.str.15 = [6 x i8] c"\0D\0A.\0D\0A\00"
@.str.16 = [7 x i8] c"QUIT\0D\0A\00"
@str = [29 x i8] c"failed to connect_MailServer\00"
define i32 @sendmail(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [4096 x i8]
%6 = alloca [5465 x i8]
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [5465 x i8], [5465 x i8]* %6, i64 0, i64 0
%9 = tail call i32 (...) @connect_MailServer()
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %93
13: ; preds = %4
%14 = call i32 @memset(i8* %7, i32 0, i32 4096)
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @strlen(i8* %7)
%17 = call i32 @send_socket(i32 %9, i8* %7, i32 %16)
%18 = call i32 @read_socket(i32 %9)
%19 = call i32 @memset(i8* %7, i32 0, i32 4096)
%20 = call i32 @strlen(i8* %7)
%21 = call i32 @send_socket(i32 %9, i8* %7, i32 %20)
%22 = call i32 @read_socket(i32 %9)
%23 = call i32 @memset(i8* %8, i32 0, i32 5465)
%24 = call i32 @strlen(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @base64_encode(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %24, i8* %8, i32 5465)
%26 = call i32 @memset(i8* %7, i32 0, i32 4096)
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%28 = call i32 @strlen(i8* %7)
%29 = call i32 @send_socket(i32 %9, i8* %7, i32 %28)
%30 = call i32 @read_socket(i32 %9)
%31 = call i32 @memset(i8* %8, i32 0, i32 5465)
%32 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32 @base64_encode(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 %32, i8* %8, i32 5465)
%34 = call i32 @memset(i8* %7, i32 0, i32 4096)
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%36 = call i32 @strlen(i8* %7)
%37 = call i32 @send_socket(i32 %9, i8* %7, i32 %36)
%38 = call i32 @read_socket(i32 %9)
%39 = call i32 @memset(i8* %7, i32 0, i32 4096)
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%41 = call i32 @strlen(i8* %7)
%42 = call i32 @send_socket(i32 %9, i8* %7, i32 %41)
%43 = call i32 @read_socket(i32 %9)
%44 = call i32 @memset(i8* %7, i32 0, i32 4096)
%45 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8* %0)
%46 = call i32 @strlen(i8* %7)
%47 = call i32 @send_socket(i32 %9, i8* %7, i32 %46)
%48 = call i32 @read_socket(i32 %9)
%49 = call i32 @strlen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%50 = call i32 @send_socket(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %49)
%51 = call i32 @read_socket(i32 %9)
%52 = call i32 @memset(i8* %7, i32 0, i32 4096)
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @.str.9, i64 0, i64 0), i8* %1)
%54 = call i32 @strlen(i8* %7)
%55 = call i32 @send_socket(i32 %9, i8* %7, i32 %54)
%56 = call i32 @memset(i8* %7, i32 0, i32 4096)
%57 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i8* %2)
%58 = call i32 @strlen(i8* %7)
%59 = call i32 @send_socket(i32 %9, i8* %7, i32 %58)
%60 = call i32 @memset(i8* %7, i32 0, i32 4096)
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([139 x i8], [139 x i8]* @.str.11, i64 0, i64 0), i8* %3, i8* %3)
%62 = call i32 @strlen(i8* %7)
%63 = call i32 @send_socket(i32 %9, i8* %7, i32 %62)
%64 = call i32* @fopen(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %68
66: ; preds = %13
%67 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0))
br label %93
68: ; preds = %13
%69 = load i32, i32* @SEEK_END
%70 = call i32 @fseek(i32* %64, i64 0, i32 %69)
%71 = call i32 @ftell(i32* %64)
%72 = load i32, i32* @SEEK_SET
%73 = call i32 @fseek(i32* %64, i64 0, i32 %72)
%74 = icmp sgt i32 %71, 0
br i1 %74, label %75, label %86
75: ; preds = %68, %82
%76 = phi i32 [ %84, %82 ], [ 0, %68 ]
%77 = call i32 @fread(i8* %7, i32 1, i32 4096, i32* %64)
%78 = call i32 @base64_encode(i8* %7, i32 %77, i8* %8, i32 5465)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %75
%81 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.14, i64 0, i64 0))
br label %93
82: ; preds = %75
%83 = call i32 @send_socket(i32 %9, i8* %8, i32 %78)
%84 = add nsw i32 %77, %76
%85 = icmp slt i32 %84, %71
br i1 %85, label %75, label %86
86: ; preds = %82, %68
%87 = call i32 @fclose(i32* %64)
%88 = call i32 @send_socket(i32 %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.15, i64 0, i64 0), i32 -1)
%89 = call i32 @read_socket(i32 %9)
%90 = call i32 @send_socket(i32 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.16, i64 0, i64 0), i32 7)
%91 = call i32 @read_socket(i32 %9)
%92 = call i32 @close(i32 %9)
br label %93
93: ; preds = %80, %86, %66, %11
%94 = phi i32 [ -1, %11 ], [ -1, %66 ], [ -1, %80 ], [ 0, %86 ]
ret i32 %94
}