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

/* Variables and functions */
int /*<<< orphan*/ add_term_internal(struct _term_vectors_writer *, char *,
                                     int);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ is_document_open(struct _term_vectors_writer *);
int /*<<< orphan*/
term_vectors_writer_is_field_open(struct _term_vectors_writer *);
void term_vectors_writer_add_term(struct _term_vectors_writer *_tvw,
                                  char *_tm_text, int _posting_freq) {
  if (!is_document_open(_tvw))
    err(1, "cannot add terms when document is not open");
  if (!term_vectors_writer_is_field_open(_tvw))
    err(1, "cannot add terms when field is not open");
  add_term_internal(_tvw, _tm_text, _posting_freq);
}


x86 assembly (clang, -O0):
<term_vectors_writer_add_term>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <is_document_open@plt>
cmp    $0x0,%eax
jne    1176 <term_vectors_writer_add_term+0x36>
mov    $0x1,%edi
lea    0xe8f(%rip),%rsi
call   1050 <err@plt>
mov    -0x8(%rbp),%rdi
call   1040 <term_vectors_writer_is_field_open@plt>
cmp    $0x0,%eax
jne    1199 <term_vectors_writer_add_term+0x59>
mov    $0x1,%edi
lea    0xe97(%rip),%rsi
call   1050 <err@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <add_term_internal@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<term_vectors_writer_add_term>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1060 <is_document_open@plt>
test   %eax,%eax
jne    1167 <term_vectors_writer_add_term+0x27>
lea    0xea3(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
mov    %rbp,%rdi
call   1040 <term_vectors_writer_is_field_open@plt>
test   %eax,%eax
jne    1184 <term_vectors_writer_add_term+0x44>
lea    0xeb1(%rip),%rsi
mov    $0x1,%edi
call   1050 <err@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <add_term_internal@plt>

LLVM IR (-O0):
%struct._term_vectors_writer = type { i32 }
@.str = [43 x i8] c"cannot add terms when document is not open\00"
@.str.1 = [40 x i8] c"cannot add terms when field is not open\00"
define void @term_vectors_writer_add_term(%struct._term_vectors_writer* %0, i8* %1, i32 %2) {
%4 = alloca %struct._term_vectors_writer*
%5 = alloca i8*
%6 = alloca i32
store %struct._term_vectors_writer* %0, %struct._term_vectors_writer** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = load %struct._term_vectors_writer*, %struct._term_vectors_writer** %4
%8 = call i32 @is_document_open(%struct._term_vectors_writer* %7)
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %3
%11 = call i32 @err(i32 1, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
%13 = load %struct._term_vectors_writer*, %struct._term_vectors_writer** %4
%14 = call i32 @term_vectors_writer_is_field_open(%struct._term_vectors_writer* %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @err(i32 1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = load %struct._term_vectors_writer*, %struct._term_vectors_writer** %4
%20 = load i8*, i8** %5
%21 = load i32, i32* %6
%22 = call i32 @add_term_internal(%struct._term_vectors_writer* %19, i8* %20, i32 %21)
ret void
}

LLVM IR (-O2):
%struct._term_vectors_writer = type { i32 }
@.str = [43 x i8] c"cannot add terms when document is not open\00"
@.str.1 = [40 x i8] c"cannot add terms when field is not open\00"
define void @term_vectors_writer_add_term(%struct._term_vectors_writer* %0, i8* %1, i32 %2) {
%4 = tail call i32 @is_document_open(%struct._term_vectors_writer* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %3
%9 = tail call i32 @term_vectors_writer_is_field_open(%struct._term_vectors_writer* %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = tail call i32 @add_term_internal(%struct._term_vectors_writer* %0, i8* %1, i32 %2)
ret void
}