// File: /workspace/github_c_makefile_star2_O1/otrtool[P]otrtool/src/main.c
// Function: contactServer
struct MemoryStruct * contactServer(char *request) {
  // http://curl.haxx.se/libcurl/c/getinmemory.html
  CURL *curl_handle;
  CURLcode res;
  char errbuf[CURL_ERROR_SIZE];
  
  struct MemoryStruct *chunk = malloc(sizeof(struct MemoryStruct));
  chunk->memory=NULL; /* we expect realloc(NULL, size) to work */ 
  chunk->size = 0;    /* no data at this point */ 
  
  curl_global_init(CURL_GLOBAL_ALL);
  
  /* init the curl session */ 
  curl_handle = curl_easy_init();
  
  /* specify URL to get */ 
  curl_easy_setopt(curl_handle, CURLOPT_URL, request);
  
  /* send all data to this function  */ 
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
  
  /* we pass our 'chunk' struct to the callback function */ 
  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)chunk);
  
  /* imitate the original OTR client */ 
  curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "Linux-OTR-Decoder/0.4.592");
  curl_easy_setopt(curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
  
  /* set verbosity and error message buffer */
  if (opts.verbosity >= VERB_DEBUG)
    curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
  curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, errbuf);
  
  /* get it! */ 
  *errbuf = 0;
  if ((res = curl_easy_perform(curl_handle)) != CURLE_OK)
    ERROR("cURL error %d: %s", res, *errbuf ? errbuf : curl_easy_strerror(res));
  
  /* cleanup curl stuff */ 
  curl_easy_cleanup(curl_handle);
  
  /*
   * Now, our chunk.memory points to a memory block that is chunk.size
   * bytes big and contains the remote file.
   *
   * Do something nice with it!
   *
   * You should be aware of the fact that at this point we might have an
   * allocated data block, and nothing has yet deallocated that data. So when
   * you're done with it, you should free() it as a nice application.
   */ 
  
  /* we're done with libcurl, so clean it up */ 
  curl_global_cleanup();
  
  // null-terminate response
  chunk->memory = realloc(chunk->memory, chunk->size + 1);
  if (chunk->memory == NULL) PERROR("realloc");
  chunk->memory[chunk->size] = 0;
  return chunk;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
movq %rdi, %r15
movl $0x10, %edi
callq 0x2300
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x3, %edi
callq 0x2080
callq 0x22e0
movq %rax, %r14
movq %rax, %rdi
movl $0x2712, %esi           # imm = 0x2712
movq %r15, %rdx
xorl %eax, %eax
callq 0x2250
leaq 0xd8(%rip), %rdx        # 0x566b
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x2250
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2250
leaq 0x2f3f(%rip), %rdx      # 0x84fa
movq %r14, %rdi
movl $0x2722, %esi           # imm = 0x2722
xorl %eax, %eax
callq 0x2250
movq %r14, %rdi
movl $0x54, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x2250
cmpb $0x1, 0x6ca3(%rip)      # 0xc288
jne 0x55fb
movq %r14, %rdi
movl $0x29, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x2250
movq %rsp, %r15
movq %r14, %rdi
movl $0x271a, %esi           # imm = 0x271A
movq %r15, %rdx
xorl %eax, %eax
callq 0x2250
movb $0x0, (%r15)
movq %r14, %rdi
callq 0x22f0
testl %eax, %eax
jne 0x565c
movq %r14, %rdi
callq 0x22b0
callq 0x20a0
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
incq %rsi
callq 0x23d0
movq %rax, (%rbx)
testq %rax, %rax
je 0x5666
movq 0x8(%rbx), %rcx
movb $0x0, (%rax,%rcx)
movq %rbx, %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
movq %rsp, %rdi
movl %eax, %esi
callq 0x2d51
callq 0x2daf