#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*/ base64_encode(char *, int, char *);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *malloc(int);
int medusaReceiveRegex(int, unsigned char **, int *, char *);
scalar_t__ medusaSend(int, unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ writeError(int, char *, char *);
int sendAuthPLAIN(int hSocket, char *szLogin, char *szPassword) {
  unsigned char *bufReceive = NULL;
  unsigned char *bufSend = NULL;
  unsigned char *szTmpBuf = NULL;
  unsigned char *szTmpBuf64 = NULL;
  int nSendBufferSize = 0;
  int nReceiveBufferSize = 0;
  writeError(10, "[%s] Initiating PLAIN Authentication Attempt.", "smtp.mod");
  bufSend = malloc(12 + 1);
  memset(bufSend, 0, 12 + 1);
  sprintf((char *)bufSend, "AUTH PLAIN\r\n");
  if (medusaSend(hSocket, bufSend, strlen((char *)bufSend), 0) < 0) {
    writeError(3, "[%s] Failed: medusaSend was not successful", "smtp.mod");
  }
  if (bufSend != NULL) {
    free(bufSend);
    bufSend = NULL;
  };
  nReceiveBufferSize = 0;
  if ((medusaReceiveRegex(hSocket, &bufReceive, &nReceiveBufferSize,
                          "^334 .*\r\n") == -1) ||
      (bufReceive == NULL)) {
    writeError(
        3,
        "[%s] SMTP server did not respond with \"334 \" to AUTH PLAIN request.",
        "smtp.mod");
    if (bufReceive != NULL) {
      free(bufReceive);
      bufReceive = NULL;
    };
    return -1;
  }
  nSendBufferSize =
      strlen(szLogin) + 1 + strlen(szLogin) + 1 + strlen(szPassword);
  szTmpBuf = malloc(nSendBufferSize + 1);
  memset(szTmpBuf, 0, nSendBufferSize + 1);
  strncpy((char *)szTmpBuf, szLogin, strlen((char *)szLogin));
  strncpy((char *)szTmpBuf + strlen(szLogin) + 1, szLogin, strlen(szLogin));
  strncpy((char *)szTmpBuf + strlen(szLogin) + 1 + strlen(szLogin) + 1,
          szPassword, strlen(szPassword));
  szTmpBuf64 = malloc((2 * nSendBufferSize + 2) + 1);
  memset(szTmpBuf64, 0, (2 * nSendBufferSize + 2) + 1);
  base64_encode((char *)szTmpBuf, nSendBufferSize, (char *)szTmpBuf64);
  if (szTmpBuf != NULL) {
    free(szTmpBuf);
    szTmpBuf = NULL;
  };
  bufSend = malloc(strlen((char *)szTmpBuf64) + 2 + 1);
  memset(bufSend, 0, strlen((char *)szTmpBuf64) + 2 + 1);
  sprintf((char *)bufSend, "%s\r\n", szTmpBuf64);
  if (szTmpBuf64 != NULL) {
    free(szTmpBuf64);
    szTmpBuf64 = NULL;
  };
  if (medusaSend(hSocket, bufSend, strlen((char *)bufSend), 0) < 0) {
    writeError(3, "[%s] Failed: medusaSend was not successful", "smtp.mod");
  }
  if (bufSend != NULL) {
    free(bufSend);
    bufSend = NULL;
  };
  return 0;
}


x86 assembly (clang, -O0):
<sendAuthPLAIN>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    $0xa,%edi
lea    0xe10(%rip),%rsi
lea    0xe37(%rip),%rdx
call   1080 <writeError@plt>
mov    $0xd,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1070 <memset@plt>
mov    -0x28(%rbp),%rdi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <medusaSend@plt>
cmp    $0x0,%rax
jge    1275 <sendAuthPLAIN+0xd5>
mov    $0x3,%edi
lea    0xddb(%rip),%rsi
lea    0xdbe(%rip),%rdx
call   1080 <writeError@plt>
cmpq   $0x0,-0x28(%rbp)
je     1291 <sendAuthPLAIN+0xf1>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x20(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    0xdc5(%rip),%rcx
call   1060 <medusaReceiveRegex@plt>
cmp    $0xffffffff,%eax
je     12c3 <sendAuthPLAIN+0x123>
cmpq   $0x0,-0x20(%rbp)
jne    1303 <sendAuthPLAIN+0x163>
mov    $0x3,%edi
lea    0xdaa(%rip),%rsi
lea    0xd58(%rip),%rdx
call   1080 <writeError@plt>
cmpq   $0x0,-0x20(%rbp)
je     12f7 <sendAuthPLAIN+0x157>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x4(%rbp)
jmp    158e <sendAuthPLAIN+0x3ee>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0xa0(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xa0(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%edx
add    $0x1,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x3c(%rbp),%edi
shl    $0x1,%edi
add    $0x2,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%edx
shl    $0x1,%edx
add    $0x2,%edx
add    $0x1,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   10a0 <base64_encode@plt>
cmpq   $0x0,-0x30(%rbp)
je     14a0 <sendAuthPLAIN+0x300>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x2,%edi
add    $0x1,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%edx
add    $0x2,%edx
add    $0x1,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xbca(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
cmpq   $0x0,-0x38(%rbp)
je     1516 <sendAuthPLAIN+0x376>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <medusaSend@plt>
cmp    $0x0,%rax
jge    156b <sendAuthPLAIN+0x3cb>
mov    $0x3,%edi
lea    0xae5(%rip),%rsi
lea    0xac8(%rip),%rdx
call   1080 <writeError@plt>
cmpq   $0x0,-0x28(%rbp)
je     1587 <sendAuthPLAIN+0x3e7>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendAuthPLAIN>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r15
mov    %rsi,%r13
mov    %edi,%ebp
movq   $0x0,(%rsp)
lea    0xe3b(%rip),%rsi
lea    0xe62(%rip),%rdx
mov    $0xa,%edi
call   1080 <writeError@plt>
mov    $0xd,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xd,%edx
call   1070 <memset@plt>
movabs $0x414c502048545541,%rax
50 4c 41
mov    %rax,(%rbx)
movabs $0xa0d4e49414c50,%rax
mov    %rax,0x5(%rbx)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <medusaSend@plt>
test   %rax,%rax
jns    1240 <sendAuthPLAIN+0xa0>
lea    0xe15(%rip),%rsi
lea    0xdf8(%rip),%rdx
mov    $0x3,%edi
call   1080 <writeError@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
movl   $0x0,0x14(%rsp)
lea    0xe18(%rip),%rcx
mov    %rsp,%rsi
lea    0x14(%rsp),%rdx
mov    %ebp,%edi
call   1060 <medusaReceiveRegex@plt>
cmp    $0xffffffff,%eax
je     13f6 <sendAuthPLAIN+0x256>
cmpq   $0x0,(%rsp)
je     13f6 <sendAuthPLAIN+0x256>
mov    %ebp,0x10(%rsp)
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,%r12d
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <strlen@plt>
add    %r12d,%ebx
mov    %ebx,%r14d
add    %eax,%r14d
lea    (%rax,%rbx,1),%ecx
add    $0x2,%ecx
mov    %ecx,0xc(%rsp)
lea    (%rax,%rbx,1),%ebp
add    $0x3,%ebp
mov    %ebp,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebp,%edx
call   1070 <memset@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
lea    (%r12,%rax,1),%rbp
add    $0x1,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    %r13,%rdi
call   1050 <strlen@plt>
movslq %eax,%rbx
add    %r12,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rax,%rbx,1),%rbp
add    $0x2,%rbp
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1040 <strncpy@plt>
lea    (%r14,%r14,1),%ebx
add    $0x7,%ebx
mov    %ebx,%edi
call   1090 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1070 <memset@plt>
mov    %r12,%rdi
mov    0xc(%rsp),%esi
mov    %rbp,%rdx
call   10a0 <base64_encode@plt>
test   %r12,%r12
je     1374 <sendAuthPLAIN+0x1d4>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x3(%rax),%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x3(%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
lea    0xd1a(%rip),%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10b0 <sprintf@plt>
test   %rbp,%rbp
je     13bd <sendAuthPLAIN+0x21d>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
xor    %ebp,%ebp
mov    0x10(%rsp),%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   10c0 <medusaSend@plt>
test   %rax,%rax
jns    1417 <sendAuthPLAIN+0x277>
lea    0xc61(%rip),%rsi
lea    0xc44(%rip),%rdx
mov    $0x3,%edi
call   1080 <writeError@plt>
jmp    1417 <sendAuthPLAIN+0x277>
lea    0xc7c(%rip),%rsi
lea    0xc2a(%rip),%rdx
mov    $0x3,%edi
call   1080 <writeError@plt>
mov    (%rsp),%rbx
mov    $0xffffffff,%ebp
test   %rbx,%rbx
je     1424 <sendAuthPLAIN+0x284>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"[%s] Initiating PLAIN Authentication Attempt.\00"
@.str.1 = [9 x i8] c"smtp.mod\00"
@.str.2 = [13 x i8] c"AUTH PLAIN\0D\0A\00"
@.str.3 = [43 x i8] c"[%s] Failed: medusaSend was not successful\00"
@.str.4 = [10 x i8] c"^334 .*\0D\0A\00"
@.str.5 = [68 x i8] c"[%s] SMTP server did not respond with \22334 \22 to AUTH PLAIN request.\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
define i32 @sendAuthPLAIN(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i8* null, i8** %11
store i32 0, i32* %12
store i32 0, i32* %13
%14 = call i32 @writeError(i32 10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = call i8* @malloc(i32 13)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = call i32 @memset(i8* %16, i32 0, i32 13)
%18 = load i8*, i8** %9
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %5
%21 = load i8*, i8** %9
%22 = load i8*, i8** %9
%23 = call i32 @strlen(i8* %22)
%24 = call i64 @medusaSend(i32 %20, i8* %21, i32 %23, i32 0)
%25 = icmp slt i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %3
%27 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %3
%29 = load i8*, i8** %9
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i8*, i8** %9
%33 = call i32 @free(i8* %32)
store i8* null, i8** %9
br label %34
34: ; preds = %31, %28
store i32 0, i32* %13
%35 = load i32, i32* %5
%36 = call i32 @medusaReceiveRegex(i32 %35, i8** %8, i32* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%37 = icmp eq i32 %36, -1
br i1 %37, label %41, label %38
38: ; preds = %34
%39 = load i8*, i8** %8
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %49
41: ; preds = %38, %34
%42 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%43 = load i8*, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = load i8*, i8** %8
%47 = call i32 @free(i8* %46)
store i8* null, i8** %8
br label %48
48: ; preds = %45, %41
store i32 -1, i32* %4
br label %153
49: ; preds = %38
%50 = load i8*, i8** %6
%51 = call i32 @strlen(i8* %50)
%52 = add nsw i32 %51, 1
%53 = load i8*, i8** %6
%54 = call i32 @strlen(i8* %53)
%55 = add nsw i32 %52, %54
%56 = add nsw i32 %55, 1
%57 = load i8*, i8** %7
%58 = call i32 @strlen(i8* %57)
%59 = add nsw i32 %56, %58
store i32 %59, i32* %12
%60 = load i32, i32* %12
%61 = add nsw i32 %60, 1
%62 = call i8* @malloc(i32 %61)
store i8* %62, i8** %10
%63 = load i8*, i8** %10
%64 = load i32, i32* %12
%65 = add nsw i32 %64, 1
%66 = call i32 @memset(i8* %63, i32 0, i32 %65)
%67 = load i8*, i8** %10
%68 = load i8*, i8** %6
%69 = load i8*, i8** %6
%70 = call i32 @strlen(i8* %69)
%71 = call i32 @strncpy(i8* %67, i8* %68, i32 %70)
%72 = load i8*, i8** %10
%73 = load i8*, i8** %6
%74 = call i32 @strlen(i8* %73)
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %72, i64 %75
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = load i8*, i8** %6
%79 = load i8*, i8** %6
%80 = call i32 @strlen(i8* %79)
%81 = call i32 @strncpy(i8* %77, i8* %78, i32 %80)
%82 = load i8*, i8** %10
%83 = load i8*, i8** %6
%84 = call i32 @strlen(i8* %83)
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %82, i64 %85
%87 = getelementptr inbounds i8, i8* %86, i64 1
%88 = load i8*, i8** %6
%89 = call i32 @strlen(i8* %88)
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %87, i64 %90
%92 = getelementptr inbounds i8, i8* %91, i64 1
%93 = load i8*, i8** %7
%94 = load i8*, i8** %7
%95 = call i32 @strlen(i8* %94)
%96 = call i32 @strncpy(i8* %92, i8* %93, i32 %95)
%97 = load i32, i32* %12
%98 = mul nsw i32 2, %97
%99 = add nsw i32 %98, 2
%100 = add nsw i32 %99, 1
%101 = call i8* @malloc(i32 %100)
store i8* %101, i8** %11
%102 = load i8*, i8** %11
%103 = load i32, i32* %12
%104 = mul nsw i32 2, %103
%105 = add nsw i32 %104, 2
%106 = add nsw i32 %105, 1
%107 = call i32 @memset(i8* %102, i32 0, i32 %106)
%108 = load i8*, i8** %10
%109 = load i32, i32* %12
%110 = load i8*, i8** %11
%111 = call i32 @base64_encode(i8* %108, i32 %109, i8* %110)
%112 = load i8*, i8** %10
%113 = icmp ne i8* %112, null
br i1 %113, label %114, label %117
114: ; preds = %49
%115 = load i8*, i8** %10
%116 = call i32 @free(i8* %115)
store i8* null, i8** %10
br label %117
117: ; preds = %114, %49
%118 = load i8*, i8** %11
%119 = call i32 @strlen(i8* %118)
%120 = add nsw i32 %119, 2
%121 = add nsw i32 %120, 1
%122 = call i8* @malloc(i32 %121)
store i8* %122, i8** %9
%123 = load i8*, i8** %9
%124 = load i8*, i8** %11
%125 = call i32 @strlen(i8* %124)
%126 = add nsw i32 %125, 2
%127 = add nsw i32 %126, 1
%128 = call i32 @memset(i8* %123, i32 0, i32 %127)
%129 = load i8*, i8** %9
%130 = load i8*, i8** %11
%131 = call i32 (i8*, i8*, ...) @sprintf(i8* %129, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %130)
%132 = load i8*, i8** %11
%133 = icmp ne i8* %132, null
br i1 %133, label %134, label %137
134: ; preds = %117
%135 = load i8*, i8** %11
%136 = call i32 @free(i8* %135)
store i8* null, i8** %11
br label %137
137: ; preds = %134, %117
%138 = load i32, i32* %5
%139 = load i8*, i8** %9
%140 = load i8*, i8** %9
%141 = call i32 @strlen(i8* %140)
%142 = call i64 @medusaSend(i32 %138, i8* %139, i32 %141, i32 0)
%143 = icmp slt i64 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %137
%145 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %146
146: ; preds = %144, %137
%147 = load i8*, i8** %9
%148 = icmp ne i8* %147, null
br i1 %148, label %149, label %152
149: ; preds = %146
%150 = load i8*, i8** %9
%151 = call i32 @free(i8* %150)
store i8* null, i8** %9
br label %152
152: ; preds = %149, %146
store i32 0, i32* %4
br label %153
153: ; preds = %152, %48
%154 = load i32, i32* %4
ret i32 %154
}

LLVM IR (-O2):
@.str = [46 x i8] c"[%s] Initiating PLAIN Authentication Attempt.\00"
@.str.1 = [9 x i8] c"smtp.mod\00"
@.str.2 = [13 x i8] c"AUTH PLAIN\0D\0A\00"
@.str.3 = [43 x i8] c"[%s] Failed: medusaSend was not successful\00"
@.str.4 = [10 x i8] c"^334 .*\0D\0A\00"
@.str.5 = [68 x i8] c"[%s] SMTP server did not respond with \22334 \22 to AUTH PLAIN request.\00"
@.str.6 = [5 x i8] c"%s\0D\0A\00"
define i32 @sendAuthPLAIN(i32 %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = bitcast i32* %5 to i8*
%8 = tail call i32 @writeError(i32 10, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call dereferenceable_or_null(13) i8* @malloc(i32 13)
%10 = tail call i32 @memset(i8* %9, i32 0, i32 13)
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(13) %9, i8* align 1 dereferenceable(13) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 13, i1 false)
%11 = tail call i32 @strlen(i8* %9)
%12 = tail call i64 @medusaSend(i32 %0, i8* %9, i32 %11, i32 0)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = tail call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %3
%17 = tail call i32 @free(i8* %9)
store i32 0, i32* %5
%18 = call i32 @medusaReceiveRegex(i32 %0, i8** %4, i32* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32 %18, -1
%20 = load i8*, i8** %4
%21 = icmp eq i8* %20, null
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%25 = load i8*, i8** %4
%26 = icmp eq i8* %25, null
br i1 %26, label %86, label %82
27: ; preds = %16
%28 = call i32 @strlen(i8* %1)
%29 = call i32 @strlen(i8* %1)
%30 = call i32 @strlen(i8* %2)
%31 = add i32 %28, 2
%32 = add i32 %31, %29
%33 = add i32 %32, %30
%34 = add nsw i32 %33, 1
%35 = call i8* @malloc(i32 %34)
%36 = call i32 @memset(i8* %35, i32 0, i32 %34)
%37 = call i32 @strlen(i8* %1)
%38 = call i32 @strncpy(i8* %35, i8* %1, i32 %37)
%39 = call i32 @strlen(i8* %1)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %35, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 1
%43 = call i32 @strlen(i8* %1)
%44 = call i32 @strncpy(i8* %42, i8* %1, i32 %43)
%45 = call i32 @strlen(i8* %1)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %35, i64 %46
%48 = getelementptr inbounds i8, i8* %47, i64 1
%49 = call i32 @strlen(i8* %1)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 1
%53 = call i32 @strlen(i8* %2)
%54 = call i32 @strncpy(i8* %52, i8* %2, i32 %53)
%55 = shl nsw i32 %33, 1
%56 = add nsw i32 %55, 3
%57 = call i8* @malloc(i32 %56)
%58 = call i32 @memset(i8* %57, i32 0, i32 %56)
%59 = call i32 @base64_encode(i8* %35, i32 %33, i8* %57)
%60 = icmp eq i8* %35, null
br i1 %60, label %63, label %61
61: ; preds = %27
%62 = call i32 @free(i8* %35)
br label %63
63: ; preds = %61, %27
%64 = call i32 @strlen(i8* %57)
%65 = add nsw i32 %64, 3
%66 = call i8* @malloc(i32 %65)
%67 = call i32 @strlen(i8* %57)
%68 = add nsw i32 %67, 3
%69 = call i32 @memset(i8* %66, i32 0, i32 %68)
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %66, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* %57)
%71 = icmp eq i8* %57, null
br i1 %71, label %74, label %72
72: ; preds = %63
%73 = call i32 @free(i8* %57)
br label %74
74: ; preds = %72, %63
%75 = call i32 @strlen(i8* %66)
%76 = call i64 @medusaSend(i32 %0, i8* %66, i32 %75, i32 0)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %74
%79 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %80
80: ; preds = %78, %74
%81 = icmp eq i8* %66, null
br i1 %81, label %86, label %82
82: ; preds = %80, %23
%83 = phi i8* [ %25, %23 ], [ %66, %80 ]
%84 = phi i32 [ -1, %23 ], [ 0, %80 ]
%85 = call i32 @free(i8* %83)
br label %86
86: ; preds = %82, %80, %23
%87 = phi i32 [ -1, %23 ], [ 0, %80 ], [ %84, %82 ]
ret i32 %87
}