// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %r15
pushq $0x1
popq %rdi
pushq $0x10
popq %rsi
callq 0x2130
movq %rax, %rbx
pushq $0x3
popq %rdi
callq 0x2080
callq 0x22f0
movq %rax, %r14
movq %rax, %rdi
movl $0x2712, %esi           # imm = 0x2712
movq %r15, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x15a(%rip), %rdx       # 0x47b6
movq %r14, %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
xorl %eax, %eax
callq 0x2260
movq %r14, %rdi
movl $0x2711, %esi           # imm = 0x2711
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2260
leaq 0x3e76(%rip), %rdx      # 0x84fa
movq %r14, %rdi
movl $0x2722, %esi           # imm = 0x2722
xorl %eax, %eax
callq 0x2260
pushq $0x54
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2260
cmpb $0x1, 0x7bee(%rip)      # 0xc298
jne 0x46bc
pushq $0x29
popq %rsi
pushq $0x1
popq %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2260
movq %rsp, %r15
movq %r14, %rdi
movl $0x271a, %esi           # imm = 0x271A
movq %r15, %rdx
xorl %eax, %eax
callq 0x2260
movb $0x0, (%r15)
movq %r14, %rdi
callq 0x2300
testl %eax, %eax
jne 0x471e
movq %r14, %rdi
callq 0x22c0
callq 0x20a0
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
incq %rsi
callq 0x23e0
movq %rax, (%rbx)
testq %rax, %rax
je 0x4768
movq 0x8(%rbx), %rcx
movb $0x0, (%rax,%rcx)
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebp
movq 0x78b1(%rip), %r14      # 0xbfd8
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x22d0
movq (%r14), %rbx
cmpb $0x0, (%rsp)
jne 0x4745
movl %ebp, %edi
callq 0x2350
movq %rax, %r15
leaq 0x3dc8(%rip), %rsi      # 0x8514
movq %rbx, %rdi
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x2340
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x22d0
jmp 0x47ae
movq 0x7869(%rip), %r14      # 0xbfd8
movq (%r14), %rsi
pushq $0xa
popq %rdi
callq 0x22d0
movq (%r14), %rcx
leaq 0x3da2(%rip), %rdi      # 0x8526
pushq $0x7
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x2480
movq (%r14), %rcx
leaq 0x3f9b(%rip), %rdi      # 0x8737
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x2480
xorl %edi, %edi
callq 0x2180
pushq $0x1
popq %rdi
callq 0x22a0