#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*/ Make_Hex_Room(char *);
int /*<<< orphan*/ h2a(char *, scalar_t__, char **);
int /*<<< orphan*/ nfc_gbk_to_utf8(char *, char **);
scalar_t__ strlen(char *);
int ui_getint(char *);
char *ui_gettext(char *);
int /*<<< orphan*/ ui_settext(char *, char *);
void btnHex_Click() {
  char *s = ui_gettext("txtAsc");
  int do_conv = ui_getint("chkAsUTF8");
  if (strlen(s) == 0)
    return;
  char *h = 0;
  if (do_conv) {
    char *g;
    nfc_gbk_to_utf8(s, &g);
    h2a(g, strlen(g), &h);
  } else
    h2a(s, strlen(s), &h);
  int do_mkroom = ui_getint("chkSpace");
  if (do_mkroom)
    Make_Hex_Room(h);
  else
    ui_settext("txtHex", h);
}


x86 assembly (clang, -O0):
<btnHex_Click>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe81(%rip),%rdi
call   1030 <ui_gettext@plt>
mov    %rax,-0x8(%rbp)
lea    0xe78(%rip),%rdi
call   1080 <ui_getint@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jne    11af <btnHex_Click+0x3f>
jmp    124c <btnHex_Click+0xdc>
movq   $0x0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f4 <btnHex_Click+0x84>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <nfc_gbk_to_utf8@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
lea    -0x18(%rbp),%rdx
call   1060 <h2a@plt>
jmp    1215 <btnHex_Click+0xa5>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
lea    -0x18(%rbp),%rdx
call   1060 <h2a@plt>
lea    0xdf5(%rip),%rdi
call   1080 <ui_getint@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     123c <btnHex_Click+0xcc>
mov    -0x18(%rbp),%rdi
call   1070 <Make_Hex_Room@plt>
jmp    124c <btnHex_Click+0xdc>
mov    -0x18(%rbp),%rsi
lea    0xdd3(%rip),%rdi
call   1090 <ui_settext@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<btnHex_Click>:
push   %rbx
sub    $0x10,%rsp
lea    0xe84(%rip),%rdi
call   1030 <ui_gettext@plt>
mov    %rax,%rbx
lea    0xe7c(%rip),%rdi
call   1080 <ui_getint@plt>
cmpb   $0x0,(%rbx)
je     11f3 <btnHex_Click+0x83>
movq   $0x0,(%rsp)
test   %eax,%eax
je     11b3 <btnHex_Click+0x43>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <nfc_gbk_to_utf8@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1060 <h2a@plt>
lea    0xe41(%rip),%rdi
call   1080 <ui_getint@plt>
mov    (%rsp),%rsi
test   %eax,%eax
je     11e7 <btnHex_Click+0x77>
mov    %rsi,%rdi
call   1070 <Make_Hex_Room@plt>
jmp    11f3 <btnHex_Click+0x83>
lea    0xe2c(%rip),%rdi
call   1090 <ui_settext@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"txtAsc\00"
@.str.1 = [10 x i8] c"chkAsUTF8\00"
@.str.2 = [9 x i8] c"chkSpace\00"
@.str.3 = [7 x i8] c"txtHex\00"
define void @btnHex_Click() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = call i8* @ui_gettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %1
%7 = call i32 @ui_getint(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 %7, i32* %2
%8 = load i8*, i8** %1
%9 = call i64 @strlen(i8* %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0
br label %37
12: ; preds = %0
store i8* null, i8** %3
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i8*, i8** %1
%17 = call i32 @nfc_gbk_to_utf8(i8* %16, i8** %4)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %4
%20 = call i64 @strlen(i8* %19)
%21 = call i32 @h2a(i8* %18, i64 %20, i8** %3)
br label %27
22: ; preds = %12
%23 = load i8*, i8** %1
%24 = load i8*, i8** %1
%25 = call i64 @strlen(i8* %24)
%26 = call i32 @h2a(i8* %23, i64 %25, i8** %3)
br label %27
27: ; preds = %22, %15
%28 = call i32 @ui_getint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %3
%33 = call i32 @Make_Hex_Room(i8* %32)
br label %37
34: ; preds = %27
%35 = load i8*, i8** %3
%36 = call i32 @ui_settext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %11, %34, %31
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"txtAsc\00"
@.str.1 = [10 x i8] c"chkAsUTF8\00"
@.str.2 = [9 x i8] c"chkSpace\00"
@.str.3 = [7 x i8] c"txtHex\00"
define void @btnHex_Click() {
%1 = alloca i8*
%2 = alloca i8*
%3 = tail call i8* @ui_gettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @ui_getint(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %28, label %7
7: ; preds = %0
%8 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%9 = icmp eq i32 %4, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = bitcast i8** %2 to i8*
%12 = call i32 @nfc_gbk_to_utf8(i8* %3, i8** %2)
%13 = load i8*, i8** %2
%14 = call i64 @strlen(i8* dereferenceable(1) %13)
%15 = call i32 @h2a(i8* %13, i64 %14, i8** %1)
br label %19
16: ; preds = %7
%17 = tail call i64 @strlen(i8* %3)
%18 = call i32 @h2a(i8* %3, i64 %17, i8** %1)
br label %19
19: ; preds = %16, %10
%20 = call i32 @ui_getint(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
%22 = load i8*, i8** %1
br i1 %21, label %25, label %23
23: ; preds = %19
%24 = call i32 @Make_Hex_Room(i8* %22)
br label %27
25: ; preds = %19
%26 = call i32 @ui_settext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %0, %27
ret void
}