#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 {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ json_delete(struct json *);
struct json *json_new_item();
int /*<<< orphan*/ parse_value(struct json *, int /*<<< orphan*/);
int /*<<< orphan*/ skip(char **);
struct json *json_parse(const char *value) {
  struct json *c = json_new_item();
  if (!c)
    return 0;
  char **end_ptr = (char **)&value;
  if (!parse_value(c, skip(end_ptr))) {
    json_delete(c);
    return 0;
  }
  return c;
}


x86 assembly (clang, -O0):
<json_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <json_new_item@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    116f <json_parse+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    11ba <json_parse+0x7a>
lea    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <skip@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1050 <parse_value@plt>
cmp    $0x0,%eax
jne    11b2 <json_parse+0x72>
mov    -0x18(%rbp),%rdi
call   1060 <json_delete@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ba <json_parse+0x7a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_parse>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
xor    %eax,%eax
call   1040 <json_new_item@plt>
test   %rax,%rax
je     1179 <json_parse+0x39>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
call   1030 <skip@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <parse_value@plt>
test   %eax,%eax
jne    117b <json_parse+0x3b>
mov    %rbx,%rdi
call   1060 <json_delete@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.json = type { i32 }
define %struct.json* @json_parse(i8* %0) {
%2 = alloca %struct.json*
%3 = alloca i8*
%4 = alloca %struct.json*
%5 = alloca i8**
store i8* %0, i8** %3
%6 = call %struct.json* (...) @json_new_item()
store %struct.json* %6, %struct.json** %4
%7 = load %struct.json*, %struct.json** %4
%8 = icmp ne %struct.json* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store %struct.json* null, %struct.json** %2
br label %21
10: ; preds = %1
store i8** %3, i8*** %5
%11 = load %struct.json*, %struct.json** %4
%12 = load i8**, i8*** %5
%13 = call i32 @skip(i8** %12)
%14 = call i32 @parse_value(%struct.json* %11, i32 %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %10
%17 = load %struct.json*, %struct.json** %4
%18 = call i32 @json_delete(%struct.json* %17)
store %struct.json* null, %struct.json** %2
br label %21
19: ; preds = %10
%20 = load %struct.json*, %struct.json** %4
store %struct.json* %20, %struct.json** %2
br label %21
21: ; preds = %19, %16, %9
%22 = load %struct.json*, %struct.json** %2
ret %struct.json* %22
}

LLVM IR (-O2):
%struct.json = type { i32 }
define %struct.json* @json_parse(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = tail call %struct.json* (...) @json_new_item()
%4 = icmp eq %struct.json* %3, null
br i1 %4, label %11, label %5
5: ; preds = %1
%6 = call i32 @skip(i8** %2)
%7 = call i32 @parse_value(%struct.json* %3, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @json_delete(%struct.json* %3)
br label %11
11: ; preds = %9, %5, %1
%12 = phi %struct.json* [ null, %1 ], [ null, %9 ], [ %3, %5 ]
ret %struct.json* %12
}