#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 */
scalar_t__ ZSTR_CASE_EQ(char const *, char *);
scalar_t__ ZSTR_N_CASE_EQ(char const *, char *, int);
char *zcharset_correct_charset(const char *charset) {
  if (ZSTR_CASE_EQ(charset, "gb2312")) {
    charset = "GB18030";
  } else if (ZSTR_CASE_EQ(charset, "CHINESEBIG5_CHARSET")) {
    charset = "BIG5";
  } else if (ZSTR_CASE_EQ(charset, "GB2312_CHARSET")) {
    charset = "GB18030";
  } else if (ZSTR_CASE_EQ(charset, "GBK")) {
    charset = "GB18030";
  } else if (ZSTR_N_CASE_EQ(charset, "ks_c_5601", 9)) {
    charset = "ISO-2022-KR";
  } else if (ZSTR_N_CASE_EQ(charset, "KS_C_5861", 9)) {
    charset = "EUC-KR";
  } else if (ZSTR_CASE_EQ(charset, "unicode-1-1-utf-7")) {
    charset = "UTF-7";
  }
  return (char *)charset;
}


x86 assembly (clang, -O0):
<zcharset_correct_charset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
cmp    $0x0,%rax
je     1156 <zcharset_correct_charset+0x36>
lea    0xeba(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1275 <zcharset_correct_charset+0x155>
mov    -0x8(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
cmp    $0x0,%rax
je     1180 <zcharset_correct_charset+0x60>
lea    0xeac(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1270 <zcharset_correct_charset+0x150>
mov    -0x8(%rbp),%rdi
lea    0xe9d(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
cmp    $0x0,%rax
je     11aa <zcharset_correct_charset+0x8a>
lea    0xe66(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    126b <zcharset_correct_charset+0x14b>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
cmp    $0x0,%rax
je     11d4 <zcharset_correct_charset+0xb4>
lea    0xe3c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1266 <zcharset_correct_charset+0x146>
mov    -0x8(%rbp),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x9,%edx
call   1040 <ZSTR_N_CASE_EQ@plt>
cmp    $0x0,%rax
je     1203 <zcharset_correct_charset+0xe3>
lea    0xe4b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1261 <zcharset_correct_charset+0x141>
mov    -0x8(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x9,%edx
call   1040 <ZSTR_N_CASE_EQ@plt>
cmp    $0x0,%rax
je     1232 <zcharset_correct_charset+0x112>
lea    0xe32(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <zcharset_correct_charset+0x13c>
mov    -0x8(%rbp),%rdi
lea    0xe25(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
cmp    $0x0,%rax
je     1257 <zcharset_correct_charset+0x137>
lea    0xe21(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    125c <zcharset_correct_charset+0x13c>
jmp    1261 <zcharset_correct_charset+0x141>
jmp    1266 <zcharset_correct_charset+0x146>
jmp    126b <zcharset_correct_charset+0x14b>
jmp    1270 <zcharset_correct_charset+0x150>
jmp    1275 <zcharset_correct_charset+0x155>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zcharset_correct_charset>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xed2(%rip),%rsi
call   1030 <ZSTR_CASE_EQ@plt>
lea    0xecd(%rip),%rbx
test   %rax,%rax
jne    11ec <zcharset_correct_charset+0xcc>
lea    0xec5(%rip),%rsi
mov    %r14,%rdi
call   1030 <ZSTR_CASE_EQ@plt>
test   %rax,%rax
je     1163 <zcharset_correct_charset+0x43>
lea    0xec5(%rip),%rbx
jmp    11ec <zcharset_correct_charset+0xcc>
lea    0xebe(%rip),%rsi
mov    %r14,%rdi
call   1030 <ZSTR_CASE_EQ@plt>
test   %rax,%rax
jne    11ec <zcharset_correct_charset+0xcc>
lea    0xeb9(%rip),%rsi
mov    %r14,%rdi
call   1030 <ZSTR_CASE_EQ@plt>
test   %rax,%rax
jne    11ec <zcharset_correct_charset+0xcc>
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
mov    $0x9,%edx
call   1040 <ZSTR_N_CASE_EQ@plt>
test   %rax,%rax
je     11ad <zcharset_correct_charset+0x8d>
lea    0xe9a(%rip),%rbx
jmp    11ec <zcharset_correct_charset+0xcc>
lea    0xe9d(%rip),%rsi
mov    %r14,%rdi
mov    $0x9,%edx
call   1040 <ZSTR_N_CASE_EQ@plt>
test   %rax,%rax
je     11cf <zcharset_correct_charset+0xaf>
lea    0xe8e(%rip),%rbx
jmp    11ec <zcharset_correct_charset+0xcc>
lea    0xe8c(%rip),%rsi
mov    %r14,%rdi
call   1030 <ZSTR_CASE_EQ@plt>
test   %rax,%rax
lea    0xe8c(%rip),%rbx
cmove  %r14,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"gb2312\00"
@.str.1 = [8 x i8] c"GB18030\00"
@.str.2 = [20 x i8] c"CHINESEBIG5_CHARSET\00"
@.str.3 = [5 x i8] c"BIG5\00"
@.str.4 = [15 x i8] c"GB2312_CHARSET\00"
@.str.5 = [4 x i8] c"GBK\00"
@.str.6 = [10 x i8] c"ks_c_5601\00"
@.str.7 = [12 x i8] c"ISO-2022-KR\00"
@.str.8 = [10 x i8] c"KS_C_5861\00"
@.str.9 = [7 x i8] c"EUC-KR\00"
@.str.10 = [18 x i8] c"unicode-1-1-utf-7\00"
@.str.11 = [6 x i8] c"UTF-7\00"
define i8* @zcharset_correct_charset(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @ZSTR_CASE_EQ(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %43
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i64 @ZSTR_CASE_EQ(i8* %8, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %42
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = call i64 @ZSTR_CASE_EQ(i8* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %41
17: ; preds = %12
%18 = load i8*, i8** %2
%19 = call i64 @ZSTR_CASE_EQ(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %40
22: ; preds = %17
%23 = load i8*, i8** %2
%24 = call i64 @ZSTR_N_CASE_EQ(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 9)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %39
27: ; preds = %22
%28 = load i8*, i8** %2
%29 = call i64 @ZSTR_N_CASE_EQ(i8* %28, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 9)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %38
32: ; preds = %27
%33 = load i8*, i8** %2
%34 = call i64 @ZSTR_CASE_EQ(i8* %33, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i8** %2
br label %37
37: ; preds = %36, %32
br label %38
38: ; preds = %37, %31
br label %39
39: ; preds = %38, %26
br label %40
40: ; preds = %39, %21
br label %41
41: ; preds = %40, %16
br label %42
42: ; preds = %41, %11
br label %43
43: ; preds = %42, %6
%44 = load i8*, i8** %2
ret i8* %44
}

LLVM IR (-O2):
@.str = [7 x i8] c"gb2312\00"
@.str.1 = [8 x i8] c"GB18030\00"
@.str.2 = [20 x i8] c"CHINESEBIG5_CHARSET\00"
@.str.3 = [5 x i8] c"BIG5\00"
@.str.4 = [15 x i8] c"GB2312_CHARSET\00"
@.str.5 = [4 x i8] c"GBK\00"
@.str.6 = [10 x i8] c"ks_c_5601\00"
@.str.7 = [12 x i8] c"ISO-2022-KR\00"
@.str.8 = [10 x i8] c"KS_C_5861\00"
@.str.9 = [7 x i8] c"EUC-KR\00"
@.str.10 = [18 x i8] c"unicode-1-1-utf-7\00"
@.str.11 = [6 x i8] c"UTF-7\00"
define i8* @zcharset_correct_charset(i8* %0) {
%2 = tail call i64 @ZSTR_CASE_EQ(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = tail call i64 @ZSTR_CASE_EQ(i8* %0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = tail call i64 @ZSTR_CASE_EQ(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = tail call i64 @ZSTR_CASE_EQ(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = tail call i64 @ZSTR_N_CASE_EQ(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 9)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = tail call i64 @ZSTR_N_CASE_EQ(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i32 9)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = tail call i64 @ZSTR_CASE_EQ(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0)
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %10 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), %13 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), %16 ], [ %22, %19 ]
ret i8* %24
}