// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movl $0x10, %edi
callq 0x2300
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rax
movq $0x0, (%rax)
movq -0x128(%rbp), %rax
movq $0x0, 0x8(%rax)
movl $0x3, %edi
callq 0x2080
callq 0x22e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rdx
movl $0x2712, %esi           # imm = 0x2712
movb $0x0, %al
callq 0x2250
movq -0x10(%rbp), %rdi
movl $0x4e2b, %esi           # imm = 0x4E2B
leaq 0x20c(%rip), %rdx       # 0x5e90
movb $0x0, %al
callq 0x2250
movq -0x10(%rbp), %rdi
movq -0x128(%rbp), %rdx
movl $0x2711, %esi           # imm = 0x2711
movb $0x0, %al
callq 0x2250
movq -0x10(%rbp), %rdi
movl $0x2722, %esi           # imm = 0x2722
leaq 0x48b8(%rip), %rdx      # 0xa56a
movb $0x0, %al
callq 0x2250
movq -0x10(%rbp), %rdi
movl $0x54, %esi
movl $0x1, %edx
movb $0x0, %al
callq 0x2250
cmpl $0x1, 0x75cf(%rip)      # 0xd2a4
jb 0x5cec
movq -0x10(%rbp), %rdi
movl $0x29, %esi
movl $0x1, %edx
movb $0x0, %al
callq 0x2250
movq -0x10(%rbp), %rdi
leaq -0x120(%rbp), %rdx
movl $0x271a, %esi           # imm = 0x271A
movb $0x0, %al
callq 0x2250
movb $0x0, -0x120(%rbp)
movq -0x10(%rbp), %rdi
callq 0x22f0
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
je 0x5dc2
jmp 0x5d21
movq 0x72b0(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4ae4(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x7298(%rip), %rax      # 0xcfd8
movq (%rax), %rax
movq %rax, -0x138(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x12c(%rbp)
movsbl -0x120(%rbp), %eax
cmpl $0x0, %eax
je 0x5d6f
leaq -0x120(%rbp), %rax
movq %rax, -0x140(%rbp)
jmp 0x5d7e
movl -0x14(%rbp), %edi
callq 0x2340
movq %rax, -0x140(%rbp)
movl -0x12c(%rbp), %edx
movq -0x138(%rbp), %rdi
movq -0x140(%rbp), %rcx
leaq 0x47eb(%rip), %rsi      # 0xa584
movb $0x0, %al
callq 0x2330
movq 0x7231(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4a65(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movl $0x1, %edi
callq 0x2290
movq -0x10(%rbp), %rdi
callq 0x22b0
callq 0x20a0
movq -0x128(%rbp), %rax
movq (%rax), %rdi
movq -0x128(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x1, %rsi
callq 0x23d0
movq %rax, %rcx
movq -0x128(%rbp), %rax
movq %rcx, (%rax)
movq -0x128(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x5e65
jmp 0x5e0a
movq 0x71c7(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x49fb(%rip), %rsi      # 0xa816
movb $0x0, %al
callq 0x2330
movq 0x71af(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x4763(%rip), %rsi      # 0xa596
movb $0x0, %al
callq 0x2330
movq 0x7197(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
leaq 0x495e(%rip), %rsi      # 0xa7a9
movb $0x0, %al
callq 0x2330
xorl %eax, %eax
movl %eax, %edi
callq 0x2180
movl $0x1, %edi
callq 0x2290
movq -0x128(%rbp), %rax
movq (%rax), %rax
movq -0x128(%rbp), %rcx
movq 0x8(%rcx), %rcx
movb $0x0, (%rax,%rcx)
movq -0x128(%rbp), %rax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nop