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

/* Variables and functions */
int /*<<< orphan*/ jx_delete(struct jx *);
struct jx *jx_parse(struct jx_parser *);
int /*<<< orphan*/ jx_parser_delete(struct jx_parser *);
scalar_t__ jx_parser_errors(struct jx_parser *);
struct jx *jx_parse_finish(struct jx_parser *p) {
  struct jx *j = jx_parse(p);
  if (jx_parser_errors(p)) {
    jx_parser_delete(p);
    jx_delete(j);
    return 0;
  }
  jx_parser_delete(p);
  return j;
}


x86 assembly (clang, -O0):
<jx_parse_finish>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <jx_parse@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <jx_parser_errors@plt>
cmp    $0x0,%rax
je     118b <jx_parse_finish+0x4b>
mov    -0x10(%rbp),%rdi
call   1050 <jx_parser_delete@plt>
mov    -0x18(%rbp),%rdi
call   1060 <jx_delete@plt>
movq   $0x0,-0x8(%rbp)
jmp    119c <jx_parse_finish+0x5c>
mov    -0x10(%rbp),%rdi
call   1050 <jx_parser_delete@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jx_parse_finish>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <jx_parse@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <jx_parser_errors@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1050 <jx_parser_delete@plt>
test   %r15,%r15
je     1173 <jx_parse_finish+0x33>
mov    %r14,%rdi
call   1060 <jx_delete@plt>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.jx = type { i32 }
%struct.jx_parser = type { i32 }
define %struct.jx* @jx_parse_finish(%struct.jx_parser* %0) {
%2 = alloca %struct.jx*
%3 = alloca %struct.jx_parser*
%4 = alloca %struct.jx*
store %struct.jx_parser* %0, %struct.jx_parser** %3
%5 = load %struct.jx_parser*, %struct.jx_parser** %3
%6 = call %struct.jx* @jx_parse(%struct.jx_parser* %5)
store %struct.jx* %6, %struct.jx** %4
%7 = load %struct.jx_parser*, %struct.jx_parser** %3
%8 = call i64 @jx_parser_errors(%struct.jx_parser* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load %struct.jx_parser*, %struct.jx_parser** %3
%12 = call i32 @jx_parser_delete(%struct.jx_parser* %11)
%13 = load %struct.jx*, %struct.jx** %4
%14 = call i32 @jx_delete(%struct.jx* %13)
store %struct.jx* null, %struct.jx** %2
br label %19
15: ; preds = %1
%16 = load %struct.jx_parser*, %struct.jx_parser** %3
%17 = call i32 @jx_parser_delete(%struct.jx_parser* %16)
%18 = load %struct.jx*, %struct.jx** %4
store %struct.jx* %18, %struct.jx** %2
br label %19
19: ; preds = %15, %10
%20 = load %struct.jx*, %struct.jx** %2
ret %struct.jx* %20
}

LLVM IR (-O2):
%struct.jx = type { i32 }
%struct.jx_parser = type { i32 }
define %struct.jx* @jx_parse_finish(%struct.jx_parser* %0) {
%2 = tail call %struct.jx* @jx_parse(%struct.jx_parser* %0)
%3 = tail call i64 @jx_parser_errors(%struct.jx_parser* %0)
%4 = icmp eq i64 %3, 0
%5 = tail call i32 @jx_parser_delete(%struct.jx_parser* %0)
br i1 %4, label %8, label %6
6: ; preds = %1
%7 = tail call i32 @jx_delete(%struct.jx* %2)
br label %8
8: ; preds = %1, %6
%9 = phi %struct.jx* [ null, %6 ], [ %2, %1 ]
ret %struct.jx* %9
}