#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*/ gbcode_capitalize(char *);
int gbcode_get_character_unicode_int(char *);
int /*<<< orphan*/ gbcode_get_pinyin_by_unicode(char *, char *);
unsigned int gbcode_get_str_len(char const *);
int /*<<< orphan*/ gbcode_substr(char const *, unsigned int, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void gbcode_get_full_pinyin(const char *str, int capitalize, char *result,
                            unsigned int result_size) {
  unsigned int i = 0, len = 0, str_len = 0;
  int unicode;
  for (i = 0, str_len = gbcode_get_str_len(str); i < str_len; i++) {
    char ch[6] = {
        0,
    };
    char chars[6] = {
        0,
    };
    gbcode_substr(str, i, 1, ch);
    unicode = gbcode_get_character_unicode_int(ch);
    if (unicode > 40869 || unicode < 19968) {
      strcat(result, ch);
    } else {
      gbcode_get_pinyin_by_unicode(ch, chars);
      int tmp = strlen(chars);
      if (result_size < (len += tmp)) {
        return;
      }
      if (tmp > 0) {
        if (capitalize)
          gbcode_capitalize(chars);
        strcat(result, chars);
      }
    }
  }
}


x86 assembly (clang, -O0):
<gbcode_get_full_pinyin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <gbcode_get_str_len@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    12ab <gbcode_get_full_pinyin+0x12b>
lea    -0x32(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x32(%rbp),%rcx
mov    $0x1,%edx
call   1090 <gbcode_substr@plt>
lea    -0x32(%rbp),%rdi
call   1060 <gbcode_get_character_unicode_int@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x9fa5,-0x2c(%rbp)
jg     1225 <gbcode_get_full_pinyin+0xa5>
cmpl   $0x4e00,-0x2c(%rbp)
jge    1237 <gbcode_get_full_pinyin+0xb7>
mov    -0x18(%rbp),%rdi
lea    -0x32(%rbp),%rsi
call   10a0 <strcat@plt>
jmp    1298 <gbcode_get_full_pinyin+0x118>
lea    -0x32(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1070 <gbcode_get_pinyin_by_unicode@plt>
lea    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x3c(%rbp),%ecx
add    -0x24(%rbp),%ecx
mov    %ecx,-0x24(%rbp)
cmp    %ecx,%eax
jae    1269 <gbcode_get_full_pinyin+0xe9>
jmp    12ab <gbcode_get_full_pinyin+0x12b>
cmpl   $0x0,-0x3c(%rbp)
jle    1293 <gbcode_get_full_pinyin+0x113>
cmpl   $0x0,-0xc(%rbp)
je     1286 <gbcode_get_full_pinyin+0x106>
lea    -0x38(%rbp),%rdi
call   1080 <gbcode_capitalize@plt>
mov    -0x18(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   10a0 <strcat@plt>
jmp    1298 <gbcode_get_full_pinyin+0x118>
jmp    129d <gbcode_get_full_pinyin+0x11d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11be <gbcode_get_full_pinyin+0x3e>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gbcode_get_full_pinyin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,0x14(%rsp)
mov    %rdx,0x20(%rsp)
mov    %esi,0x10(%rsp)
mov    %rdi,%r13
call   1030 <gbcode_get_str_len@plt>
test   %eax,%eax
je     1267 <gbcode_get_full_pinyin+0xf7>
mov    %eax,%r14d
xor    %ebp,%ebp
lea    0x18(%rsp),%r12
xor    %r15d,%r15d
jmp    11c9 <gbcode_get_full_pinyin+0x59>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rsi
mov    0x20(%rsp),%rdi
call   1090 <strcat@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
je     1267 <gbcode_get_full_pinyin+0xf7>
movw   $0x0,0x1c(%rsp)
movl   $0x0,0x18(%rsp)
movw   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1080 <gbcode_substr@plt>
mov    %r12,%rdi
call   1050 <gbcode_get_character_unicode_int@plt>
add    $0xffff605a,%eax
cmp    $0xffffae5a,%eax
jb     11b0 <gbcode_get_full_pinyin+0x40>
mov    %r12,%rbx
mov    %r12,%rdi
lea    0x8(%rsp),%r12
mov    %r12,%rsi
call   1060 <gbcode_get_pinyin_by_unicode@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
add    %eax,%r15d
cmp    0x14(%rsp),%r15d
ja     1267 <gbcode_get_full_pinyin+0xf7>
test   %eax,%eax
jle    1255 <gbcode_get_full_pinyin+0xe5>
cmpl   $0x0,0x10(%rsp)
mov    %rbx,%r12
je     125d <gbcode_get_full_pinyin+0xed>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <gbcode_capitalize@plt>
mov    %rbx,%rsi
jmp    11b3 <gbcode_get_full_pinyin+0x43>
mov    %rbx,%r12
jmp    11bd <gbcode_get_full_pinyin+0x4d>
lea    0x8(%rsp),%rsi
jmp    11b3 <gbcode_get_full_pinyin+0x43>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @gbcode_get_full_pinyin(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [6 x i8]
%14 = alloca [6 x i8]
%15 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %9
%16 = load i8*, i8** %5
%17 = call i32 @gbcode_get_str_len(i8* %16)
store i32 %17, i32* %11
br label %18
18: ; preds = %67, %4
%19 = load i32, i32* %9
%20 = load i32, i32* %11
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %70
22: ; preds = %18
%23 = bitcast [6 x i8]* %13 to i8*
%24 = bitcast [6 x i8]* %14 to i8*
%25 = load i8*, i8** %5
%26 = load i32, i32* %9
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%28 = call i32 @gbcode_substr(i8* %25, i32 %26, i32 1, i8* %27)
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%30 = call i32 @gbcode_get_character_unicode_int(i8* %29)
store i32 %30, i32* %12
%31 = load i32, i32* %12
%32 = icmp sgt i32 %31, 40869
br i1 %32, label %36, label %33
33: ; preds = %22
%34 = load i32, i32* %12
%35 = icmp slt i32 %34, 19968
br i1 %35, label %36, label %40
36: ; preds = %33, %22
%37 = load i8*, i8** %7
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%39 = call i32 @strcat(i8* %37, i8* %38)
br label %66
40: ; preds = %33
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %13, i64 0, i64 0
%42 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%43 = call i32 @gbcode_get_pinyin_by_unicode(i8* %41, i8* %42)
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
store i32 %45, i32* %15
%46 = load i32, i32* %8
%47 = load i32, i32* %15
%48 = load i32, i32* %10
%49 = add i32 %48, %47
store i32 %49, i32* %10
%50 = icmp ult i32 %46, %49
br i1 %50, label %51, label %52
51: ; preds = %40
br label %70
52: ; preds = %40
%53 = load i32, i32* %15
%54 = icmp sgt i32 %53, 0
br i1 %54, label %55, label %65
55: ; preds = %52
%56 = load i32, i32* %6
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%60 = call i32 @gbcode_capitalize(i8* %59)
br label %61
61: ; preds = %58, %55
%62 = load i8*, i8** %7
%63 = getelementptr inbounds [6 x i8], [6 x i8]* %14, i64 0, i64 0
%64 = call i32 @strcat(i8* %62, i8* %63)
br label %65
65: ; preds = %61, %52
br label %66
66: ; preds = %65, %36
br label %67
67: ; preds = %66
%68 = load i32, i32* %9
%69 = add i32 %68, 1
store i32 %69, i32* %9
br label %18
70: ; preds = %51, %18
ret void
}

LLVM IR (-O2):
define void @gbcode_get_full_pinyin(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca [6 x i8]
%6 = alloca [6 x i8]
%7 = tail call i32 @gbcode_get_str_len(i8* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %39, label %9
9: ; preds = %4
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%12 = icmp eq i32 %1, 0
br label %13
13: ; preds = %9, %35
%14 = phi i32 [ 0, %9 ], [ %37, %35 ]
%15 = phi i32 [ 0, %9 ], [ %36, %35 ]
%16 = call i32 @gbcode_substr(i8* %0, i32 %14, i32 1, i8* %10)
%17 = call i32 @gbcode_get_character_unicode_int(i8* %10)
%18 = add i32 %17, -40870
%19 = icmp ult i32 %18, -20902
br i1 %19, label %31, label %20
20: ; preds = %13
%21 = call i32 @gbcode_get_pinyin_by_unicode(i8* %10, i8* %11)
%22 = call i32 @strlen(i8* %11)
%23 = add i32 %22, %15
%24 = icmp ugt i32 %23, %3
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = icmp sgt i32 %22, 0
br i1 %26, label %27, label %35
27: ; preds = %25
br i1 %12, label %31, label %28
28: ; preds = %27
%29 = call i32 @gbcode_capitalize(i8* %11)
br label %31
30: ; preds = %20
br label %39
31: ; preds = %27, %28, %13
%32 = phi i8* [ %10, %13 ], [ %11, %28 ], [ %11, %27 ]
%33 = phi i32 [ %15, %13 ], [ %23, %28 ], [ %23, %27 ]
%34 = call i32 @strcat(i8* %2, i8* %32)
br label %35
35: ; preds = %31, %25
%36 = phi i32 [ %23, %25 ], [ %33, %31 ]
%37 = add nuw i32 %14, 1
%38 = icmp eq i32 %37, %7
br i1 %38, label %39, label %13
39: ; preds = %35, %4, %30
ret void
}