#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*/ username;
typedef int /*<<< orphan*/ password;

/* Variables and functions */
int auth_pass(char *, char *);
int /*<<< orphan*/ elog(char *);
int /*<<< orphan*/ read_line(int, char *, int);
int /*<<< orphan*/ send(int, char *, int, int /*<<< orphan*/);
int sprintf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int do_auth(int fd, char *param) {
  while (1) {
    char username[128], password[128];
    char buf[128] = "334 VXNlcm5hbWU6\r\n";
    send(fd, buf, strlen(buf), 0);
    read_line(fd, username, sizeof(username));
    strcpy(buf, "334 UGFzc3dvcmQ6\r\n");
    send(fd, buf, strlen(buf), 0);
    read_line(fd, password, sizeof(password));
    do {
      char format_msg[1024] = {0};
      int i = sprintf(format_msg, "[%s %s:%d]:", "08:25:37",
                      "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                      "outputs/2022-01-22/02-19-57/repos/sundyCoder/STMP_POP3/"
                      "refs/heads/master/smtpserver/smtp_ser.c",
                      149);
      sprintf(format_msg + i, "%d:username=%s,%d:password=%s\n",
              strlen(username), username, strlen(password), password);
      elog(format_msg);
    } while (0);
    int ret = auth_pass(username, password);
    if (ret) {
      strcpy(buf, "235 OK, go ahead\r\n");
      send(fd, buf, strlen(buf), 0);
      return 1;
    } else {
      strcpy(buf, "500 ERR,input again!\r\n");
      send(fd, buf, strlen(buf), 0);
      continue;
    }
  }
}


x86 assembly (clang, -O0):
<do_auth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5f0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x190(%rbp),%rdi
lea    0xe50(%rip),%rsi
mov    $0x80,%edx
call   1070 <memcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x5b4(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x5b0(%rbp)
lea    -0x190(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5b4(%rbp),%edi
mov    -0x5b0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x4(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1090 <read_line@plt>
lea    -0x190(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x5a4(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x5a0(%rbp)
lea    -0x190(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5a4(%rbp),%edi
mov    -0x5a0(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    -0x4(%rbp),%edi
lea    -0x110(%rbp),%rsi
mov    $0x80,%edx
call   1090 <read_line@plt>
lea    -0x590(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x590(%rbp),%rdi
lea    0xe0b(%rip),%rsi
lea    0xe10(%rip),%rdx
lea    0xe12(%rip),%rcx
mov    $0x95,%r8d
mov    $0x0,%al
call   10b0 <sprintf@plt>
mov    %eax,-0x594(%rbp)
lea    -0x590(%rbp),%rax
movslq -0x594(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x5d0(%rbp)
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x5c4(%rbp)
lea    -0x90(%rbp),%rax
mov    %rax,-0x5c0(%rbp)
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5d0(%rbp),%rdi
mov    -0x5c4(%rbp),%edx
mov    -0x5c0(%rbp),%rcx
mov    %eax,%r8d
lea    -0x110(%rbp),%r9
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x590(%rbp),%rdi
call   1080 <elog@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   10a0 <auth_pass@plt>
mov    %eax,-0x598(%rbp)
cmpl   $0x0,-0x598(%rbp)
je     13a5 <do_auth+0x215>
lea    -0x190(%rbp),%rdi
lea    0xe05(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x5dc(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x5d8(%rbp)
lea    -0x190(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5dc(%rbp),%edi
mov    -0x5d8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    $0x1,%eax
add    $0x5f0,%rsp
pop    %rbp
ret
lea    -0x190(%rbp),%rdi
lea    0xdbe(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x5ec(%rbp)
lea    -0x190(%rbp),%rax
mov    %rax,-0x5e8(%rbp)
lea    -0x190(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5ec(%rbp),%edi
mov    -0x5e8(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    11a2 <do_auth+0x12>

x86 assembly (clang, -O2):
<do_auth>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x598,%rsp
mov    %edi,%ebx
lea    0x10(%rsp),%rbp
mov    %edi,0xc(%rsp)
nopl   0x0(%rax)
movaps 0xec9(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xe8e(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe72(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe56(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe3a(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe1e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe02(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %ebx,%edi
lea    0x90(%rsp),%rsi
mov    $0x80,%edx
call   1080 <read_line@plt>
mov    %rbp,%rdi
lea    0xe49(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %rbp,%r13
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %ebx,%edi
lea    0x110(%rsp),%r14
mov    %r14,%rsi
mov    $0x80,%edx
call   1080 <read_line@plt>
mov    $0x400,%edx
lea    0x190(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    %r15,%rdi
lea    0xe06(%rip),%rsi
lea    0xe0b(%rip),%rdx
lea    0xe0d(%rip),%rcx
mov    $0x95,%r8d
xor    %eax,%eax
call   10a0 <sprintf@plt>
cltq
lea    (%rsp,%rax,1),%r12
add    $0x190,%r12
lea    0x90(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r12,%rdi
lea    0xe66(%rip),%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    %eax,%r8d
mov    %r14,%r9
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
call   1070 <elog@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <auth_pass@plt>
test   %eax,%eax
jne    1333 <do_auth+0x1b3>
mov    %r13,%rbp
mov    %r13,%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
mov    %r13,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    11a0 <do_auth+0x20>
lea    0xe24(%rip),%rsi
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    $0x1,%eax
add    $0x598,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.do_auth.buf = [128 x i8] c"334 VXNlcm5hbWU6\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [19 x i8] c"334 UGFzc3dvcmQ6\0D\0A\00"
@.str.1 = [12 x i8] c"[%s %s:%d]:\00"
@.str.2 = [9 x i8] c"08:25:37\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sundyCoder/STMP_POP3/refs/heads/master/smtpserver/smtp_ser.c\00"
@.str.4 = [31 x i8] c"%d:username=%s,%d:password=%s\0A\00"
@.str.5 = [19 x i8] c"235 OK, go ahead\0D\0A\00"
@.str.6 = [23 x i8] c"500 ERR,input again!\0D\0A\00"
define i32 @do_auth(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca [128 x i8]
%8 = alloca [1024 x i8]
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
br label %11
11: ; preds = %2, %62
%12 = bitcast [128 x i8]* %7 to i8*
%13 = load i32, i32* %3
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @send(i32 %13, i8* %14, i32 %16, i32 0)
%18 = load i32, i32* %3
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%20 = call i32 @read_line(i32 %18, i8* %19, i32 128)
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%22 = call i32 @strcpy(i8* %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = call i32 @send(i32 %23, i8* %24, i32 %26, i32 0)
%28 = load i32, i32* %3
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%30 = call i32 @read_line(i32 %28, i8* %29, i32 128)
br label %31
31: ; preds = %11
%32 = bitcast [1024 x i8]* %8 to i8*
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 149)
store i32 %34, i32* %9
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%40 = call i32 @strlen(i8* %39)
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
%44 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%45 = call i32 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %40, i8* %41, i32 %43, i8* %44)
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%47 = call i32 @elog(i8* %46)
br label %48
48: ; preds = %31
%49 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%51 = call i32 @auth_pass(i8* %49, i8* %50)
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %48
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%56 = call i32 @strcpy(i8* %55, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32, i32* %3
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = call i32 @send(i32 %57, i8* %58, i32 %60, i32 0)
ret i32 1
62: ; preds = %48
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%64 = call i32 @strcpy(i8* %63, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%65 = load i32, i32* %3
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%68 = call i32 @strlen(i8* %67)
%69 = call i32 @send(i32 %65, i8* %66, i32 %68, i32 0)
br label %11
}

LLVM IR (-O2):
@__const.do_auth.buf = [128 x i8] c"334 VXNlcm5hbWU6\0D\0A\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [19 x i8] c"334 UGFzc3dvcmQ6\0D\0A\00"
@.str.1 = [12 x i8] c"[%s %s:%d]:\00"
@.str.2 = [9 x i8] c"08:25:37\00"
@.str.3 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/sundyCoder/STMP_POP3/refs/heads/master/smtpserver/smtp_ser.c\00"
@.str.4 = [31 x i8] c"%d:username=%s,%d:password=%s\0A\00"
@.str.5 = [19 x i8] c"235 OK, go ahead\0D\0A\00"
@.str.6 = [23 x i8] c"500 ERR,input again!\0D\0A\00"
define i32 @do_auth(i32 %0, i8* nocapture readnone %1) {
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
br label %11
11: ; preds = %28, %2
%12 = call i32 @strlen(i8* %9)
%13 = call i32 @send(i32 %0, i8* %9, i32 %12, i32 0)
%14 = call i32 @read_line(i32 %0, i8* %7, i32 128)
%15 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @strlen(i8* %9)
%17 = call i32 @send(i32 %0, i8* %9, i32 %16, i32 0)
%18 = call i32 @read_line(i32 %0, i8* %8, i32 128)
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.3, i64 0, i64 0), i32 149)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 %20
%22 = call i32 @strlen(i8* %7)
%23 = call i32 @strlen(i8* %8)
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %22, i8* %7, i32 %23, i8* %8)
%25 = call i32 @elog(i8* %10)
%26 = call i32 @auth_pass(i8* %7, i8* %8)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %11
%29 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 @strlen(i8* %9)
%31 = call i32 @send(i32 %0, i8* %9, i32 %30, i32 0)
br label %11
32: ; preds = %11
%33 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 @strlen(i8* %9)
%35 = call i32 @send(i32 %0, i8* %9, i32 %34, i32 0)
ret i32 1
}