#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_stream(const char *value, char **end_ptr) {
  if (!end_ptr)
    return NULL;
  struct json *c = json_new_item();
  if (!c)
    return 0;
  *end_ptr = (char *)value;
  if (!parse_value(c, skip(end_ptr))) {
    json_delete(c);
    return 0;
  }
  return c;
}


x86 assembly (clang, -O0):
<json_parse_stream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1168 <json_parse_stream+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <json_parse_stream+0x99>
mov    $0x0,%al
call   1040 <json_new_item@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118b <json_parse_stream+0x4b>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <json_parse_stream+0x99>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <skip@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1050 <parse_value@plt>
cmp    $0x0,%eax
jne    11d1 <json_parse_stream+0x91>
mov    -0x20(%rbp),%rdi
call   1060 <json_delete@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <json_parse_stream+0x99>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<json_parse_stream>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1180 <json_parse_stream+0x40>
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1040 <json_new_item@plt>
test   %rax,%rax
je     1180 <json_parse_stream+0x40>
mov    %rax,%r14
mov    %r15,(%rbx)
mov    %rbx,%rdi
call   1030 <skip@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1050 <parse_value@plt>
test   %eax,%eax
jne    1183 <json_parse_stream+0x43>
mov    %r14,%rdi
call   1060 <json_delete@plt>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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