#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*/ cStringToExamine;
typedef int /*<<< orphan*/ UErrorCode;
typedef int /*<<< orphan*/ UChar;
typedef int /*<<< orphan*/ UBreakIterator;

/* Variables and functions */
int /*<<< orphan*/ UBRK_CHARACTER;
int /*<<< orphan*/ UBRK_SENTENCE;
scalar_t__ U_FAILURE(int /*<<< orphan*/);
int /*<<< orphan*/ U_ZERO_ERROR;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printAt(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printEachBackward(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ printEachForward(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printFirst(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printLast(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
char *u_errorName(int /*<<< orphan*/);
int u_strlen(int /*<<< orphan*/ *);
int /*<<< orphan*/ u_uastrcpy(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ubrk_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ubrk_open(int /*<<< orphan*/, char *, int /*<<< orphan*/ *,
                              int, int /*<<< orphan*/ *);
int main(void) {
  UBreakIterator *boundary;
  char cStringToExamine[] = "共产党世界中国深圳。腾讯北京SNG。安卓123消息。  "
                            "Aaa bbb ccc. Ddd eee fff.";
  UChar stringToExamine[sizeof(cStringToExamine) + 1];
  UErrorCode status = U_ZERO_ERROR;
  printf("\n\n"
         "C Boundary Analysis\n"
         "-------------------\n\n");
  printf("Examining: %s\n", cStringToExamine);
  u_uastrcpy(stringToExamine, cStringToExamine);
  boundary = ubrk_open(UBRK_SENTENCE, "zh_CN", stringToExamine, -1, &status);
  if (U_FAILURE(status)) {
    printf("ubrk_open error: %s\n", u_errorName(status));
    exit(1);
  }
  printf("\n----- Sentence Boundaries, forward: -----------\n");
  printEachForward(boundary, stringToExamine);
  printf("\n----- Sentence Boundaries, backward: ----------\n");
  printEachBackward(boundary, stringToExamine);
  ubrk_close(boundary);
  boundary = ubrk_open(UBRK_CHARACTER, "zh_CN", stringToExamine,
                       u_strlen(stringToExamine), &status);
  printf("\n----- Word Boundaries, forward: -----------\n");
  printEachForward(boundary, stringToExamine);
  printf("\n----- Word Boundaries, backward: ----------\n");
  printEachBackward(boundary, stringToExamine);
  printf("\n----- first: -------------\n");
  printFirst(boundary, stringToExamine);
  printf("\n----- last: --------------\n");
  printLast(boundary, stringToExamine);
  printf("\n----- at pos 10: ---------\n");
  printAt(boundary, 10, stringToExamine);
  ubrk_close(boundary);
  printf("\nEnd of C boundary analysis\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe03(%rip),%rsi
mov    $0x5e,%edx
call   10a0 <memcpy@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1f4(%rbp)
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x1f0(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <u_uastrcpy@plt>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    -0x1f0(%rbp),%rdx
lea    0xe3c(%rip),%rsi
mov    $0xffffffff,%ecx
lea    -0x1f4(%rbp),%r8
call   10f0 <ubrk_open@plt>
mov    %rax,-0x10(%rbp)
mov    -0x1f4(%rbp),%edi
call   1050 <U_FAILURE@plt>
cmp    $0x0,%rax
je     12ad <main+0xcd>
mov    -0x1f4(%rbp),%edi
call   1030 <u_errorName@plt>
mov    %rax,%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   1070 <printEachForward@plt>
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   10c0 <printEachBackward@plt>
mov    -0x10(%rbp),%rdi
call   10e0 <ubrk_close@plt>
mov    0x2cdf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x204(%rbp)
lea    -0x1f0(%rbp),%rax
mov    %rax,-0x200(%rbp)
lea    -0x1f0(%rbp),%rdi
call   10d0 <u_strlen@plt>
mov    -0x204(%rbp),%edi
mov    -0x200(%rbp),%rdx
mov    %eax,%ecx
lea    0xd68(%rip),%rsi
lea    -0x1f4(%rbp),%r8
call   10f0 <ubrk_open@plt>
mov    %rax,-0x10(%rbp)
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   1070 <printEachForward@plt>
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   10c0 <printEachBackward@plt>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   10b0 <printFirst@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rsi
call   1080 <printLast@plt>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x1f0(%rbp),%rdx
mov    $0xa,%esi
call   1090 <printAt@plt>
mov    -0x10(%rbp),%rdi
call   10e0 <ubrk_close@plt>
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x1f8,%rsp
movups 0xe5d(%rip),%xmm0
movups %xmm0,0x5e(%rsp)
movaps 0xe43(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe27(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xdef(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xdd3(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
lea    0xe42(%rip),%rdi
call   1050 <puts@plt>
lea    0xe0c(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x70(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <u_uastrcpy@plt>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
lea    0xdec(%rip),%rsi
lea    0xc(%rsp),%r8
mov    %r14,%rdx
mov    $0xffffffff,%ecx
call   10f0 <ubrk_open@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%edi
call   1060 <U_FAILURE@plt>
test   %rax,%rax
jne    13a8 <main+0x1c8>
lea    0xe04(%rip),%rdi
call   1050 <puts@plt>
lea    0x70(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <printEachForward@plt>
lea    0xe19(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <printEachBackward@plt>
mov    %rbx,%rdi
call   10e0 <ubrk_close@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%ebx
mov    %r14,%rdi
call   10d0 <u_strlen@plt>
lea    0xd72(%rip),%rsi
lea    0xc(%rsp),%r8
mov    %ebx,%edi
mov    %r14,%rdx
mov    %eax,%ecx
call   10f0 <ubrk_open@plt>
mov    %rax,%rbx
lea    0xdff(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <printEachForward@plt>
lea    0xe15(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <printEachBackward@plt>
lea    0xe2b(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <printFirst@plt>
lea    0xe30(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <printLast@plt>
lea    0xe35(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
mov    %r14,%rdx
call   10a0 <printAt@plt>
mov    %rbx,%rdi
call   10e0 <ubrk_close@plt>
lea    0xe2d(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
pop    %rbx
pop    %r14
ret
mov    0xc(%rsp),%edi
call   1030 <u_errorName@plt>
lea    0xcbb(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@__const.main.cStringToExamine = [94 x i8] c"\E5\85\B1\E4\BA\A7\E5\85\9A\E4\B8\96\E7\95\8C\E4\B8\AD\E5\9B\BD\E6\B7\B1\E5\9C\B3\E3\80\82\E8\85\BE\E8\AE\AF\E5\8C\97\E4\BA\ACSNG\E3\80\82\E5\AE\89\E5\8D\93123\E6\B6\88\E6\81\AF\E3\80\82 Aaa bbb ccc. Ddd eee fff.\00"
@U_ZERO_ERROR = global i32 0
@.str = [44 x i8] c"\0A\0AC Boundary Analysis\0A-------------------\0A\0A\00"
@.str.1 = [15 x i8] c"Examining: %s\0A\00"
@UBRK_SENTENCE = global i32 0
@.str.2 = [6 x i8] c"zh_CN\00"
@.str.3 = [21 x i8] c"ubrk_open error: %s\0A\00"
@.str.4 = [50 x i8] c"\0A----- Sentence Boundaries, forward: -----------\0A\00"
@.str.5 = [50 x i8] c"\0A----- Sentence Boundaries, backward: ----------\0A\00"
@UBRK_CHARACTER = global i32 0
@.str.6 = [46 x i8] c"\0A----- Word Boundaries, forward: -----------\0A\00"
@.str.7 = [46 x i8] c"\0A----- Word Boundaries, backward: ----------\0A\00"
@.str.8 = [29 x i8] c"\0A----- first: -------------\0A\00"
@.str.9 = [29 x i8] c"\0A----- last: --------------\0A\00"
@.str.10 = [29 x i8] c"\0A----- at pos 10: ---------\0A\00"
@.str.11 = [29 x i8] c"\0AEnd of C boundary analysis\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [94 x i8]
%4 = alloca [95 x i32]
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [94 x i8]* %3 to i8*
%7 = load i32, i32* @U_ZERO_ERROR
store i32 %7, i32* %5
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [94 x i8], [94 x i8]* %3, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%12 = getelementptr inbounds [94 x i8], [94 x i8]* %3, i64 0, i64 0
%13 = call i32 @u_uastrcpy(i32* %11, i8* %12)
%14 = load i32, i32* @UBRK_SENTENCE
%15 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%16 = call i32* @ubrk_open(i32 %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %15, i32 -1, i32* %5)
store i32* %16, i32** %2
%17 = load i32, i32* %5
%18 = call i64 @U_FAILURE(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %0
%21 = load i32, i32* %5
%22 = call i8* @u_errorName(i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32*, i32** %2
%28 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%29 = call i32 @printEachForward(i32* %27, i32* %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%31 = load i32*, i32** %2
%32 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%33 = call i32 @printEachBackward(i32* %31, i32* %32)
%34 = load i32*, i32** %2
%35 = call i32 @ubrk_close(i32* %34)
%36 = load i32, i32* @UBRK_CHARACTER
%37 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%38 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%39 = call i32 @u_strlen(i32* %38)
%40 = call i32* @ubrk_open(i32 %36, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %37, i32 %39, i32* %5)
store i32* %40, i32** %2
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32*, i32** %2
%43 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%44 = call i32 @printEachForward(i32* %42, i32* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0))
%46 = load i32*, i32** %2
%47 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%48 = call i32 @printEachBackward(i32* %46, i32* %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0))
%50 = load i32*, i32** %2
%51 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%52 = call i32 @printFirst(i32* %50, i32* %51)
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%54 = load i32*, i32** %2
%55 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%56 = call i32 @printLast(i32* %54, i32* %55)
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%58 = load i32*, i32** %2
%59 = getelementptr inbounds [95 x i32], [95 x i32]* %4, i64 0, i64 0
%60 = call i32 @printAt(i32* %58, i32 10, i32* %59)
%61 = load i32*, i32** %2
%62 = call i32 @ubrk_close(i32* %61)
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.11, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.cStringToExamine = [94 x i8] c"\E5\85\B1\E4\BA\A7\E5\85\9A\E4\B8\96\E7\95\8C\E4\B8\AD\E5\9B\BD\E6\B7\B1\E5\9C\B3\E3\80\82\E8\85\BE\E8\AE\AF\E5\8C\97\E4\BA\ACSNG\E3\80\82\E5\AE\89\E5\8D\93123\E6\B6\88\E6\81\AF\E3\80\82 Aaa bbb ccc. Ddd eee fff.\00"
@U_ZERO_ERROR = global i32 0
@.str.1 = [15 x i8] c"Examining: %s\0A\00"
@UBRK_SENTENCE = global i32 0
@.str.2 = [6 x i8] c"zh_CN\00"
@.str.3 = [21 x i8] c"ubrk_open error: %s\0A\00"
@UBRK_CHARACTER = global i32 0
@str = [43 x i8] c"\0A\0AC Boundary Analysis\0A-------------------\0A\00"
@str.12 = [49 x i8] c"\0A----- Sentence Boundaries, forward: -----------\00"
@str.13 = [49 x i8] c"\0A----- Sentence Boundaries, backward: ----------\00"
@str.14 = [45 x i8] c"\0A----- Word Boundaries, forward: -----------\00"
@str.15 = [45 x i8] c"\0A----- Word Boundaries, backward: ----------\00"
@str.16 = [28 x i8] c"\0A----- first: -------------\00"
@str.17 = [28 x i8] c"\0A----- last: --------------\00"
@str.18 = [28 x i8] c"\0A----- at pos 10: ---------\00"
@str.19 = [28 x i8] c"\0AEnd of C boundary analysis\00"
define i32 @main() {
%1 = alloca [94 x i8]
%2 = alloca [95 x i32]
%3 = alloca i32
%4 = getelementptr inbounds [94 x i8], [94 x i8]* %1, i64 0, i64 0
%5 = bitcast [95 x i32]* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @U_ZERO_ERROR
store i32 %7, i32* %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = getelementptr inbounds [95 x i32], [95 x i32]* %2, i64 0, i64 0
%11 = call i32 @u_uastrcpy(i32* %10, i8* %4)
%12 = load i32, i32* @UBRK_SENTENCE
%13 = call i32* @ubrk_open(i32 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %10, i32 -1, i32* %3)
%14 = load i32, i32* %3
%15 = call i64 @U_FAILURE(i32 %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %0
%18 = load i32, i32* %3
%19 = call i8* @u_errorName(i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %0
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.12, i64 0, i64 0))
%24 = call i32 @printEachForward(i32* %13, i32* %10)
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.13, i64 0, i64 0))
%26 = call i32 @printEachBackward(i32* %13, i32* %10)
%27 = call i32 @ubrk_close(i32* %13)
%28 = load i32, i32* @UBRK_CHARACTER
%29 = call i32 @u_strlen(i32* %10)
%30 = call i32* @ubrk_open(i32 %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %10, i32 %29, i32* %3)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.14, i64 0, i64 0))
%32 = call i32 @printEachForward(i32* %30, i32* %10)
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.15, i64 0, i64 0))
%34 = call i32 @printEachBackward(i32* %30, i32* %10)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.16, i64 0, i64 0))
%36 = call i32 @printFirst(i32* %30, i32* %10)
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.17, i64 0, i64 0))
%38 = call i32 @printLast(i32* %30, i32* %10)
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.18, i64 0, i64 0))
%40 = call i32 @printAt(i32* %30, i32 10, i32* %10)
%41 = call i32 @ubrk_close(i32* %30)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.19, i64 0, i64 0))
ret i32 0
}