#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ STDIN_FILENO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ parse_json(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ request_and_response(char *, char *, char *);
int main(int argc, char *argv[]) {
  int i;
  char json[32768], buffer[32768];
  if (argc < 2) {
    puts("Usage: ./a.out [ga|gd|gv]");
    exit(1);
  }
  read(STDIN_FILENO, buffer, 32768);
  request_and_response(argv[1], buffer, json);
  parse_json(json);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1189 <main+0x39>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x10020(%rbp),%rsi
mov    $0x8000,%edx
call   1050 <read@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x10020(%rbp),%rsi
lea    -0x8020(%rbp),%rdx
call   1040 <request_and_response@plt>
lea    -0x8020(%rbp),%rdi
call   1060 <parse_json@plt>
xor    %eax,%eax
add    $0x10020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x10008,%rsp
cmp    $0x1,%edi
jle    11a7 <main+0x57>
mov    %rsi,%rbx
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%r14
mov    %r14,%rsi
mov    $0x8000,%edx
call   1050 <read@plt>
mov    0x8(%rbx),%rdi
lea    0x8000(%rsp),%rbx
mov    %r14,%rsi
mov    %rbx,%rdx
call   1040 <request_and_response@plt>
mov    %rbx,%rdi
call   1060 <parse_json@plt>
xor    %eax,%eax
add    $0x10008,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: ./a.out [ga|gd|gv]\00"
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [32768 x i8]
%8 = alloca [32768 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i32, i32* @STDIN_FILENO
%16 = getelementptr inbounds [32768 x i8], [32768 x i8]* %8, i64 0, i64 0
%17 = call i32 @read(i32 %15, i8* %16, i32 32768)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [32768 x i8], [32768 x i8]* %8, i64 0, i64 0
%22 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%23 = call i32 @request_and_response(i8* %20, i8* %21, i8* %22)
%24 = getelementptr inbounds [32768 x i8], [32768 x i8]* %7, i64 0, i64 0
%25 = call i32 @parse_json(i8* %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [26 x i8] c"Usage: ./a.out [ga|gd|gv]\00"
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32768 x i8]
%4 = alloca [32768 x i8]
%5 = getelementptr inbounds [32768 x i8], [32768 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32768 x i8], [32768 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i32, i32* @STDIN_FILENO
%13 = call i32 @read(i32 %12, i8* %6, i32 32768)
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @request_and_response(i8* %15, i8* %6, i8* %5)
%17 = call i32 @parse_json(i8* %5)
ret i32 0
}