#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 */
typedef int /*<<< orphan*/ wchar_t;
struct TokenStream {
  int dummy;
};
struct AST {
  int dummy;
};

/* Variables and functions */
struct AST *build_ast(struct TokenStream *);
int /*<<< orphan*/ token_stream_free(struct TokenStream *);
struct TokenStream *tokenize(int /*<<< orphan*/ *);
int wcslen(int /*<<< orphan*/ *);
struct AST *ast_new_from_parse(wchar_t *data) {
  if (wcslen(data) < 1)
    return NULL;
  struct TokenStream *ts = tokenize(data);
  if (ts == NULL)
    return NULL;
  struct AST *ast = build_ast(ts);
  token_stream_free(ts);
  return ast;
}


x86 assembly (clang, -O0):
<ast_new_from_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <wcslen@plt>
cmp    $0x1,%eax
jge    116b <ast_new_from_parse+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11ae <ast_new_from_parse+0x6e>
mov    -0x10(%rbp),%rdi
call   1050 <tokenize@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1190 <ast_new_from_parse+0x50>
movq   $0x0,-0x8(%rbp)
jmp    11ae <ast_new_from_parse+0x6e>
mov    -0x18(%rbp),%rdi
call   1060 <build_ast@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <token_stream_free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ast_new_from_parse>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <wcslen@plt>
test   %eax,%eax
jle    1178 <ast_new_from_parse+0x38>
mov    %rbx,%rdi
call   1050 <tokenize@plt>
test   %rax,%rax
je     1178 <ast_new_from_parse+0x38>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <build_ast@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <token_stream_free@plt>
mov    %r14,%rax
jmp    117a <ast_new_from_parse+0x3a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.AST = type { i32 }
%struct.TokenStream = type { i32 }
define %struct.AST* @ast_new_from_parse(i32* %0) {
%2 = alloca %struct.AST*
%3 = alloca i32*
%4 = alloca %struct.TokenStream*
%5 = alloca %struct.AST*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @wcslen(i32* %6)
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %1
store %struct.AST* null, %struct.AST** %2
br label %22
10: ; preds = %1
%11 = load i32*, i32** %3
%12 = call %struct.TokenStream* @tokenize(i32* %11)
store %struct.TokenStream* %12, %struct.TokenStream** %4
%13 = load %struct.TokenStream*, %struct.TokenStream** %4
%14 = icmp eq %struct.TokenStream* %13, null
br i1 %14, label %15, label %16
15: ; preds = %10
store %struct.AST* null, %struct.AST** %2
br label %22
16: ; preds = %10
%17 = load %struct.TokenStream*, %struct.TokenStream** %4
%18 = call %struct.AST* @build_ast(%struct.TokenStream* %17)
store %struct.AST* %18, %struct.AST** %5
%19 = load %struct.TokenStream*, %struct.TokenStream** %4
%20 = call i32 @token_stream_free(%struct.TokenStream* %19)
%21 = load %struct.AST*, %struct.AST** %5
store %struct.AST* %21, %struct.AST** %2
br label %22
22: ; preds = %16, %15, %9
%23 = load %struct.AST*, %struct.AST** %2
ret %struct.AST* %23
}

LLVM IR (-O2):
%struct.AST = type { i32 }
%struct.TokenStream = type { i32 }
define %struct.AST* @ast_new_from_parse(i32* %0) {
%2 = tail call i32 @wcslen(i32* %0)
%3 = icmp slt i32 %2, 1
br i1 %3, label %10, label %4
4: ; preds = %1
%5 = tail call %struct.TokenStream* @tokenize(i32* %0)
%6 = icmp eq %struct.TokenStream* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call %struct.AST* @build_ast(%struct.TokenStream* %5)
%9 = tail call i32 @token_stream_free(%struct.TokenStream* %5)
br label %10
10: ; preds = %7, %4, %1
%11 = phi %struct.AST* [ null, %1 ], [ %8, %7 ], [ null, %4 ]
ret %struct.AST* %11
}