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

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int r2w(struct varstr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ store_kv(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
struct varstr *varstr_init();
int /*<<< orphan*/ *varstr_pack(struct varstr *);
extern bool read_data(wchar_t *text, bool is_sentence) {
  wchar_t *last = NULL;
  struct varstr *cur = NULL;
  signed int read_last = 0;
  bool is_ss = (is_sentence ? true : false);
  for (last = NULL;;) {
    cur = varstr_init();
    if (cur == NULL) {
      perror("init varstr in read_data()");
      return false;
    }
    read_last = r2w(cur, text);
    if (last != NULL) {
      wchar_t *v;
      wchar_t *now = last;
      if ((last = v = varstr_pack(cur)) == NULL) {
        perror("packing varstr in read_data()");
        return false;
      }
      store_kv(now, v, is_ss);
      is_ss = false;
    }
    if (last == NULL && (last = varstr_pack(cur)) == NULL) {
      perror("packing varstr in read_data()");
      return false;
    }
    if (read_last < 0) {
      break;
    }
    text += read_last;
  }
  return true;
}


x86 assembly (clang, -O0):
<read_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <varstr_init@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11bf <read_data+0x6f>
lea    0xe52(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1296 <read_data+0x146>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <r2w@plt>
mov    %eax,-0x2c(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     122c <read_data+0xdc>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <varstr_pack@plt>
mov    %rax,-0x38(%rbp)
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1215 <read_data+0xc5>
lea    0xe17(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1296 <read_data+0x146>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%edx
call   1040 <store_kv@plt>
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1266 <read_data+0x116>
mov    -0x28(%rbp),%rdi
call   1060 <varstr_pack@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1266 <read_data+0x116>
lea    0xdc6(%rip),%rdi
call   1070 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1296 <read_data+0x146>
cmpl   $0x0,-0x2c(%rbp)
jge    1275 <read_data+0x125>
jmp    128f <read_data+0x13f>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1191 <read_data+0x41>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1030 <varstr_init@plt>
lea    0xe8e(%rip),%rdi
test   %rax,%rax
je     1221 <read_data+0xd1>
mov    %rax,%rbp
xor    %r12d,%r12d
test   %r14d,%r14d
setne  %r12b
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <r2w@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1060 <varstr_pack@plt>
mov    %rax,%r15
test   %r13,%r13
je     11d0 <read_data+0x80>
test   %r15,%r15
je     1217 <read_data+0xc7>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12d,%edx
call   1040 <store_kv@plt>
xor    %r12d,%r12d
jmp    11d5 <read_data+0x85>
cs nopw 0x0(%rax,%rax,1)
test   %r15,%r15
je     1217 <read_data+0xc7>
test   %r14d,%r14d
js     11ff <read_data+0xaf>
mov    %r14d,%eax
lea    (%rbx,%rax,4),%rbx
xor    %eax,%eax
call   1030 <varstr_init@plt>
mov    %rax,%rbp
mov    %r15,%r13
test   %rax,%rax
jne    1190 <read_data+0x40>
xor    %r15d,%r15d
lea    0xe03(%rip),%rdi
jmp    1221 <read_data+0xd1>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdfd(%rip),%rdi
xor    %r15d,%r15d
call   1070 <perror@plt>
jmp    1205 <read_data+0xb5>

LLVM IR (-O0):
%struct.varstr = type { i32 }
@.str = [27 x i8] c"init varstr in read_data()\00"
@.str.1 = [30 x i8] c"packing varstr in read_data()\00"
define i32 @read_data(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca %struct.varstr*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32* null, i32** %6
store %struct.varstr* null, %struct.varstr** %7
store i32 0, i32* %8
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 1, i32 0
store i32 %15, i32* %9
store i32* null, i32** %6
br label %16
16: ; preds = %53, %2
%17 = call %struct.varstr* (...) @varstr_init()
store %struct.varstr* %17, %struct.varstr** %7
%18 = load %struct.varstr*, %struct.varstr** %7
%19 = icmp eq %struct.varstr* %18, null
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %59
22: ; preds = %16
%23 = load %struct.varstr*, %struct.varstr** %7
%24 = load i32*, i32** %4
%25 = call i32 @r2w(%struct.varstr* %23, i32* %24)
store i32 %25, i32* %8
%26 = load i32*, i32** %6
%27 = icmp ne i32* %26, null
br i1 %27, label %28, label %40
28: ; preds = %22
%29 = load i32*, i32** %6
store i32* %29, i32** %11
%30 = load %struct.varstr*, %struct.varstr** %7
%31 = call i32* @varstr_pack(%struct.varstr* %30)
store i32* %31, i32** %10
store i32* %31, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %59
35: ; preds = %28
%36 = load i32*, i32** %11
%37 = load i32*, i32** %10
%38 = load i32, i32* %9
%39 = call i32 @store_kv(i32* %36, i32* %37, i32 %38)
store i32 0, i32* %9
br label %40
40: ; preds = %35, %22
%41 = load i32*, i32** %6
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load %struct.varstr*, %struct.varstr** %7
%45 = call i32* @varstr_pack(%struct.varstr* %44)
store i32* %45, i32** %6
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %49
47: ; preds = %43
%48 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %59
49: ; preds = %43, %40
%50 = load i32, i32* %8
%51 = icmp slt i32 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %49
br label %58
53: ; preds = %49
%54 = load i32, i32* %8
%55 = load i32*, i32** %4
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i32, i32* %55, i64 %56
store i32* %57, i32** %4
br label %16
58: ; preds = %52
store i32 1, i32* %3
br label %59
59: ; preds = %58, %47, %33, %20
%60 = load i32, i32* %3
ret i32 %60
}

LLVM IR (-O2):
%struct.varstr = type { i32 }
@.str = [27 x i8] c"init varstr in read_data()\00"
@.str.1 = [30 x i8] c"packing varstr in read_data()\00"
define i32 @read_data(i32* %0, i32 %1) {
%3 = tail call %struct.varstr* (...) @varstr_init()
%4 = icmp eq %struct.varstr* %3, null
br i1 %4, label %29, label %5
5: ; preds = %2
%6 = icmp ne i32 %1, 0
%7 = zext i1 %6 to i32
br label %8
8: ; preds = %5, %24
%9 = phi %struct.varstr* [ %27, %24 ], [ %3, %5 ]
%10 = phi i32* [ %26, %24 ], [ %0, %5 ]
%11 = phi i32 [ %22, %24 ], [ %7, %5 ]
%12 = phi i32* [ %15, %24 ], [ null, %5 ]
%13 = tail call i32 @r2w(%struct.varstr* %9, i32* %10)
%14 = icmp eq i32* %12, null
%15 = tail call i32* @varstr_pack(%struct.varstr* %9)
%16 = icmp eq i32* %15, null
br i1 %14, label %20, label %17
17: ; preds = %8
br i1 %16, label %29, label %18
18: ; preds = %17
%19 = tail call i32 @store_kv(i32* %12, i32* %15, i32 %11)
br label %21
20: ; preds = %8
br i1 %16, label %29, label %21
21: ; preds = %18, %20
%22 = phi i32 [ %11, %20 ], [ 0, %18 ]
%23 = icmp slt i32 %13, 0
br i1 %23, label %32, label %24
24: ; preds = %21
%25 = zext i32 %13 to i64
%26 = getelementptr inbounds i32, i32* %10, i64 %25
%27 = tail call %struct.varstr* (...) @varstr_init()
%28 = icmp eq %struct.varstr* %27, null
br i1 %28, label %29, label %8
29: ; preds = %20, %17, %24, %2
%30 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), %24 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %17 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %20 ]
%31 = tail call i32 @perror(i8* %30)
br label %32
32: ; preds = %21, %29
%33 = phi i32 [ 0, %29 ], [ 1, %21 ]
ret i32 %33
}