// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x820, %rsp            # imm = 0x820
movq %rdi, %rbx
leaq 0x119b(%rip), %rdi      # 0x5381
xorl %r14d, %r14d
xorl %esi, %esi
xorl %eax, %eax
callq 0x10f0
testl %eax, %eax
js 0x4368
leaq -0x840(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
movl %eax, %edi
callq 0x11c0
testl %eax, %eax
jle 0x423c
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
xorl %r14d, %r14d
movb -0x840(%rbp,%r14), %dl
cmpb $0x20, %dl
je 0x423c
movb %dl, -0x440(%rbp,%r14)
incq %r14
cmpq %r14, %rcx
jne 0x421c
movl %eax, %r14d
movl %r14d, %ecx
movb $0x0, -0x440(%rbp,%rcx)
incl %r14d
cmpl %eax, %r14d
jge 0x426e
leaq (%rcx,%rbp), %rsi
addq $-0x83f, %rsi           # imm = 0xF7C1
subl %ecx, %eax
addl $-0x2, %eax
incq %rax
leaq -0x25(%rbp), %rdi
movq %rax, %rdx
callq 0x1110
movb $0x0, -0x21(%rbp)
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x1070
testl %eax, %eax
js 0x4371
movl %eax, %r14d
leaq -0x38(%rbp), %r15
movw $0x2, (%r15)
leaq -0x25(%rbp), %rdi
callq 0x1200
rolw $0x8, %ax
movw %ax, 0x2(%r15)
leaq -0x440(%rbp), %rdi
callq 0x1160
movl %eax, 0x4(%r15)
movl %r14d, %edi
movq %r15, %rsi
movl $0x10, %edx
callq 0x1120
testl %eax, %eax
jns 0x42ff
leaq 0x1e61(%rip), %r15      # 0x6136
leaq -0x38(%rbp), %r12
movq %r15, %rdi
callq 0x11e0
movl $0x3, %edi
callq 0x1100
movl %r14d, %edi
movq %r12, %rsi
movl $0x10, %edx
callq 0x1120
testl %eax, %eax
js 0x42d9
leaq 0x1e05(%rip), %rdi      # 0x610b
callq 0x11e0
movl $0x400, %edi            # imm = 0x400
callq 0x1190
movq %rax, %r15
movq $0x0, (%rax)
movq %rbx, %rdi
callq 0x10a0
movl %r14d, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1080
movl $0x3ff, %edx            # imm = 0x3FF
movl %r14d, %edi
movq %r15, %rsi
callq 0x11c0
testl %eax, %eax
jle 0x4355
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movb $0x0, (%r15,%rax)
jmp 0x4335
movq %r15, %rax
addq $0x820, %rsp            # imm = 0x820
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e31(%rip), %rdi      # 0x61a0
jmp 0x4378
leaq 0x1e06(%rip), %rdi      # 0x617e
callq 0x11e0
movl $0x1, %edi
callq 0x1180