// File: /workspace/github_c_makefile_star2_O0/evanwire[P]GitClone/client.c
// Function: connect_to_WTFserver
char* connect_to_WTFserver(char* message_to_server){
  //Checking for .configure file, throwing an error if it does not exist
  int config_fd = open(".configure", O_RDONLY);
  if(config_fd < 0){
    printf("\nError: Could not open the .configure file. Please run the configure command before trying again.\n");
    exit(1);
  }

  //Read address and port number from file
  int i;
  int j = 0;
  char config_buffer[1024];
  char address[1020];
  char port[5];
  int bytes_read = read(config_fd, config_buffer, 1024);

  for(i = 0; i < bytes_read; i++){
    if(config_buffer[i] == ' '){
      break;
    }
    address[i] = config_buffer[i];
  }

  address[i] = '\0';

  for(i += 1; i < bytes_read; i++){
    port[j] = config_buffer[i];
    j++;
  }

  port[4] = '\0';

  //Creating the structs/variables neccesary to connect to server
  int sockfd = 0,n = 0;
  struct sockaddr_in serv_addr;

  //Create the socket
  if((sockfd = socket(AF_INET, SOCK_STREAM, 0))< 0){
    printf("\n Error: Could not create socket \n");
    exit(1);
  }

  //Set connection configurations
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_port = htons(atoi(port));
  serv_addr.sin_addr.s_addr = inet_addr(address);

  //Attempting to connect to server, retrying every three seconds
  while(1){
    if(connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))<0){
      printf("\n Error: Could not find server. Will attempt to recconect in 3 seconds.\n");
      sleep(3);
    }else{
      printf("\nSTATUS: Successfully connected to server.\n");
      break;
    }
  }

  //Prepare buffer for communicating with server
  char* recvBuff = (char*)malloc(1024);
  memset(recvBuff, 0, sizeof(recvBuff));

  //Write to server
  n = write(sockfd, message_to_server, strlen(message_to_server));

  //Read from server, return its response
  while((n = read(sockfd, recvBuff, 1023)) > 0){
    recvBuff[n] = 0;
  }

  return recvBuff;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x860, %rsp            # imm = 0x860
movq %rdi, -0x8(%rbp)
leaq 0x1850(%rip), %rdi      # 0x7446
xorl %esi, %esi
movb $0x0, %al
callq 0x10f0
movl %eax, -0xc(%rbp)
cmpl $0x0, -0xc(%rbp)
jge 0x5c20
leaq 0x1ecd(%rip), %rdi      # 0x7adc
movb $0x0, %al
callq 0x1040
movl $0x1, %edi
callq 0x1170
movl $0x0, -0x14(%rbp)
movl -0xc(%rbp), %edi
leaq -0x420(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x11a0
movl %eax, -0x82c(%rbp)
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x82c(%rbp), %eax
jge 0x5c87
movslq -0x10(%rbp), %rax
movsbl -0x420(%rbp,%rax), %eax
cmpl $0x20, %eax
jne 0x5c66
jmp 0x5c87
movslq -0x10(%rbp), %rax
movb -0x420(%rbp,%rax), %cl
movslq -0x10(%rbp), %rax
movb %cl, -0x820(%rbp,%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5c48
movslq -0x10(%rbp), %rax
movb $0x0, -0x820(%rbp,%rax)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x82c(%rbp), %eax
jge 0x5cd1
movslq -0x10(%rbp), %rax
movb -0x420(%rbp,%rax), %cl
movslq -0x14(%rbp), %rax
movb %cl, -0x825(%rbp,%rax)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5c9c
movb $0x0, -0x821(%rbp)
movl $0x0, -0x830(%rbp)
movl $0x0, -0x834(%rbp)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1080
movl %eax, -0x830(%rbp)
cmpl $0x0, %eax
jge 0x5d20
leaq 0x1e30(%rip), %rdi      # 0x7b3f
movb $0x0, %al
callq 0x1040
movl $0x1, %edi
callq 0x1170
movw $0x2, -0x844(%rbp)
leaq -0x825(%rbp), %rdi
callq 0x11d0
movzwl %ax, %edi
callq 0x1050
movw %ax, -0x842(%rbp)
leaq -0x820(%rbp), %rdi
callq 0x1150
movl %eax, -0x840(%rbp)
movl -0x830(%rbp), %edi
leaq -0x844(%rbp), %rsi
movl $0x10, %edx
callq 0x1110
cmpl $0x0, %eax
jge 0x5d8c
leaq 0x1de9(%rip), %rdi      # 0x7b62
movb $0x0, %al
callq 0x1040
movl $0x3, %edi
callq 0x1100
jmp 0x5d9c
leaq 0x1e18(%rip), %rdi      # 0x7bab
movb $0x0, %al
callq 0x1040
jmp 0x5d9e
jmp 0x5d56
movl $0x400, %edi            # imm = 0x400
callq 0x1180
movq %rax, -0x850(%rbp)
movq -0x850(%rbp), %rdi
xorl %esi, %esi
movl $0x8, %edx
callq 0x10d0
movl -0x830(%rbp), %eax
movl %eax, -0x85c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x858(%rbp)
movq -0x8(%rbp), %rdi
callq 0x10b0
movl -0x85c(%rbp), %edi
movq -0x858(%rbp), %rsi
movq %rax, %rdx
callq 0x1090
movl %eax, -0x834(%rbp)
movl -0x830(%rbp), %edi
movq -0x850(%rbp), %rsi
movl $0x3ff, %edx            # imm = 0x3FF
callq 0x11a0
movl %eax, -0x834(%rbp)
cmpl $0x0, %eax
jle 0x5e33
movq -0x850(%rbp), %rax
movslq -0x834(%rbp), %rcx
movb $0x0, (%rax,%rcx)
jmp 0x5dfd
movq -0x850(%rbp), %rax
addq $0x860, %rsp            # imm = 0x860
popq %rbp
retq
nopw %cs:(%rax,%rax)