#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct stat {
  int dummy;
};
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ serv_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ atoi(char *);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getFunction(char *, int, char *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ lsFunction(char *, int, char *);
int /*<<< orphan*/ mgetFunction(char *, int, char *, struct sockaddr_in,
                                char *);
int /*<<< orphan*/ pexit(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putFunction(char *, int, int, char *, long long,
                               struct stat);
int /*<<< orphan*/ read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int i, sockfd, filedesc;
  long long ret = 0;
  char buffer[8096];
  static struct sockaddr_in serv_addr;
  struct stat stat_buf;
  char fileName[50];
  if (argc != 5) {
    printf("Usage: ./client <SERVER IP ADDRESS> <LISTENING PORT> <COMMAND> "
           "<FILE/DIR>\n");
    printf("Example: ./client 127.0.0.1 8141 get remoteFileName\n./client "
           "127.0.0.1 8141 [put/get/ls] [localFileName/dir]\n\n");
    exit(1);
  }
  printf("client trying to connect to IP = %s PORT = %s method= %s for "
         "FILE/DIR= %s\n",
         argv[1], argv[2], argv[3], argv[4]);
  strcpy(fileName, argv[4]);
  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    pexit("socket() failed");
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = inet_addr(argv[1]);
  serv_addr.sin_port = htons(atoi(argv[2]));
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    pexit("connect() failed");
  if (!strcmp(argv[3], "get")) {
    printf("\n\n-------------------------\n| A começar download... "
           "|\n-------------------------\n\n");
    getFunction(buffer, sockfd, fileName);
  } else if (!strcmp(argv[3], "put")) {
    putFunction(buffer, sockfd, filedesc, fileName, ret, stat_buf);
  } else if (!strcmp(argv[3], "ls")) {
    lsFunction(buffer, sockfd, fileName);
  } else if (!strcmp(argv[3], "mget")) {
    mgetFunction(buffer, sockfd, fileName, serv_addr, argv[0]);
  } else if (!strcmp(argv[3], "cd")) {
    char *token;
    sprintf(buffer, "cd %s", fileName);
    write(sockfd, buffer, strlen(buffer));
    read(sockfd, buffer, 8096);
    getFunction(buffer, sockfd, "a0.png");
    printf("%s", buffer);
    sprintf(buffer, "reset");
    write(sockfd, buffer, strlen(buffer));
    read(sockfd, buffer, 8096);
    printf("%s", buffer);
  } else {
    printf("unsuported method\n");
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     1271 <main+0x51>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%r8
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x2010(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
call   1030 <strcpy@plt>
mov    0x2d2e(%rip),%rax
mov    (%rax),%edi
mov    0x2d15(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1140 <socket@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    12e4 <main+0xc4>
lea    0xe26(%rip),%rdi
call   1110 <pexit@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2dc9(%rip)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x2db2(%rip)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %eax,0x2d94(%rip)
mov    -0x18(%rbp),%edi
lea    0x2d8a(%rip),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    134a <main+0x12a>
lea    0xdd0(%rip),%rdi
call   1110 <pexit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe28(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    1390 <main+0x170>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1fd0(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x2010(%rbp),%rdx
call   1100 <getFunction@plt>
jmp    15c0 <main+0x3a0>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdda(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    13d6 <main+0x1b6>
lea    -0x1fd0(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0x2010(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x1fd8(%rbp),%r9d
call   1080 <putFunction@plt>
jmp    15bb <main+0x39b>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd98(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    140e <main+0x1ee>
lea    -0x1fd0(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x2010(%rbp),%rdx
call   1120 <lsFunction@plt>
jmp    15b6 <main+0x396>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd63(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    1475 <main+0x255>
lea    -0x1fd0(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    -0x2010(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%r9
mov    0x2c6a(%rip),%rax
mov    %rax,-0x2020(%rbp)
mov    0x2c65(%rip),%eax
mov    %eax,-0x2018(%rbp)
mov    -0x2020(%rbp),%rcx
mov    -0x2018(%rbp),%r8d
call   1130 <mgetFunction@plt>
jmp    15b1 <main+0x391>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd01(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%eax
jne    159e <main+0x37e>
lea    -0x1fd0(%rbp),%rdi
lea    -0x2010(%rbp),%rdx
lea    0xce1(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2044(%rbp)
lea    -0x1fd0(%rbp),%rax
mov    %rax,-0x2040(%rbp)
lea    -0x1fd0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2044(%rbp),%edi
mov    -0x2040(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x1fd0(%rbp),%rsi
mov    $0x1fa0,%edx
call   1090 <read@plt>
lea    -0x1fd0(%rbp),%rdi
mov    -0x18(%rbp),%esi
lea    0xc84(%rip),%rdx
call   1100 <getFunction@plt>
lea    -0x1fd0(%rbp),%rsi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x1fd0(%rbp),%rdi
lea    0xc63(%rip),%rsi
mov    $0x0,%al
call   10d0 <sprintf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2034(%rbp)
lea    -0x1fd0(%rbp),%rax
mov    %rax,-0x2030(%rbp)
lea    -0x1fd0(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2034(%rbp),%edi
mov    -0x2030(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    -0x18(%rbp),%edi
lea    -0x1fd0(%rbp),%rsi
mov    $0x1fa0,%edx
call   1090 <read@plt>
lea    -0x1fd0(%rbp),%rsi
lea    0xbf9(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15ac <main+0x38c>
lea    0xbf6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15b1 <main+0x391>
jmp    15b6 <main+0x396>
jmp    15bb <main+0x39b>
jmp    15c0 <main+0x3a0>
mov    $0x1,%eax
add    $0x2050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1fe0,%rsp
cmp    $0x5,%edi
jne    1496 <main+0x266>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rcx
mov    0x20(%rbx),%r8
lea    0xda2(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x20(%rbx),%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
mov    0x2d70(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d56(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1150 <socket@plt>
mov    %eax,%r14d
test   %eax,%eax
jns    129e <main+0x6e>
lea    0xdb2(%rip),%rdi
call   1120 <pexit@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x2e21(%rip)
lea    0x2e12(%rip),%rbp
mov    0x8(%rbx),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x2e07(%rip)
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%edi
call   1070 <htons@plt>
mov    %eax,0x2ded(%rip)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0xc,%edx
call   1100 <connect@plt>
test   %rax,%rax
jns    12f4 <main+0xc4>
lea    0xd6c(%rip),%rdi
call   1120 <pexit@plt>
mov    0x18(%rbx),%rbp
lea    0xd75(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     136c <main+0x13c>
lea    0xd5a(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     138d <main+0x15d>
lea    0xd4b(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     13a5 <main+0x175>
lea    0xd3b(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     13ba <main+0x18a>
lea    0xd2d(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <strcmp@plt>
test   %eax,%eax
je     13e0 <main+0x1b0>
lea    0xd7e(%rip),%rdi
call   1040 <puts@plt>
jmp    1485 <main+0x255>
lea    0xd1b(%rip),%rdi
call   1040 <puts@plt>
lea    0x40(%rsp),%rdi
mov    %rsp,%rdx
mov    %r14d,%esi
call   1110 <getFunction@plt>
jmp    1485 <main+0x255>
lea    0x40(%rsp),%rdi
mov    %rsp,%rcx
mov    %r14d,%esi
xor    %r8d,%r8d
call   1090 <putFunction@plt>
jmp    1485 <main+0x255>
lea    0x40(%rsp),%rdi
mov    %rsp,%rdx
mov    %r14d,%esi
call   1130 <lsFunction@plt>
jmp    1485 <main+0x255>
mov    (%rbx),%r9
mov    0x2cfc(%rip),%rcx
mov    0x2cfd(%rip),%r8d
lea    0x40(%rsp),%rdi
mov    %rsp,%rdx
mov    %r14d,%esi
call   1140 <mgetFunction@plt>
jmp    1485 <main+0x255>
lea    0xc94(%rip),%rsi
lea    0x40(%rsp),%rbx
mov    %rsp,%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   10e0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x1fa0,%edx
call   10a0 <read@plt>
lea    0xc5c(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1110 <getFunction@plt>
lea    0xc47(%rip),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
movl   $0x65736572,0x40(%rsp)
65
movw   $0x74,0x44(%rsp)
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x1fa0,%edx
call   10a0 <read@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%eax
add    $0x1fe0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xc55(%rip),%rdi
call   1040 <puts@plt>
lea    0xc93(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.stat = type { i32 }
%struct.sockaddr = type { i32 }
@main.serv_addr = internal global %struct.sockaddr_in zeroinitializer
@.str = [75 x i8] c"Usage: ./client <SERVER IP ADDRESS> <LISTENING PORT> <COMMAND> <FILE/DIR>\0A\00"
@.str.1 = [111 x i8] c"Example: ./client 127.0.0.1 8141 get remoteFileName\0A./client 127.0.0.1 8141 [put/get/ls] [localFileName/dir]\0A\0A\00"
@.str.2 = [75 x i8] c"client trying to connect to IP = %s PORT = %s method= %s for FILE/DIR= %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [16 x i8] c"socket() failed\00"
@.str.4 = [17 x i8] c"connect() failed\00"
@.str.5 = [4 x i8] c"get\00"
@.str.6 = [83 x i8] c"\0A\0A-------------------------\0A| A come\C3\A7ar download... |\0A-------------------------\0A\0A\00"
@.str.7 = [4 x i8] c"put\00"
@.str.8 = [3 x i8] c"ls\00"
@.str.9 = [5 x i8] c"mget\00"
@.str.10 = [3 x i8] c"cd\00"
@.str.11 = [6 x i8] c"cd %s\00"
@.str.12 = [7 x i8] c"a0.png\00"
@.str.13 = [3 x i8] c"%s\00"
@.str.14 = [6 x i8] c"reset\00"
@.str.15 = [19 x i8] c"unsuported method\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca [8096 x i8]
%11 = alloca %struct.stat
%12 = alloca [50 x i8]
%13 = alloca { i64, i32 }
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %9
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 5
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([111 x i8], [111 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 4
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %27, i8* %30, i8* %33)
%35 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = call i32 @strcpy(i8* %35, i8* %38)
%40 = load i32, i32* @AF_INET
%41 = load i32, i32* @SOCK_STREAM
%42 = call i32 @socket(i32 %40, i32 %41, i32 0)
store i32 %42, i32* %7
%43 = icmp slt i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %21
%45 = call i32 @pexit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %46
46: ; preds = %44, %21
%47 = load i32, i32* @AF_INET
store i32 %47, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i32 0, i32 2)
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @inet_addr(i8* %50)
store i32 %51, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i32 0, i32 1, i32 0)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
%56 = call i32 @htons(i32 %55)
store i32 %56, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i32 0, i32 0)
%57 = load i32, i32* %7
%58 = call i64 @connect(i32 %57, %struct.sockaddr* bitcast (%struct.sockaddr_in* @main.serv_addr to %struct.sockaddr*), i32 12)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %46
%61 = call i32 @pexit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %46
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 3
%65 = load i8*, i8** %64
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %74, label %68
68: ; preds = %62
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.6, i64 0, i64 0))
%70 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%71 = load i32, i32* %7
%72 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%73 = call i32 @getFunction(i8* %70, i32 %71, i8* %72)
br label %160
74: ; preds = %62
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 3
%77 = load i8*, i8** %76
%78 = call i32 @strcmp(i8* %77, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%79 = icmp ne i32 %78, 0
br i1 %79, label %89, label %80
80: ; preds = %74
%81 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%82 = load i32, i32* %7
%83 = load i32, i32* %8
%84 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%85 = load i64, i64* %9
%86 = getelementptr inbounds %struct.stat, %struct.stat* %11, i32 0, i32 0
%87 = load i32, i32* %86
%88 = call i32 @putFunction(i8* %81, i32 %82, i32 %83, i8* %84, i64 %85, i32 %87)
br label %159
89: ; preds = %74
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 3
%92 = load i8*, i8** %91
%93 = call i32 @strcmp(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%94 = icmp ne i32 %93, 0
br i1 %94, label %100, label %95
95: ; preds = %89
%96 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%97 = load i32, i32* %7
%98 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%99 = call i32 @lsFunction(i8* %96, i32 %97, i8* %98)
br label %158
100: ; preds = %89
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 3
%103 = load i8*, i8** %102
%104 = call i32 @strcmp(i8* %103, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%105 = icmp ne i32 %104, 0
br i1 %105, label %119, label %106
106: ; preds = %100
%107 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%108 = load i32, i32* %7
%109 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = bitcast { i64, i32 }* %13 to i8*
%114 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %13, i32 0, i32 0
%115 = load i64, i64* %114
%116 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %13, i32 0, i32 1
%117 = load i32, i32* %116
%118 = call i32 @mgetFunction(i8* %107, i32 %108, i8* %109, i64 %115, i32 %117, i8* %112)
br label %157
119: ; preds = %100
%120 = load i8**, i8*** %5
%121 = getelementptr inbounds i8*, i8** %120, i64 3
%122 = load i8*, i8** %121
%123 = call i32 @strcmp(i8* %122, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%124 = icmp ne i32 %123, 0
br i1 %124, label %154, label %125
125: ; preds = %119
%126 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%127 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
%128 = call i32 (i8*, i8*, ...) @sprintf(i8* %126, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %127)
%129 = load i32, i32* %7
%130 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%131 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%132 = call i32 @strlen(i8* %131)
%133 = call i32 @write(i32 %129, i8* %130, i32 %132)
%134 = load i32, i32* %7
%135 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%136 = call i32 @read(i32 %134, i8* %135, i32 8096)
%137 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%138 = load i32, i32* %7
%139 = call i32 @getFunction(i8* %137, i32 %138, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%140 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %140)
%142 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%143 = call i32 (i8*, i8*, ...) @sprintf(i8* %142, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
%144 = load i32, i32* %7
%145 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%146 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%147 = call i32 @strlen(i8* %146)
%148 = call i32 @write(i32 %144, i8* %145, i32 %147)
%149 = load i32, i32* %7
%150 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%151 = call i32 @read(i32 %149, i8* %150, i32 8096)
%152 = getelementptr inbounds [8096 x i8], [8096 x i8]* %10, i64 0, i64 0
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %152)
br label %156
154: ; preds = %119
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.15, i64 0, i64 0))
br label %156
156: ; preds = %154, %125
br label %157
157: ; preds = %156, %106
br label %158
158: ; preds = %157, %95
br label %159
159: ; preds = %158, %80
br label %160
160: ; preds = %159, %68
ret i32 1
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@main.serv_addr = internal global %struct.sockaddr_in zeroinitializer
@.str.2 = [75 x i8] c"client trying to connect to IP = %s PORT = %s method= %s for FILE/DIR= %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.3 = [16 x i8] c"socket() failed\00"
@.str.4 = [17 x i8] c"connect() failed\00"
@.str.5 = [4 x i8] c"get\00"
@.str.7 = [4 x i8] c"put\00"
@.str.8 = [3 x i8] c"ls\00"
@.str.9 = [5 x i8] c"mget\00"
@.str.10 = [3 x i8] c"cd\00"
@.str.11 = [6 x i8] c"cd %s\00"
@.str.12 = [7 x i8] c"a0.png\00"
@.str.13 = [3 x i8] c"%s\00"
@.str.14 = [6 x i8] c"reset\00"
@str = [82 x i8] c"\0A\0A-------------------------\0A| A come\C3\A7ar download... |\0A-------------------------\0A\00"
@str.16 = [18 x i8] c"unsuported method\00"
@str.17 = [74 x i8] c"Usage: ./client <SERVER IP ADDRESS> <LISTENING PORT> <COMMAND> <FILE/DIR>\00"
@str.18 = [110 x i8] c"Example: ./client 127.0.0.1 8141 get remoteFileName\0A./client 127.0.0.1 8141 [put/get/ls] [localFileName/dir]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8096 x i8]
%4 = alloca [50 x i8]
%5 = getelementptr inbounds [8096 x i8], [8096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [50 x i8], [50 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 5
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.17, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([110 x i8], [110 x i8]* @str.18, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %1, i64 4
%20 = load i8*, i8** %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0), i8* %14, i8* %16, i8* %18, i8* %20)
%22 = load i8*, i8** %19
%23 = call i32 @strcpy(i8* %6, i8* %22)
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_STREAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %12
%29 = call i32 @pexit(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %28, %12
%31 = load i32, i32* @AF_INET
store i32 %31, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i64 0, i32 2)
%32 = load i8*, i8** %13
%33 = call i32 @inet_addr(i8* %32)
store i32 %33, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i64 0, i32 1, i32 0)
%34 = load i8*, i8** %15
%35 = call i32 @atoi(i8* %34)
%36 = call i32 @htons(i32 %35)
store i32 %36, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i64 0, i32 0)
%37 = call i64 @connect(i32 %26, %struct.sockaddr* bitcast (%struct.sockaddr_in* @main.serv_addr to %struct.sockaddr*), i32 12)
%38 = icmp slt i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %30
%40 = call i32 @pexit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %30
%42 = load i8*, i8** %17
%43 = call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str, i64 0, i64 0))
%47 = call i32 @getFunction(i8* %5, i32 %26, i8* %6)
br label %82
48: ; preds = %41
%49 = call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @putFunction(i8* %5, i32 %26, i32 undef, i8* %6, i64 0, i32 undef)
br label %82
53: ; preds = %48
%54 = call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%55 = icmp eq i32 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @lsFunction(i8* %5, i32 %26, i8* %6)
br label %82
58: ; preds = %53
%59 = call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %66
61: ; preds = %58
%62 = load i8*, i8** %1
%63 = load i64, i64* bitcast (%struct.sockaddr_in* @main.serv_addr to i64*)
%64 = load i32, i32* getelementptr inbounds (%struct.sockaddr_in, %struct.sockaddr_in* @main.serv_addr, i64 0, i32 2)
%65 = call i32 @mgetFunction(i8* %5, i32 %26, i8* %6, i64 %63, i32 %64, i8* %62)
br label %82
66: ; preds = %58
%67 = call i32 @strcmp(i8* dereferenceable(1) %42, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %80
69: ; preds = %66
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8* %6)
%71 = call i32 @strlen(i8* %5)
%72 = call i32 @write(i32 %26, i8* %5, i32 %71)
%73 = call i32 @read(i32 %26, i8* %5, i32 8096)
%74 = call i32 @getFunction(i8* %5, i32 %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %5)
%76 = call i32 @strlen(i8* %5)
%77 = call i32 @write(i32 %26, i8* %5, i32 %76)
%78 = call i32 @read(i32 %26, i8* %5, i32 8096)
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0), i8* %5)
br label %82
80: ; preds = %66
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.16, i64 0, i64 0))
br label %82
82: ; preds = %51, %61, %80, %69, %56, %45
ret i32 1
}