#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 */
struct json_value {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct json_value *json_search(struct json_value *, char const *);
int /*<<< orphan*/ json_stringify(struct json_value *);
struct json_value *parse_file(char const *);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, const char **argv) {
  struct json_value *json_value;
  if (argc < 2) {
    fprintf(stderr, "usage: json <json_file> [search_path]\n");
    return 2;
  }
  json_value = parse_file(argv[1]);
  if (argc >= 3) {
    json_value = json_search(json_value, argv[2]);
    if (!json_value) {
      fprintf(stderr, "Unable to find %s\n", argv[2]);
      return 2;
    }
  }
  puts(json_stringify(json_value));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1193 <main+0x43>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1215 <main+0xc5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <parse_file@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     11fe <main+0xae>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <json_search@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f9 <main+0xa9>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1215 <main+0xc5>
jmp    11fe <main+0xae>
mov    -0x18(%rbp),%rdi
call   1040 <json_stringify@plt>
mov    %eax,%edi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     1176 <main+0x26>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x2,%eax
jmp    11ab <main+0x5b>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
call   1070 <parse_file@plt>
cmp    $0x2,%ebp
je     119a <main+0x4a>
mov    0x10(%rbx),%rsi
mov    %rax,%rdi
call   1060 <json_search@plt>
test   %rax,%rax
je     11b2 <main+0x62>
mov    %rax,%rdi
call   1040 <json_stringify@plt>
mov    %eax,%edi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe61(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    116f <main+0x1f>

LLVM IR (-O0):
%struct.json_value = type { i32 }
@stderr = global i32 0
@.str = [39 x i8] c"usage: json <json_file> [search_path]\0A\00"
@.str.1 = [19 x i8] c"Unable to find %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.json_value*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %3
br label %38
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call %struct.json_value* @parse_file(i8* %15)
store %struct.json_value* %16, %struct.json_value** %6
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 3
br i1 %18, label %19, label %34
19: ; preds = %12
%20 = load %struct.json_value*, %struct.json_value** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call %struct.json_value* @json_search(%struct.json_value* %20, i8* %23)
store %struct.json_value* %24, %struct.json_value** %6
%25 = load %struct.json_value*, %struct.json_value** %6
%26 = icmp ne %struct.json_value* %25, null
br i1 %26, label %33, label %27
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %31)
store i32 2, i32* %3
br label %38
33: ; preds = %19
br label %34
34: ; preds = %33, %12
%35 = load %struct.json_value*, %struct.json_value** %6
%36 = call i32 @json_stringify(%struct.json_value* %35)
%37 = call i32 @puts(i32 %36)
store i32 0, i32* %3
br label %38
38: ; preds = %34, %27, %9
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
%struct.json_value = type { i32 }
@stderr = global i32 0
@.str = [39 x i8] c"usage: json <json_file> [search_path]\0A\00"
@.str.1 = [19 x i8] c"Unable to find %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %25
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call %struct.json_value* @parse_file(i8* %9)
%11 = icmp eq i32 %0, 2
br i1 %11, label %21, label %12
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call %struct.json_value* @json_search(%struct.json_value* %10, i8* %14)
%16 = icmp eq %struct.json_value* %15, null
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i8*, i8** %13
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %25
21: ; preds = %12, %7
%22 = phi %struct.json_value* [ %15, %12 ], [ %10, %7 ]
%23 = tail call i32 @json_stringify(%struct.json_value* %22)
%24 = tail call i32 @puts(i32 %23)
br label %25
25: ; preds = %21, %17, %4
%26 = phi i32 [ 2, %4 ], [ 0, %21 ], [ 2, %17 ]
ret i32 %26
}