int ftp_close_datasockfd(int sockfd, int datasockfd) {
  char recvbuf[1024] = {'\0'};
  if (sockfd < 0 || datasockfd < 0) {
    return -1;
  }
  close(datasockfd);
  read_socket(sockfd, recvbuf, sizeof(recvbuf));
  if (strncmp(recvbuf, "226", 3) == 0) {
    printf("###%s(),send commend 226 get file sucessful!\n", __func__);
    return 0;
  }
  printf("###%s(),send commend  get file failed!\n", __func__);
  return -1;
}


x86 assembly (clang, -O0):
<ftp_close_datasockfd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1188 <ftp_close_datasockfd+0x38>
cmpl   $0x0,-0xc(%rbp)
jge    1194 <ftp_close_datasockfd+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    1212 <ftp_close_datasockfd+0xc2>
mov    -0xc(%rbp),%edi
mov    $0x0,%al
call   1070 <close@plt>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
mov    $0x0,%al
call   1050 <read_socket@plt>
lea    -0x410(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11f6 <ftp_close_datasockfd+0xa6>
lea    0xe28(%rip),%rdi
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1212 <ftp_close_datasockfd+0xc2>
lea    0xe4a(%rip),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftp_close_datasockfd>:
push   %rbp
push   %rbx
sub    $0x408,%rsp
mov    %esi,%ebp
mov    %edi,%ebx
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    %ebp,%eax
or     %ebx,%eax
js     11b8 <ftp_close_datasockfd+0x78>
mov    %ebp,%edi
xor    %eax,%eax
call   1060 <close@plt>
mov    %rsp,%rsi
mov    $0x400,%edx
mov    %ebx,%edi
xor    %eax,%eax
call   1040 <read_socket@plt>
mov    $0x3232,%eax
xor    (%rsp),%eax
movzbl 0x2(%rsp),%ecx
xor    $0x36,%ecx
xor    %ebx,%ebx
or     %ax,%cx
setne  %bl
lea    0xe69(%rip),%rax
lea    0xea5(%rip),%rdi
cmove  %rax,%rdi
neg    %ebx
lea    0xe83(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11bd <ftp_close_datasockfd+0x7d>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"226\00"
@.str.1 = [46 x i8] c"###%s(),send commend 226 get file sucessful!\0A\00"
@__func__.ftp_close_datasockfd = [21 x i8] c"ftp_close_datasockfd\00"
@.str.2 = [40 x i8] c"###%s(),send commend get file failed!\0A\00"
define i32 @ftp_close_datasockfd(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = bitcast [1024 x i8]* %6 to i8*
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %10, %2
store i32 -1, i32* %3
br label %27
14: ; preds = %10
%15 = load i32, i32* %5
%16 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %15)
%17 = load i32, i32* %4
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%19 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read_socket to i32 (i32, i8*, i64, ...)*)(i32 %17, i8* %18, i64 1024)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.ftp_close_datasockfd, i64 0, i64 0))
store i32 0, i32* %3
br label %27
25: ; preds = %14
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.ftp_close_datasockfd, i64 0, i64 0))
store i32 -1, i32* %3
br label %27
27: ; preds = %25, %23, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"226\00"
@.str.1 = [46 x i8] c"###%s(),send commend 226 get file sucessful!\0A\00"
@__func__.ftp_close_datasockfd = [21 x i8] c"ftp_close_datasockfd\00"
@.str.2 = [40 x i8] c"###%s(),send commend get file failed!\0A\00"
define i32 @ftp_close_datasockfd(i32 %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = or i32 %1, %0
%6 = icmp sgt i32 %5, -1
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %1)
%9 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read_socket to i32 (i32, i8*, i64, ...)*)(i32 %0, i8* %4, i64 1024)
%10 = call i32 @bcmp(i8* dereferenceable(3) %4, i8* dereferenceable(3) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 3)
%11 = icmp eq i32 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0)
%13 = xor i1 %11, true
%14 = sext i1 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %12, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @__func__.ftp_close_datasockfd, i64 0, i64 0))
br label %16
16: ; preds = %7, %2
%17 = phi i32 [ -1, %2 ], [ %14, %7 ]
ret i32 %17
}