#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 NAME_MAX;
int PATH_MAX;
int atoi(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ isdigit(char);
char *malloc(int);
int /*<<< orphan*/ print_usage_details();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
int parse_client_args(int argc, char **argv, int *client_port,
                      char *from_file_name, char *host, char *to_file_name) {
  int numPortChars, counter;
  int iPort;
  int host_length;
  char *szPort;
  char scratch[16 + PATH_MAX + NAME_MAX + 1];
  char *token;
  short argv_counter = 1;
  if (argc < 3) {
    print_usage_details();
    printf("Starting a client\n");
    printf("Had less than 3 arguments\n.");
    return -1;
  }
  if (strncmp(argv[argv_counter], "--port=", 7) == 0) {
    numPortChars = strlen(argv[argv_counter]) - 7 + 1;
    szPort = malloc(numPortChars * sizeof(char));
    strncpy(szPort, argv[argv_counter] + 7, numPortChars);
    szPort[numPortChars] = '\0';
    counter = 0;
    while (szPort[counter] != '\0') {
      if (!isdigit(szPort[counter])) {
        print_usage_details();
        printf("Found a character in the port number\n");
        return -1;
      }
      counter++;
    }
    iPort = atoi(szPort);
    if (iPort > 65535) {
      print_usage_details();
      printf("Port number was greater than 65535\n");
      return -1;
    }
    *client_port = iPort;
    argv_counter++;
    free(szPort);
  } else
    *client_port = 1111;
  strncpy(from_file_name, argv[argv_counter], PATH_MAX + NAME_MAX + 1);
  argv_counter++;
  strncpy(scratch, argv[argv_counter], 16 + PATH_MAX + NAME_MAX + 1);
  token = strchr(scratch, ':');
  if (token != NULL) {
    token = strtok(scratch, ":");
    strncpy(host, token, 16);
    host_length = strlen(host) + 1;
    strncpy(to_file_name, scratch + host_length, PATH_MAX + NAME_MAX + 1);
  } else {
    sprintf(host, "127.0.0.1");
    strncpy(to_file_name, scratch, PATH_MAX + NAME_MAX + 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_client_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
mov    0x2de1(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
mov    %edx,%eax
lea    0x11(%rax,%rcx,1),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movw   $0x1,-0x62(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    125e <parse_client_args+0x9e>
mov    $0x0,%al
call   10a0 <print_usage_details@plt>
lea    0xdc6(%rip),%rdi
call   1090 <printf@plt>
lea    0xdcd(%rip),%rdi
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14d8 <parse_client_args+0x318>
mov    -0x10(%rbp),%rax
movswq -0x62(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xdbd(%rip),%rsi
mov    $0x7,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
jne    13a9 <parse_client_args+0x1e9>
mov    -0x10(%rbp),%rax
movswq -0x62(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1070 <strlen@plt>
sub    $0x7,%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
movswq -0x62(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
add    $0x7,%rsi
mov    -0x34(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x48(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x38(%rbp)
mov    -0x48(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1347 <parse_client_args+0x187>
mov    -0x48(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1060 <isdigit@plt>
cmp    $0x0,%eax
jne    1339 <parse_client_args+0x179>
mov    $0x0,%al
call   10a0 <print_usage_details@plt>
lea    0xd16(%rip),%rdi
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14d8 <parse_client_args+0x318>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12e4 <parse_client_args+0x124>
mov    -0x48(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffff,-0x3c(%rbp)
jle    1386 <parse_client_args+0x1c6>
mov    $0x0,%al
call   10a0 <print_usage_details@plt>
lea    0xcef(%rip),%rdi
call   1090 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14d8 <parse_client_args+0x318>
mov    -0x3c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x62(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x62(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
jmp    13b3 <parse_client_args+0x1f3>
mov    -0x18(%rbp),%rax
movl   $0x457,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movswq -0x62(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2c25(%rip),%rax
mov    (%rax),%edx
mov    0x2bfc(%rip),%rax
add    (%rax),%edx
add    $0x1,%edx
call   1040 <strncpy@plt>
mov    -0x70(%rbp),%rdi
mov    -0x62(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x62(%rbp)
mov    -0x10(%rbp),%rax
movswq -0x62(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    0x2bee(%rip),%rax
mov    (%rax),%edx
add    $0x10,%edx
mov    0x2bc2(%rip),%rax
add    (%rax),%edx
add    $0x1,%edx
call   1040 <strncpy@plt>
mov    -0x70(%rbp),%rdi
mov    $0x3a,%esi
call   1080 <strchr@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1498 <parse_client_args+0x2d8>
mov    -0x70(%rbp),%rdi
lea    0xc41(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x60(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strncpy@plt>
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x70(%rbp),%rsi
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
movslq -0x40(%rbp),%rax
add    %rax,%rsi
mov    0x2b70(%rip),%rax
mov    (%rax),%edx
mov    0x2b47(%rip),%rax
add    (%rax),%edx
add    $0x1,%edx
call   1040 <strncpy@plt>
jmp    14ca <parse_client_args+0x30a>
mov    -0x28(%rbp),%rdi
lea    0xbe0(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x70(%rbp),%rsi
mov    -0x30(%rbp),%rdi
mov    0x2b39(%rip),%rax
mov    (%rax),%edx
mov    0x2b10(%rip),%rax
add    (%rax),%edx
add    $0x1,%edx
call   1040 <strncpy@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_client_args>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    0x2e15(%rip),%r13
mov    0x0(%r13),%eax
mov    0x2dea(%rip),%rdx
mov    (%rdx),%edx
add    %edx,%eax
add    $0x11,%eax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
cmp    $0x2,%edi
jg     122c <parse_client_args+0x6c>
xor    %eax,%eax
call   10b0 <print_usage_details@plt>
lea    0xe67(%rip),%rdi
call   1070 <puts@plt>
lea    0xde3(%rip),%rdi
call   10a0 <printf@plt>
mov    $0xffffffff,%eax
jmp    13bf <parse_client_args+0x1ff>
mov    %r9,%r15
mov    %rsi,%r12
mov    %rcx,-0x48(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x8(%rsi),%rdi
lea    0xdd7(%rip),%rsi
mov    $0x7,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
mov    %r15,-0x38(%rbp)
je     1305 <parse_client_args+0x145>
movl   $0x457,(%rbx)
mov    $0x1,%ax
movzwl %ax,%ebx
mov    (%r12,%rbx,8),%rsi
mov    0x0(%r13),%eax
mov    0x2d58(%rip),%r15
mov    (%r15),%ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    -0x48(%rbp),%rdi
call   1040 <strncpy@plt>
mov    0x8(%r12,%rbx,8),%rsi
mov    0x0(%r13),%eax
mov    (%r15),%ecx
lea    (%rax,%rcx,1),%edx
add    $0x11,%edx
mov    %r14,%rdi
call   1040 <strncpy@plt>
mov    %r14,%rdi
mov    $0x3a,%esi
call   1090 <strchr@plt>
test   %rax,%rax
je     138d <parse_client_args+0x1cd>
lea    0xd63(%rip),%rsi
mov    %r14,%rdi
call   10d0 <strtok@plt>
mov    -0x30(%rbp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x10,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1080 <strlen@plt>
cltq
lea    (%rax,%r14,1),%rsi
add    $0x1,%rsi
mov    0x0(%r13),%eax
mov    (%r15),%ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%rdi
jmp    13b8 <parse_client_args+0x1f8>
mov    %rbx,-0x40(%rbp)
mov    0x8(%r12),%rdi
call   1080 <strlen@plt>
movslq %eax,%rbx
lea    -0x6(%rbx),%r13
mov    %r13d,%edi
call   10c0 <malloc@plt>
mov    %rax,%r15
mov    0x8(%r12),%rsi
add    $0x7,%rsi
mov    %rax,%rdi
mov    %r13d,%edx
call   1040 <strncpy@plt>
movb   $0x0,-0x6(%r15,%rbx,1)
mov    (%r15),%al
test   %al,%al
je     1367 <parse_client_args+0x1a7>
lea    0x1(%r15),%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1060 <isdigit@plt>
test   %eax,%eax
je     13ce <parse_client_args+0x20e>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1350 <parse_client_args+0x190>
mov    %r15,%rdi
call   10e0 <atoi@plt>
cmp    $0x10000,%eax
mov    0x2c75(%rip),%r13
jl     13e6 <parse_client_args+0x226>
xor    %eax,%eax
call   10b0 <print_usage_details@plt>
lea    0xca5(%rip),%rdi
jmp    13dc <parse_client_args+0x21c>
movabs $0x2e302e302e373231,%rax
2e 30 2e
mov    -0x30(%rbp),%rcx
mov    %rax,(%rcx)
movw   $0x31,0x8(%rcx)
mov    0x0(%r13),%eax
mov    (%r15),%ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    -0x38(%rbp),%rdi
mov    %r14,%rsi
call   1040 <strncpy@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10b0 <print_usage_details@plt>
lea    0xc77(%rip),%rdi
call   1070 <puts@plt>
jmp    1222 <parse_client_args+0x62>
mov    -0x40(%rbp),%rcx
mov    %eax,(%rcx)
mov    %r15,%rdi
call   1030 <free@plt>
mov    $0x2,%ax
jmp    1266 <parse_client_args+0xa6>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@NAME_MAX = global i32 0
@.str = [19 x i8] c"Starting a client\0A\00"
@.str.1 = [28 x i8] c"Had less than 3 arguments\0A.\00"
@.str.2 = [8 x i8] c"--port=\00"
@.str.3 = [38 x i8] c"Found a character in the port number\0A\00"
@.str.4 = [36 x i8] c"Port number was greater than 65535\0A\00"
@.str.5 = [2 x i8] c":\00"
@.str.6 = [10 x i8] c"127.0.0.1\00"
define i32 @parse_client_args(i32 %0, i8** %1, i32* %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i8*
%22 = alloca i16
%23 = alloca i32
store i32 %0, i32* %8
store i8** %1, i8*** %9
store i32* %2, i32** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%24 = load i32, i32* @PATH_MAX
%25 = add nsw i32 16, %24
%26 = load i32, i32* @NAME_MAX
%27 = add nsw i32 %25, %26
%28 = add nsw i32 %27, 1
%29 = zext i32 %28 to i64
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %19
%31 = alloca i8, i64 %29
store i64 %29, i64* %20
store i16 1, i16* %22
%32 = load i32, i32* %8
%33 = icmp slt i32 %32, 3
br i1 %33, label %34, label %38
34: ; preds = %6
%35 = call i32 (...) @print_usage_details()
%36 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %7
store i32 1, i32* %23
br label %167
38: ; preds = %6
%39 = load i8**, i8*** %9
%40 = load i16, i16* %22
%41 = sext i16 %40 to i64
%42 = getelementptr inbounds i8*, i8** %39, i64 %41
%43 = load i8*, i8** %42
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %110
46: ; preds = %38
%47 = load i8**, i8*** %9
%48 = load i16, i16* %22
%49 = sext i16 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @strlen(i8* %51)
%53 = sub nsw i32 %52, 7
%54 = add nsw i32 %53, 1
store i32 %54, i32* %14
%55 = load i32, i32* %14
%56 = sext i32 %55 to i64
%57 = mul i64 %56, 1
%58 = trunc i64 %57 to i32
%59 = call i8* @malloc(i32 %58)
store i8* %59, i8** %18
%60 = load i8*, i8** %18
%61 = load i8**, i8*** %9
%62 = load i16, i16* %22
%63 = sext i16 %62 to i64
%64 = getelementptr inbounds i8*, i8** %61, i64 %63
%65 = load i8*, i8** %64
%66 = getelementptr inbounds i8, i8* %65, i64 7
%67 = load i32, i32* %14
%68 = call i32 @strncpy(i8* %60, i8* %66, i32 %67)
%69 = load i8*, i8** %18
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 0, i8* %72
store i32 0, i32* %15
br label %73
73: ; preds = %92, %46
%74 = load i8*, i8** %18
%75 = load i32, i32* %15
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 0
br i1 %80, label %81, label %95
81: ; preds = %73
%82 = load i8*, i8** %18
%83 = load i32, i32* %15
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i8, i8* %82, i64 %84
%86 = load i8, i8* %85
%87 = call i32 @isdigit(i8 signext %86)
%88 = icmp ne i32 %87, 0
br i1 %88, label %92, label %89
89: ; preds = %81
%90 = call i32 (...) @print_usage_details()
%91 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %7
store i32 1, i32* %23
br label %167
92: ; preds = %81
%93 = load i32, i32* %15
%94 = add nsw i32 %93, 1
store i32 %94, i32* %15
br label %73
95: ; preds = %73
%96 = load i8*, i8** %18
%97 = call i32 @atoi(i8* %96)
store i32 %97, i32* %16
%98 = load i32, i32* %16
%99 = icmp sgt i32 %98, 65535
br i1 %99, label %100, label %103
100: ; preds = %95
%101 = call i32 (...) @print_usage_details()
%102 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %7
store i32 1, i32* %23
br label %167
103: ; preds = %95
%104 = load i32, i32* %16
%105 = load i32*, i32** %10
store i32 %104, i32* %105
%106 = load i16, i16* %22
%107 = add i16 %106, 1
store i16 %107, i16* %22
%108 = load i8*, i8** %18
%109 = call i32 @free(i8* %108)
br label %112
110: ; preds = %38
%111 = load i32*, i32** %10
store i32 1111, i32* %111
br label %112
112: ; preds = %110, %103
%113 = load i8*, i8** %11
%114 = load i8**, i8*** %9
%115 = load i16, i16* %22
%116 = sext i16 %115 to i64
%117 = getelementptr inbounds i8*, i8** %114, i64 %116
%118 = load i8*, i8** %117
%119 = load i32, i32* @PATH_MAX
%120 = load i32, i32* @NAME_MAX
%121 = add nsw i32 %119, %120
%122 = add nsw i32 %121, 1
%123 = call i32 @strncpy(i8* %113, i8* %118, i32 %122)
%124 = load i16, i16* %22
%125 = add i16 %124, 1
store i16 %125, i16* %22
%126 = load i8**, i8*** %9
%127 = load i16, i16* %22
%128 = sext i16 %127 to i64
%129 = getelementptr inbounds i8*, i8** %126, i64 %128
%130 = load i8*, i8** %129
%131 = load i32, i32* @PATH_MAX
%132 = add nsw i32 16, %131
%133 = load i32, i32* @NAME_MAX
%134 = add nsw i32 %132, %133
%135 = add nsw i32 %134, 1
%136 = call i32 @strncpy(i8* %31, i8* %130, i32 %135)
%137 = call i8* @strchr(i8* %31, i8 signext 58)
store i8* %137, i8** %21
%138 = load i8*, i8** %21
%139 = icmp ne i8* %138, null
br i1 %139, label %140, label %157
140: ; preds = %112
%141 = call i8* @strtok(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %141, i8** %21
%142 = load i8*, i8** %12
%143 = load i8*, i8** %21
%144 = call i32 @strncpy(i8* %142, i8* %143, i32 16)
%145 = load i8*, i8** %12
%146 = call i32 @strlen(i8* %145)
%147 = add nsw i32 %146, 1
store i32 %147, i32* %17
%148 = load i8*, i8** %13
%149 = load i32, i32* %17
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds i8, i8* %31, i64 %150
%152 = load i32, i32* @PATH_MAX
%153 = load i32, i32* @NAME_MAX
%154 = add nsw i32 %152, %153
%155 = add nsw i32 %154, 1
%156 = call i32 @strncpy(i8* %148, i8* %151, i32 %155)
br label %166
157: ; preds = %112
%158 = load i8*, i8** %12
%159 = call i32 @sprintf(i8* %158, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%160 = load i8*, i8** %13
%161 = load i32, i32* @PATH_MAX
%162 = load i32, i32* @NAME_MAX
%163 = add nsw i32 %161, %162
%164 = add nsw i32 %163, 1
%165 = call i32 @strncpy(i8* %160, i8* %31, i32 %164)
br label %166
166: ; preds = %157, %140
store i32 0, i32* %7
store i32 1, i32* %23
br label %167
167: ; preds = %166, %100, %89, %34
%168 = load i8*, i8** %19
%169 = load i32, i32* %7
ret i32 %169
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@NAME_MAX = global i32 0
@.str.1 = [28 x i8] c"Had less than 3 arguments\0A.\00"
@.str.2 = [8 x i8] c"--port=\00"
@.str.5 = [2 x i8] c":\00"
@.str.6 = [10 x i8] c"127.0.0.1\00"
@str = [35 x i8] c"Port number was greater than 65535\00"
@str.7 = [37 x i8] c"Found a character in the port number\00"
@str.8 = [18 x i8] c"Starting a client\00"
define i32 @parse_client_args(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, i8* %3, i8* %4, i8* %5) {
%7 = load i32, i32* @PATH_MAX
%8 = load i32, i32* @NAME_MAX
%9 = add i32 %7, 17
%10 = add i32 %9, %8
%11 = zext i32 %10 to i64
%12 = alloca i8, i64 %11
%13 = icmp slt i32 %0, 3
br i1 %13, label %14, label %18
14: ; preds = %6
%15 = tail call i32 (...) @print_usage_details()
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.8, i64 0, i64 0))
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
br label %96
18: ; preds = %6
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i64 @strncmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %56
23: ; preds = %18
%24 = load i8*, i8** %19
%25 = tail call i32 @strlen(i8* %24)
%26 = add nsw i32 %25, -6
%27 = sext i32 %26 to i64
%28 = tail call i8* @malloc(i32 %26)
%29 = load i8*, i8** %19
%30 = getelementptr inbounds i8, i8* %29, i64 7
%31 = tail call i32 @strncpy(i8* %28, i8* %30, i32 %26)
%32 = getelementptr inbounds i8, i8* %28, i64 %27
store i8 0, i8* %32
%33 = load i8, i8* %28
%34 = icmp eq i8 %33, 0
br i1 %34, label %48, label %39
35: ; preds = %39
%36 = getelementptr inbounds i8, i8* %28, i64 %44
%37 = load i8, i8* %36
%38 = icmp eq i8 %37, 0
br i1 %38, label %48, label %39
39: ; preds = %23, %35
%40 = phi i64 [ %44, %35 ], [ 0, %23 ]
%41 = phi i8 [ %37, %35 ], [ %33, %23 ]
%42 = tail call i32 @isdigit(i8 signext %41)
%43 = icmp eq i32 %42, 0
%44 = add nuw i64 %40, 1
br i1 %43, label %45, label %35
45: ; preds = %39
%46 = tail call i32 (...) @print_usage_details()
%47 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %96
48: ; preds = %35, %23
%49 = tail call i32 @atoi(i8* %28)
%50 = icmp sgt i32 %49, 65535
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = tail call i32 (...) @print_usage_details()
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %96
54: ; preds = %48
store i32 %49, i32* %2
%55 = tail call i32 @free(i8* %28)
br label %57
56: ; preds = %18
store i32 1111, i32* %2
br label %57
57: ; preds = %56, %54
%58 = phi i16 [ 2, %54 ], [ 1, %56 ]
%59 = zext i16 %58 to i64
%60 = getelementptr inbounds i8*, i8** %1, i64 %59
%61 = load i8*, i8** %60
%62 = load i32, i32* @PATH_MAX
%63 = load i32, i32* @NAME_MAX
%64 = add i32 %62, 1
%65 = add i32 %64, %63
%66 = tail call i32 @strncpy(i8* %3, i8* %61, i32 %65)
%67 = add nuw nsw i16 %58, 1
%68 = zext i16 %67 to i64
%69 = getelementptr inbounds i8*, i8** %1, i64 %68
%70 = load i8*, i8** %69
%71 = load i32, i32* @PATH_MAX
%72 = load i32, i32* @NAME_MAX
%73 = add i32 %71, 17
%74 = add i32 %73, %72
%75 = call i32 @strncpy(i8* %12, i8* %70, i32 %74)
%76 = call i8* @strchr(i8* %12, i8 signext 58)
%77 = icmp eq i8* %76, null
br i1 %77, label %90, label %78
78: ; preds = %57
%79 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%80 = call i32 @strncpy(i8* %4, i8* %79, i32 16)
%81 = call i32 @strlen(i8* %4)
%82 = add nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %12, i64 %83
%85 = load i32, i32* @PATH_MAX
%86 = load i32, i32* @NAME_MAX
%87 = add i32 %85, 1
%88 = add i32 %87, %86
%89 = call i32 @strncpy(i8* %5, i8* %84, i32 %88)
br label %96
90: ; preds = %57
%91 = load i32, i32* @PATH_MAX
%92 = load i32, i32* @NAME_MAX
%93 = add i32 %91, 1
%94 = add i32 %93, %92
%95 = call i32 @strncpy(i8* %5, i8* %12, i32 %94)
br label %96
96: ; preds = %78, %90, %51, %45, %14
%97 = phi i32 [ -1, %14 ], [ -1, %45 ], [ -1, %51 ], [ 0, %90 ], [ 0, %78 ]
ret i32 %97
}