#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 */

/* Variables and functions */
int /*<<< orphan*/ exists_word(char *);
int /*<<< orphan*/ process_word(int, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void process_chinese_word(int pos, char *word) {
  int i, j, len = strlen(word);
  char tmp[1024];
  i = 0;
  while (i < len) {
    j = len - i;
    if (j > 10)
      j = 10;
    strncpy(tmp, word + i, j);
    tmp[j] = 0;
    while (!exists_word(tmp) && j > 2) {
      j -= 2;
      strncpy(tmp, word + i, j);
      tmp[j] = 0;
    }
    process_word(pos + i, tmp);
    i += j;
  }
}


x86 assembly (clang, -O0):
<process_chinese_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1244 <process_chinese_word+0x104>
mov    -0x1c(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jle    118b <process_chinese_word+0x4b>
movl   $0xa,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
lea    -0x420(%rbp),%rdi
call   1060 <exists_word@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x421(%rbp)
jne    11dd <process_chinese_word+0x9d>
cmpl   $0x2,-0x18(%rbp)
setg   %al
mov    %al,-0x421(%rbp)
mov    -0x421(%rbp),%al
test   $0x1,%al
jne    11f0 <process_chinese_word+0xb0>
jmp    1224 <process_chinese_word+0xe4>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
add    %rax,%rsi
mov    -0x18(%rbp),%edx
call   1030 <strncpy@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
jmp    11b1 <process_chinese_word+0x71>
mov    -0x4(%rbp),%edi
add    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1040 <process_word@plt>
mov    -0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1165 <process_chinese_word+0x25>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_chinese_word>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rdi,0x10(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rsi,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1229 <process_chinese_word+0xe9>
xor    %r12d,%r12d
lea    0x20(%rsp),%r13
mov    %eax,0xc(%rsp)
jmp    11a4 <process_chinese_word+0x64>
nopl   0x0(%rax)
mov    0x10(%rsp),%rax
lea    (%r12,%rax,1),%edi
mov    %r13,%rsi
call   1040 <process_word@plt>
add    %r12d,%r15d
mov    %r15d,%r12d
mov    0xc(%rsp),%eax
cmp    %r15d,%eax
jle    1229 <process_chinese_word+0xe9>
mov    %eax,%r15d
sub    %r12d,%r15d
cmp    $0xa,%r15d
mov    $0xa,%eax
cmovge %eax,%r15d
movslq %r12d,%rbx
add    0x18(%rsp),%rbx
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
movslq %r15d,%r14
movb   $0x0,0x20(%rsp,%r14,1)
mov    %r13,%rdi
call   1060 <exists_word@plt>
cmp    $0x3,%r14d
jl     1180 <process_chinese_word+0x40>
test   %eax,%eax
jne    1180 <process_chinese_word+0x40>
lea    -0x2(%r15),%r14d
nopl   0x0(%rax)
mov    %r15d,%ebp
lea    -0x2(%rbp),%r15d
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x20(%rsp,%r14,1)
mov    %r13,%rdi
call   1060 <exists_word@plt>
cmp    $0x5,%ebp
jb     1180 <process_chinese_word+0x40>
add    $0xfffffffffffffffe,%r14
test   %eax,%eax
je     11f0 <process_chinese_word+0xb0>
jmp    1180 <process_chinese_word+0x40>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @process_chinese_word(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %7
store i32 0, i32* %5
br label %11
11: ; preds = %55, %2
%12 = load i32, i32* %5
%13 = load i32, i32* %7
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %64
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 10
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 10, i32* %6
br label %22
22: ; preds = %21, %15
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%24 = load i8*, i8** %4
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i32, i32* %6
%29 = call i32 @strncpy(i8* %23, i8* %27, i32 %28)
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %31
store i8 0, i8* %32
br label %33
33: ; preds = %42, %22
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = call i32 @exists_word(i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = load i32, i32* %6
%39 = icmp sgt i32 %38, 2
br label %40
40: ; preds = %37, %33
%41 = phi i1 [ false, %33 ], [ %39, %37 ]
br i1 %41, label %42, label %55
42: ; preds = %40
%43 = load i32, i32* %6
%44 = sub nsw i32 %43, 2
store i32 %44, i32* %6
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%46 = load i8*, i8** %4
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i32, i32* %6
%51 = call i32 @strncpy(i8* %45, i8* %49, i32 %50)
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 %53
store i8 0, i8* %54
br label %33
55: ; preds = %40
%56 = load i32, i32* %3
%57 = load i32, i32* %5
%58 = add nsw i32 %56, %57
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%60 = call i32 @process_word(i32 %58, i8* %59)
%61 = load i32, i32* %6
%62 = load i32, i32* %5
%63 = add nsw i32 %62, %61
store i32 %63, i32* %5
br label %11
64: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @process_chinese_word(i32 %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32 @strlen(i8* %1)
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp sgt i32 %4, 0
br i1 %6, label %7, label %37
7: ; preds = %2, %31
%8 = phi i32 [ %35, %31 ], [ 0, %2 ]
%9 = sub nsw i32 %4, %8
%10 = icmp slt i32 %9, 10
%11 = select i1 %10, i32 %9, i32 10
%12 = sext i32 %8 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = call i32 @strncpy(i8* %5, i8* %13, i32 %11)
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @exists_word(i8* %5)
%18 = icmp eq i32 %17, 0
%19 = icmp sgt i32 %11, 2
%20 = and i1 %19, %18
br i1 %20, label %21, label %31
21: ; preds = %7, %21
%22 = phi i32 [ %23, %21 ], [ %11, %7 ]
%23 = add nsw i32 %22, -2
%24 = call i32 @strncpy(i8* %5, i8* %13, i32 %23)
%25 = zext i32 %23 to i64
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %25
store i8 0, i8* %26
%27 = call i32 @exists_word(i8* %5)
%28 = icmp eq i32 %27, 0
%29 = icmp ugt i32 %22, 4
%30 = and i1 %29, %28
br i1 %30, label %21, label %31
31: ; preds = %21, %7
%32 = phi i32 [ %11, %7 ], [ %23, %21 ]
%33 = add nsw i32 %8, %0
%34 = call i32 @process_word(i32 %33, i8* %5)
%35 = add nsw i32 %32, %8
%36 = icmp sgt i32 %4, %35
br i1 %36, label %7, label %37
37: ; preds = %31, %2
ret void
}