#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int ftserve_check_user(char *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int recv_data(int, char *, int);
int /*<<< orphan*/ send_response(int, int);
int ftserve_login(int sock_controll) {
  char buf[512];
  char user[512];
  char pass[512];
  memset(user, 0, 512);
  memset(pass, 0, 512);
  memset(buf, 0, 512);
  if ((recv_data(sock_controll, buf, sizeof(buf))) == -1) {
    perror("recv error \n");
    exit(1);
  }
  int i = 5;
  int n = 0;
  while (buf[i] != 0) {
    user[n++] = buf[i++];
  }
  send_response(sock_controll, 331);
  memset(buf, 0, 512);
  if ((recv_data(sock_controll, buf, sizeof(buf))) == -1) {
    perror("recv error\n");
    exit(1);
  }
  i = 5;
  n = 0;
  while (buf[i] != 0) {
    pass[n++] = buf[i++];
  }
  return (ftserve_check_user(user, pass));
}


x86 assembly (clang, -O0):
<ftserve_login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x620,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    -0x610(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1030 <recv_data@plt>
cmp    $0xffffffff,%eax
jne    11da <ftserve_login+0x7a>
lea    0xe35(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x5,-0x614(%rbp)
movl   $0x0,-0x618(%rbp)
movslq -0x614(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     123f <ftserve_login+0xdf>
mov    -0x614(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x614(%rbp)
cltq
mov    -0x210(%rbp,%rax,1),%cl
mov    -0x618(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x618(%rbp)
cltq
mov    %cl,-0x410(%rbp,%rax,1)
jmp    11ee <ftserve_login+0x8e>
mov    -0x4(%rbp),%edi
mov    $0x14b,%esi
call   1040 <send_response@plt>
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x200,%edx
call   1030 <recv_data@plt>
cmp    $0xffffffff,%eax
jne    1292 <ftserve_login+0x132>
lea    0xd8a(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x5,-0x614(%rbp)
movl   $0x0,-0x618(%rbp)
movslq -0x614(%rbp),%rax
movsbl -0x210(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     12f7 <ftserve_login+0x197>
mov    -0x614(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x614(%rbp)
cltq
mov    -0x210(%rbp,%rax,1),%cl
mov    -0x618(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x618(%rbp)
cltq
mov    %cl,-0x610(%rbp,%rax,1)
jmp    12a6 <ftserve_login+0x146>
lea    -0x410(%rbp),%rdi
lea    -0x610(%rbp),%rsi
call   1060 <ftserve_check_user@plt>
add    $0x620,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftserve_login>:
push   %rbp
push   %rbx
sub    $0x608,%rsp
mov    %edi,%ebp
lea    0x400(%rsp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
lea    0x200(%rsp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1030 <recv_data@plt>
cmp    $0xffffffff,%eax
je     1253 <ftserve_login+0xf3>
mov    0x5(%rsp),%al
test   %al,%al
je     11e4 <ftserve_login+0x84>
xor    %ecx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %al,0x400(%rsp,%rcx,1)
movzbl 0x6(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    11d0 <ftserve_login+0x70>
mov    %ebp,%edi
mov    $0x14b,%esi
call   1040 <send_response@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1050 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
call   1030 <recv_data@plt>
cmp    $0xffffffff,%eax
je     125c <ftserve_login+0xfc>
mov    0x5(%rsp),%al
test   %al,%al
je     1234 <ftserve_login+0xd4>
xor    %ecx,%ecx
mov    %al,0x200(%rsp,%rcx,1)
movzbl 0x6(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    1220 <ftserve_login+0xc0>
lea    0x400(%rsp),%rdi
lea    0x200(%rsp),%rsi
call   1060 <ftserve_check_user@plt>
add    $0x608,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xda6(%rip),%rdi
jmp    1263 <ftserve_login+0x103>
lea    0xdaa(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"recv error \0A\00"
@.str.1 = [12 x i8] c"recv error\0A\00"
define i32 @ftserve_login(i32 %0) {
%2 = alloca i32
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 512)
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 512)
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%13 = call i32 @memset(i8* %12, i32 0, i32 512)
%14 = load i32, i32* %2
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%16 = call i32 @recv_data(i32 %14, i8* %15, i32 512)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %1
store i32 5, i32* %6
store i32 0, i32* %7
br label %22
22: ; preds = %29, %21
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %39
29: ; preds = %22
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %37
store i8 %34, i8* %38
br label %22
39: ; preds = %22
%40 = load i32, i32* %2
%41 = call i32 @send_response(i32 %40, i32 331)
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%43 = call i32 @memset(i8* %42, i32 0, i32 512)
%44 = load i32, i32* %2
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%46 = call i32 @recv_data(i32 %44, i8* %45, i32 512)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %51
48: ; preds = %39
%49 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %39
store i32 5, i32* %6
store i32 0, i32* %7
br label %52
52: ; preds = %59, %51
%53 = load i32, i32* %6
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %69
59: ; preds = %52
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = load i32, i32* %7
%66 = add nsw i32 %65, 1
store i32 %66, i32* %7
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %67
store i8 %64, i8* %68
br label %52
69: ; preds = %52
%70 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%72 = call i32 @ftserve_check_user(i8* %70, i8* %71)
ret i32 %72
}

LLVM IR (-O2):
@.str = [13 x i8] c"recv error \0A\00"
@.str.1 = [12 x i8] c"recv error\0A\00"
define i32 @ftserve_login(i32 %0) {
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %6, i32 0, i32 512)
%9 = call i32 @memset(i8* %7, i32 0, i32 512)
%10 = call i32 @memset(i8* %5, i32 0, i32 512)
%11 = call i32 @recv_data(i32 %0, i8* %5, i32 512)
%12 = icmp eq i32 %11, -1
br i1 %12, label %17, label %13
13: ; preds = %1
%14 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 5
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %30, label %20
17: ; preds = %1
%18 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13, %20
%21 = phi i64 [ %24, %20 ], [ 5, %13 ]
%22 = phi i64 [ %25, %20 ], [ 0, %13 ]
%23 = phi i8 [ %28, %20 ], [ %15, %13 ]
%24 = add nuw nsw i64 %21, 1
%25 = add nuw i64 %22, 1
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %22
store i8 %23, i8* %26
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %24
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %20
30: ; preds = %20, %13
%31 = call i32 @send_response(i32 %0, i32 331)
%32 = call i32 @memset(i8* %5, i32 0, i32 512)
%33 = call i32 @recv_data(i32 %0, i8* %5, i32 512)
%34 = icmp eq i32 %33, -1
br i1 %34, label %38, label %35
35: ; preds = %30
%36 = load i8, i8* %14
%37 = icmp eq i8 %36, 0
br i1 %37, label %51, label %41
38: ; preds = %30
%39 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %35, %41
%42 = phi i64 [ %45, %41 ], [ 5, %35 ]
%43 = phi i64 [ %46, %41 ], [ 0, %35 ]
%44 = phi i8 [ %49, %41 ], [ %36, %35 ]
%45 = add nuw nsw i64 %42, 1
%46 = add nuw i64 %43, 1
%47 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 %43
store i8 %44, i8* %47
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 %45
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 0
br i1 %50, label %51, label %41
51: ; preds = %41, %35
%52 = call i32 @ftserve_check_user(i8* %6, i8* %7)
ret i32 %52
}