#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 ftp_connect(char *, char *);
int /*<<< orphan*/ ftp_login(char *, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ serve();
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char **argv) {
  char port[10];
  char user[50], passwd[50];
  int res;
  if (argc == 3)
    strcpy(port, argv[2]);
  else if (argc == 2)
    strcpy(port, "21");
  else {
    printf("Usage: recftp server port\n");
    return 0;
  }
  if (ftp_connect(argv[1], port) > -1)
    ftp_login(argv[1], port);
  serve();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    1189 <main+0x39>
lea    -0x1a(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1030 <strcpy@plt>
jmp    11c5 <main+0x75>
cmpl   $0x2,-0x8(%rbp)
jne    11a8 <main+0x58>
lea    -0x1a(%rbp),%rdi
lea    0xe62(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11c0 <main+0x70>
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11fe <main+0xae>
jmp    11c5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1a(%rbp),%rsi
call   1070 <ftp_connect@plt>
cmp    $0xffffffff,%eax
jle    11f0 <main+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1a(%rbp),%rsi
call   1050 <ftp_login@plt>
mov    $0x0,%al
call   1060 <serve@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
je     116a <main+0x1a>
cmp    $0x3,%edi
jne    11a5 <main+0x55>
mov    0x10(%rbx),%rsi
jmp    1171 <main+0x21>
lea    0xe8f(%rip),%rsi
lea    0xe(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%rdi
mov    %r14,%rsi
call   1070 <ftp_connect@plt>
test   %eax,%eax
js     119c <main+0x4c>
mov    0x8(%rbx),%rdi
lea    0xe(%rsp),%rsi
call   1050 <ftp_login@plt>
xor    %eax,%eax
call   1060 <serve@plt>
jmp    11b1 <main+0x61>
lea    0xe57(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"21\00"
@.str.1 = [27 x i8] c"Usage: recftp server port\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [10 x i8]
%7 = alloca [50 x i8]
%8 = alloca [50 x i8]
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 3
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @strcpy(i8* %13, i8* %16)
br label %27
18: ; preds = %2
%19 = load i32, i32* %4
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %26
24: ; preds = %18
%25 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %42
26: ; preds = %21
br label %27
27: ; preds = %26, %12
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%32 = call i32 @ftp_connect(i8* %30, i8* %31)
%33 = icmp sgt i32 %32, -1
br i1 %33, label %34, label %40
34: ; preds = %27
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%39 = call i32 @ftp_login(i8* %37, i8* %38)
br label %40
40: ; preds = %34, %27
%41 = call i32 (...) @serve()
store i32 0, i32* %3
br label %42
42: ; preds = %40, %24
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@.str = [3 x i8] c"21\00"
@str = [26 x i8] c"Usage: recftp server port\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10 x i8]
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
switch i32 %0, label %8 [
i32 3, label %5
i32 2, label %10
]
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 2
%7 = load i8*, i8** %6
br label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
br label %22
10: ; preds = %2, %5
%11 = phi i8* [ %7, %5 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = call i32 @strcpy(i8* %4, i8* %11)
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @ftp_connect(i8* %14, i8* %4)
%16 = icmp sgt i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8*, i8** %13
%19 = call i32 @ftp_login(i8* %18, i8* %4)
br label %20
20: ; preds = %17, %10
%21 = call i32 (...) @serve()
br label %22
22: ; preds = %20, %8
ret i32 0
}