#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 TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(int /*<<< orphan*/, char, int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *strtok(char *, char const *);
int findDsts(char *server, int serverport, char **dsts, char *prim_dest) {
  int depSocket;
  char buffer[1024], num_int[5];
  struct sockaddr_in serverAddr;
  socklen_t addr_size;
  const char s[2] = ",";
  const char s2[2] = "<";
  const char s3[2] = ">";
  if (1)
    printf("Connecting to %s:%d\n", server, serverport);
  depSocket = socket(AF_INET, SOCK_STREAM, 0);
  serverAddr.sin_family = AF_INET;
  serverAddr.sin_port = htons(serverport);
  serverAddr.sin_addr.s_addr = inet_addr(server);
  memset(serverAddr.sin_zero, '\0', sizeof serverAddr.sin_zero);
  addr_size = sizeof serverAddr;
  int result = connect(depSocket, (struct sockaddr *)&serverAddr, addr_size);
  printf("Prim %s\n", prim_dest);
  printf("Connected? %d\n", result);
  strcpy(buffer, "rdp device,");
  strcat(buffer, prim_dest);
  strcat(buffer, ",*\n");
  send(depSocket, buffer, strlen(buffer), 0);
  bzero(buffer, 512);
  int size = 0;
  char *size_str;
  while (recv(depSocket, buffer, 512, 0)) {
    break;
  }
  strtok(buffer, s);
  strtok(NULL, s);
  size_str = strtok(NULL, s);
  size = atoi(strtok(size_str, s3));
  int i;
  bzero(buffer, 512);
  strcpy(buffer, "rdp ");
  strcat(buffer, prim_dest);
  for (i = 0; i < size - 1; i++) {
    strcat(buffer, ",*");
  }
  strcat(buffer, "\n");
  send(depSocket, buffer, strlen(buffer), 0);
  if (1)
    printf("Sent second request %s\n", buffer);
  bzero(buffer, 512);
  while (recv(depSocket, buffer, 512, 0)) {
    break;
  }
  char *temp = (char *)malloc(sizeof(char) * 50);
  if (1)
    printf("Buffer initial form %s\n", buffer);
  strtok(buffer, s2);
  temp = strtok(NULL, s2);
  temp = strtok(temp, s3);
  strcpy(dsts[0], strtok(temp, s));
  for (i = 1; i < size; i++) {
    strcpy(dsts[i], strtok(NULL, s));
  }
  return size;
}


x86 assembly (clang, -O0):
<findDsts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0xe2a(%rip),%ax
mov    %ax,-0x44e(%rbp)
mov    0xde1(%rip),%ax
mov    %ax,-0x450(%rbp)
mov    0xdd5(%rip),%ax
mov    %ax,-0x452(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x24(%rbp)
mov    0x2d7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x43c(%rbp)
mov    -0xc(%rbp),%edi
call   1060 <htons@plt>
mov    %eax,-0x440(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x444(%rbp)
mov    -0x448(%rbp),%edi
xor    %esi,%esi
mov    $0x4,%edx
call   1090 <memset@plt>
movl   $0x10,-0x44c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x448(%rbp),%rsi
mov    -0x44c(%rbp),%edx
call   1100 <connect@plt>
mov    %eax,-0x458(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x458(%rbp),%esi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10f0 <strcat@plt>
lea    -0x430(%rbp),%rdi
lea    0xd1e(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x484(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x480(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x484(%rbp),%edi
mov    -0x480(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
lea    -0x430(%rbp),%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
movl   $0x0,-0x45c(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
je     139d <findDsts+0x1ad>
jmp    139d <findDsts+0x1ad>
lea    -0x430(%rbp),%rdi
lea    -0x44e(%rbp),%rsi
call   10c0 <strtok@plt>
lea    -0x44e(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
lea    -0x44e(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
mov    %rax,-0x468(%rbp)
mov    -0x468(%rbp),%rdi
lea    -0x452(%rbp),%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x45c(%rbp)
lea    -0x430(%rbp),%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
lea    -0x430(%rbp),%rdi
lea    0xc2a(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10f0 <strcat@plt>
movl   $0x0,-0x46c(%rbp)
mov    -0x46c(%rbp),%eax
mov    -0x45c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1474 <findDsts+0x284>
lea    -0x430(%rbp),%rdi
lea    0xbeb(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x46c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x46c(%rbp)
jmp    1436 <findDsts+0x246>
lea    -0x430(%rbp),%rdi
lea    0xbbd(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x494(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x490(%rbp)
lea    -0x430(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x494(%rbp),%edi
mov    -0x490(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
lea    -0x430(%rbp),%rsi
lea    0xb7b(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x430(%rbp),%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
mov    -0x24(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
je     150b <findDsts+0x31b>
jmp    150b <findDsts+0x31b>
mov    $0x32,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x478(%rbp)
lea    -0x430(%rbp),%rsi
lea    0xb37(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x430(%rbp),%rdi
lea    -0x450(%rbp),%rsi
call   10c0 <strtok@plt>
lea    -0x450(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
mov    %rax,-0x478(%rbp)
mov    -0x478(%rbp),%rdi
lea    -0x452(%rbp),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x478(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x4a0(%rbp)
mov    -0x478(%rbp),%rdi
lea    -0x44e(%rbp),%rsi
call   10c0 <strtok@plt>
mov    -0x4a0(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
movl   $0x1,-0x46c(%rbp)
mov    -0x46c(%rbp),%eax
cmp    -0x45c(%rbp),%eax
jge    160a <findDsts+0x41a>
mov    -0x18(%rbp),%rax
movslq -0x46c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x4a8(%rbp)
lea    -0x44e(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <strtok@plt>
mov    -0x4a8(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x46c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x46c(%rbp)
jmp    15af <findDsts+0x3bf>
mov    -0x45c(%rbp),%eax
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findDsts>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rcx,%r14
mov    %rdx,%r13
mov    %esi,%ebx
mov    %rdi,%rbp
movw   $0x2c,0xa(%rsp)
movw   $0x3c,0xe(%rsp)
movw   $0x3e,0xc(%rsp)
lea    0xdd8(%rip),%rdi
mov    %rbp,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2dad(%rip),%r15
mov    (%r15),%edi
mov    0x2d93(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,%r12d
mov    (%r15),%eax
mov    %eax,0x1c(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %eax,0x18(%rsp)
mov    %rbp,%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
xor    %esi,%esi
mov    $0x4,%edx
call   1090 <memset@plt>
lea    0x10(%rsp),%rsi
mov    %r12d,%edi
mov    $0x10,%edx
call   1100 <connect@plt>
mov    %eax,%ebx
lea    0xd7f(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd77(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xd76(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
lea    0xd63(%rip),%rsi
mov    %rbp,%rdi
call   10f0 <strcat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
mov    %rbp,%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
lea    0xa(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   10e0 <atoi@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
lea    0xcd9(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcpy@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
cmp    $0x2,%r15d
jl     13a0 <findDsts+0x1b0>
lea    -0x1(%r15),%ebp
lea    0xcba(%rip),%r14
lea    0x20(%rsp),%rbx
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
add    $0xffffffff,%ebp
jne    1390 <findDsts+0x1a0>
lea    0xc94(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   10f0 <strcat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
lea    0xc73(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
mov    $0x200,%esi
call   10d0 <bzero@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    $0x32,%edi
call   10b0 <malloc@plt>
lea    0xc51(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe(%rsp),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
lea    0xc(%rsp),%rsi
mov    %rax,%rdi
call   10c0 <strtok@plt>
mov    0x0(%r13),%rbx
lea    0xa(%rsp),%rsi
mov    %rax,%rdi
call   10c0 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
cmp    $0x2,%r15d
jl     1493 <findDsts+0x2a3>
mov    %r15d,%r12d
mov    $0x1,%ebp
lea    0xa(%rsp),%r14
nopl   0x0(%rax)
mov    0x0(%r13,%rbp,8),%rbx
xor    %edi,%edi
mov    %r14,%rsi
call   10c0 <strtok@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1470 <findDsts+0x280>
mov    %r15d,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.findDsts.s = [2 x i8] c",\00"
@__const.findDsts.s2 = [2 x i8] c"<\00"
@__const.findDsts.s3 = [2 x i8] c">\00"
@.str = [21 x i8] c"Connecting to %s:%d\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [9 x i8] c"Prim %s\0A\00"
@.str.2 = [15 x i8] c"Connected? %d\0A\00"
@.str.3 = [12 x i8] c"rdp device,\00"
@.str.4 = [4 x i8] c",*\0A\00"
@.str.5 = [5 x i8] c"rdp \00"
@.str.6 = [3 x i8] c",*\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [24 x i8] c"Sent second request %s\0A\00"
@.str.9 = [24 x i8] c"Buffer initial form %s\0A\00"
define i32 @findDsts(i8* %0, i32 %1, i8** %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [1024 x i8]
%11 = alloca [5 x i8]
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca [2 x i8]
%15 = alloca [2 x i8]
%16 = alloca [2 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8* %3, i8** %8
%22 = bitcast [2 x i8]* %14 to i8*
%23 = bitcast [2 x i8]* %15 to i8*
%24 = bitcast [2 x i8]* %16 to i8*
%25 = load i8*, i8** %5
%26 = load i32, i32* %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %25, i32 %26)
%28 = load i32, i32* @AF_INET
%29 = load i32, i32* @SOCK_STREAM
%30 = call i32 @socket(i32 %28, i32 %29, i32 0)
store i32 %30, i32* %9
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 3
store i32 %31, i32* %32
%33 = load i32, i32* %6
%34 = call i32 @htons(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %34, i32* %35
%36 = load i8*, i8** %5
%37 = call i32 @inet_addr(i8* %36)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
store i32 %37, i32* %39
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 @memset(i32 %41, i8 signext 0, i32 4)
store i32 16, i32* %13
%43 = load i32, i32* %9
%44 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%45 = load i32, i32* %13
%46 = call i32 @connect(i32 %43, %struct.sockaddr* %44, i32 %45)
store i32 %46, i32* %17
%47 = load i8*, i8** %8
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %47)
%49 = load i32, i32* %17
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%54 = load i8*, i8** %8
%55 = call i32 @strcat(i8* %53, i8* %54)
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%58 = load i32, i32* %9
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%61 = call i32 @strlen(i8* %60)
%62 = call i32 @send(i32 %58, i8* %59, i32 %61, i32 0)
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%64 = call i32 @bzero(i8* %63, i32 512)
store i32 0, i32* %18
br label %65
65: ; preds = %4
%66 = load i32, i32* %9
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%68 = call i64 @recv(i32 %66, i8* %67, i32 512, i32 0)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %65
br label %71
71: ; preds = %70, %65
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%73 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%74 = call i8* @strtok(i8* %72, i8* %73)
%75 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%76 = call i8* @strtok(i8* null, i8* %75)
%77 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%78 = call i8* @strtok(i8* null, i8* %77)
store i8* %78, i8** %19
%79 = load i8*, i8** %19
%80 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%81 = call i8* @strtok(i8* %79, i8* %80)
%82 = call i32 @atoi(i8* %81)
store i32 %82, i32* %18
%83 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%84 = call i32 @bzero(i8* %83, i32 512)
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%86 = call i32 @strcpy(i8* %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%88 = load i8*, i8** %8
%89 = call i32 @strcat(i8* %87, i8* %88)
store i32 0, i32* %20
br label %90
90: ; preds = %98, %71
%91 = load i32, i32* %20
%92 = load i32, i32* %18
%93 = sub nsw i32 %92, 1
%94 = icmp slt i32 %91, %93
br i1 %94, label %95, label %101
95: ; preds = %90
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%97 = call i32 @strcat(i8* %96, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
br label %98
98: ; preds = %95
%99 = load i32, i32* %20
%100 = add nsw i32 %99, 1
store i32 %100, i32* %20
br label %90
101: ; preds = %90
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%103 = call i32 @strcat(i8* %102, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%104 = load i32, i32* %9
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%107 = call i32 @strlen(i8* %106)
%108 = call i32 @send(i32 %104, i8* %105, i32 %107, i32 0)
%109 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %109)
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%112 = call i32 @bzero(i8* %111, i32 512)
br label %113
113: ; preds = %101
%114 = load i32, i32* %9
%115 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%116 = call i64 @recv(i32 %114, i8* %115, i32 512, i32 0)
%117 = icmp ne i64 %116, 0
br i1 %117, label %118, label %119
118: ; preds = %113
br label %119
119: ; preds = %118, %113
%120 = call i64 @malloc(i32 50)
%121 = inttoptr i64 %120 to i8*
store i8* %121, i8** %21
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %122)
%124 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%125 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%126 = call i8* @strtok(i8* %124, i8* %125)
%127 = getelementptr inbounds [2 x i8], [2 x i8]* %15, i64 0, i64 0
%128 = call i8* @strtok(i8* null, i8* %127)
store i8* %128, i8** %21
%129 = load i8*, i8** %21
%130 = getelementptr inbounds [2 x i8], [2 x i8]* %16, i64 0, i64 0
%131 = call i8* @strtok(i8* %129, i8* %130)
store i8* %131, i8** %21
%132 = load i8**, i8*** %7
%133 = getelementptr inbounds i8*, i8** %132, i64 0
%134 = load i8*, i8** %133
%135 = load i8*, i8** %21
%136 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%137 = call i8* @strtok(i8* %135, i8* %136)
%138 = call i32 @strcpy(i8* %134, i8* %137)
store i32 1, i32* %20
br label %139
139: ; preds = %152, %119
%140 = load i32, i32* %20
%141 = load i32, i32* %18
%142 = icmp slt i32 %140, %141
br i1 %142, label %143, label %155
143: ; preds = %139
%144 = load i8**, i8*** %7
%145 = load i32, i32* %20
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds i8*, i8** %144, i64 %146
%148 = load i8*, i8** %147
%149 = getelementptr inbounds [2 x i8], [2 x i8]* %14, i64 0, i64 0
%150 = call i8* @strtok(i8* null, i8* %149)
%151 = call i32 @strcpy(i8* %148, i8* %150)
br label %152
152: ; preds = %143
%153 = load i32, i32* %20
%154 = add nsw i32 %153, 1
store i32 %154, i32* %20
br label %139
155: ; preds = %139
%156 = load i32, i32* %18
ret i32 %156
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [21 x i8] c"Connecting to %s:%d\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [9 x i8] c"Prim %s\0A\00"
@.str.2 = [15 x i8] c"Connected? %d\0A\00"
@.str.3 = [12 x i8] c"rdp device,\00"
@.str.4 = [4 x i8] c",*\0A\00"
@.str.5 = [5 x i8] c"rdp \00"
@.str.6 = [3 x i8] c",*\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [24 x i8] c"Sent second request %s\0A\00"
@.str.9 = [24 x i8] c"Buffer initial form %s\0A\00"
define i32 @findDsts(i8* %0, i32 %1, i8** nocapture %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = alloca %struct.sockaddr_in
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%11 = bitcast %struct.sockaddr_in* %6 to i8*
%12 = bitcast i16* %7 to i8*
store i16 44, i16* %7
%13 = bitcast i16* %8 to i8*
store i16 60, i16* %8
%14 = bitcast i16* %9 to i8*
store i16 62, i16* %9
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%16 = load i32, i32* @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = tail call i32 @socket(i32 %16, i32 %17, i32 0)
%19 = load i32, i32* @AF_INET
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 3
store i32 %19, i32* %20
%21 = tail call i32 @htons(i32 %1)
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 2
store i32 %21, i32* %22
%23 = tail call i32 @inet_addr(i8* %0)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 1, i32 0
store i32 %23, i32* %24
%25 = tail call i32 @memset(i32 undef, i8 signext 0, i32 4)
%26 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%27 = call i32 @connect(i32 %18, %struct.sockaddr* %26, i32 16)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%30 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%31 = call i32 @strcat(i8* %10, i8* %3)
%32 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%33 = call i32 @strlen(i8* %10)
%34 = call i32 @send(i32 %18, i8* %10, i32 %33, i32 0)
%35 = call i32 @bzero(i8* %10, i32 512)
%36 = call i64 @recv(i32 %18, i8* %10, i32 512, i32 0)
%37 = call i8* @strtok(i8* %10, i8* %12)
%38 = call i8* @strtok(i8* null, i8* %12)
%39 = call i8* @strtok(i8* null, i8* %12)
%40 = call i8* @strtok(i8* %39, i8* %14)
%41 = call i32 @atoi(i8* %40)
%42 = call i32 @bzero(i8* %10, i32 512)
%43 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 @strcat(i8* %10, i8* %3)
%45 = add i32 %41, -1
%46 = icmp sgt i32 %41, 1
br i1 %46, label %47, label %52
47: ; preds = %4, %47
%48 = phi i32 [ %50, %47 ], [ 0, %4 ]
%49 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%50 = add nuw nsw i32 %48, 1
%51 = icmp eq i32 %50, %45
br i1 %51, label %52, label %47
52: ; preds = %47, %4
%53 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 @strlen(i8* %10)
%55 = call i32 @send(i32 %18, i8* %10, i32 %54, i32 0)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0), i8* %10)
%57 = call i32 @bzero(i8* %10, i32 512)
%58 = call i64 @recv(i32 %18, i8* %10, i32 512, i32 0)
%59 = call i64 @malloc(i32 50)
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %10)
%61 = call i8* @strtok(i8* %10, i8* %13)
%62 = call i8* @strtok(i8* null, i8* %13)
%63 = call i8* @strtok(i8* %62, i8* %14)
%64 = load i8*, i8** %2
%65 = call i8* @strtok(i8* %63, i8* %12)
%66 = call i32 @strcpy(i8* %64, i8* %65)
br i1 %46, label %67, label %77
67: ; preds = %52
%68 = zext i32 %41 to i64
br label %69
69: ; preds = %67, %69
%70 = phi i64 [ 1, %67 ], [ %75, %69 ]
%71 = getelementptr inbounds i8*, i8** %2, i64 %70
%72 = load i8*, i8** %71
%73 = call i8* @strtok(i8* null, i8* %12)
%74 = call i32 @strcpy(i8* %72, i8* %73)
%75 = add nuw nsw i64 %70, 1
%76 = icmp eq i64 %75, %68
br i1 %76, label %77, label %69
77: ; preds = %69, %52
ret i32 %41
}