#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 */
struct ftpsub_buf {
  int dummy;
};

/* Variables and functions */
int OkResultCheck(struct ftpsub_buf *, int, char *, char *);
int OpenConnect(struct ftpsub_buf *, char *, int);
int RecvMessage_(struct ftpsub_buf *, int);
int SendMessage_(struct ftpsub_buf *, int);
int SndPASV(struct ftpsub_buf *, int, char *, int *);
int CmdPASV(struct ftpsub_buf *fbf, int sockfd) {
  int trans_sockfd;
  int iport;
  char sip[128 + 1];
  if (SndPASV(fbf, sockfd, sip, &iport) == -1) {
    return (-1);
  }
  if (SendMessage_(fbf, sockfd) == -1) {
    return (-1);
  }
  if ((trans_sockfd = OpenConnect(fbf, sip, iport)) == -1) {
    return (-1);
  }
  if (RecvMessage_(fbf, sockfd) == -1) {
    return (-1);
  }
  if (OkResultCheck(fbf, 2, "150", "125") == -1) {
    return (-1);
  }
  return (trans_sockfd);
}


x86 assembly (clang, -O0):
<CmdPASV>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0xa0(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1050 <SndPASV@plt>
cmp    $0xffffffff,%eax
jne    118e <CmdPASV+0x3e>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <CmdPASV+0xe2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <SendMessage_@plt>
cmp    $0xffffffff,%eax
jne    11af <CmdPASV+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <CmdPASV+0xe2>
mov    -0x10(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <OpenConnect@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    11da <CmdPASV+0x8a>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <CmdPASV+0xe2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <RecvMessage_@plt>
cmp    $0xffffffff,%eax
jne    11fb <CmdPASV+0xab>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <CmdPASV+0xe2>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
lea    0xdf5(%rip),%rdx
lea    0xdf2(%rip),%rcx
call   1070 <OkResultCheck@plt>
cmp    $0xffffffff,%eax
jne    122c <CmdPASV+0xdc>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <CmdPASV+0xe2>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CmdPASV>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1050 <SndPASV@plt>
mov    $0xffffffff,%r14d
cmp    $0xffffffff,%eax
je     11d8 <CmdPASV+0x88>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <SendMessage_@plt>
cmp    $0xffffffff,%eax
je     11d8 <CmdPASV+0x88>
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <OpenConnect@plt>
cmp    $0xffffffff,%eax
je     11d8 <CmdPASV+0x88>
mov    %eax,%r15d
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <RecvMessage_@plt>
cmp    $0xffffffff,%eax
je     11d8 <CmdPASV+0x88>
lea    0xe46(%rip),%rdx
lea    0xe43(%rip),%rcx
mov    %rbx,%rdi
mov    $0x2,%esi
call   1070 <OkResultCheck@plt>
cmp    $0xffffffff,%eax
cmove  %eax,%r15d
mov    %r15d,%r14d
mov    %r14d,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ftpsub_buf = type { i32 }
@.str = [4 x i8] c"150\00"
@.str.1 = [4 x i8] c"125\00"
define i32 @CmdPASV(%struct.ftpsub_buf* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.ftpsub_buf*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [129 x i8]
store %struct.ftpsub_buf* %0, %struct.ftpsub_buf** %4
store i32 %1, i32* %5
%9 = load %struct.ftpsub_buf*, %struct.ftpsub_buf** %4
%10 = load i32, i32* %5
%11 = getelementptr inbounds [129 x i8], [129 x i8]* %8, i64 0, i64 0
%12 = call i32 @SndPASV(%struct.ftpsub_buf* %9, i32 %10, i8* %11, i32* %7)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 -1, i32* %3
br label %41
15: ; preds = %2
%16 = load %struct.ftpsub_buf*, %struct.ftpsub_buf** %4
%17 = load i32, i32* %5
%18 = call i32 @SendMessage_(%struct.ftpsub_buf* %16, i32 %17)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 -1, i32* %3
br label %41
21: ; preds = %15
%22 = load %struct.ftpsub_buf*, %struct.ftpsub_buf** %4
%23 = getelementptr inbounds [129 x i8], [129 x i8]* %8, i64 0, i64 0
%24 = load i32, i32* %7
%25 = call i32 @OpenConnect(%struct.ftpsub_buf* %22, i8* %23, i32 %24)
store i32 %25, i32* %6
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 -1, i32* %3
br label %41
28: ; preds = %21
%29 = load %struct.ftpsub_buf*, %struct.ftpsub_buf** %4
%30 = load i32, i32* %5
%31 = call i32 @RecvMessage_(%struct.ftpsub_buf* %29, i32 %30)
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 -1, i32* %3
br label %41
34: ; preds = %28
%35 = load %struct.ftpsub_buf*, %struct.ftpsub_buf** %4
%36 = call i32 @OkResultCheck(%struct.ftpsub_buf* %35, i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i32 %36, -1
br i1 %37, label %38, label %39
38: ; preds = %34
store i32 -1, i32* %3
br label %41
39: ; preds = %34
%40 = load i32, i32* %6
store i32 %40, i32* %3
br label %41
41: ; preds = %39, %38, %33, %27, %20, %14
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
%struct.ftpsub_buf = type { i32 }
@.str = [4 x i8] c"150\00"
@.str.1 = [4 x i8] c"125\00"
define i32 @CmdPASV(%struct.ftpsub_buf* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [129 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [129 x i8], [129 x i8]* %4, i64 0, i64 0
%7 = call i32 @SndPASV(%struct.ftpsub_buf* %0, i32 %1, i8* %6, i32* %3)
%8 = icmp eq i32 %7, -1
br i1 %8, label %23, label %9
9: ; preds = %2
%10 = call i32 @SendMessage_(%struct.ftpsub_buf* %0, i32 %1)
%11 = icmp eq i32 %10, -1
br i1 %11, label %23, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i32 @OpenConnect(%struct.ftpsub_buf* %0, i8* %6, i32 %13)
%15 = icmp eq i32 %14, -1
br i1 %15, label %23, label %16
16: ; preds = %12
%17 = call i32 @RecvMessage_(%struct.ftpsub_buf* %0, i32 %1)
%18 = icmp eq i32 %17, -1
br i1 %18, label %23, label %19
19: ; preds = %16
%20 = call i32 @OkResultCheck(%struct.ftpsub_buf* %0, i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32 %20, -1
%22 = select i1 %21, i32 -1, i32 %14
br label %23
23: ; preds = %19, %16, %12, %9, %2
%24 = phi i32 [ -1, %2 ], [ -1, %9 ], [ -1, %12 ], [ -1, %16 ], [ %22, %19 ]
ret i32 %24
}