#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*/ free(char *);
int /*<<< orphan*/ gbk2utf8(char *, size_t, char *, size_t);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ print_log(char *, char *, char *, char *);
void pr_info_gbk(char *in, size_t inlen) {
  size_t _utf8_size = inlen << 2;
  char *_utf8_buf = (char *)malloc(_utf8_size);
  memset(_utf8_buf, 0, _utf8_size);
  if (_utf8_buf != NULL) {
    gbk2utf8(in, inlen, _utf8_buf, _utf8_size);
    print_log("I", "", "%s", _utf8_buf);
    ;
    free(_utf8_buf);
  } else {
    _utf8_buf = in;
    print_log("I", "", "%s", _utf8_buf);
    ;
  }
}


x86 assembly (clang, -O0):
<pr_info_gbk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
xor    %esi,%esi
call   1050 <memset@plt>
cmpq   $0x0,-0x20(%rbp)
je     11d4 <pr_info_gbk+0x84>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1060 <gbk2utf8@plt>
mov    -0x20(%rbp),%rcx
lea    0xe4d(%rip),%rdi
lea    0xe47(%rip),%rsi
lea    0xe41(%rip),%rdx
call   1040 <print_log@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
jmp    11fa <pr_info_gbk+0xaa>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
lea    0xe19(%rip),%rdi
lea    0xe13(%rip),%rsi
lea    0xe0d(%rip),%rdx
call   1040 <print_log@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pr_info_gbk>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x0(,%rsi,4),%r15
mov    %r15,%rdi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1050 <memset@plt>
test   %rbx,%rbx
je     11c4 <pr_info_gbk+0x74>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
call   1060 <gbk2utf8@plt>
lea    0xe65(%rip),%rdi
lea    0xe5f(%rip),%rsi
lea    0xe59(%rip),%rdx
mov    %rbx,%rcx
call   1040 <print_log@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
lea    0xe35(%rip),%rdi
lea    0xe2f(%rip),%rsi
lea    0xe29(%rip),%rdx
mov    %r14,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <print_log@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"I\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
define void @pr_info_gbk(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = shl i64 %7, 2
store i64 %8, i64* %5
%9 = load i64, i64* %5
%10 = call i64 @malloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = load i64, i64* %5
%14 = call i32 @memset(i8* %12, i32 0, i64 %13)
%15 = load i8*, i8** %6
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %27
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = load i64, i64* %4
%20 = load i8*, i8** %6
%21 = load i64, i64* %5
%22 = call i32 @gbk2utf8(i8* %18, i64 %19, i8* %20, i64 %21)
%23 = load i8*, i8** %6
%24 = call i32 @print_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @free(i8* %25)
br label %31
27: ; preds = %2
%28 = load i8*, i8** %3
store i8* %28, i8** %6
%29 = load i8*, i8** %6
%30 = call i32 @print_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %17
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"I\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c"%s\00"
define void @pr_info_gbk(i8* %0, i64 %1) {
%3 = shl i64 %1, 2
%4 = tail call i64 @malloc(i64 %3)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @memset(i8* %5, i32 0, i64 %3)
%7 = icmp eq i64 %4, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @gbk2utf8(i8* %0, i64 %1, i8* %5, i64 %3)
%10 = tail call i32 @print_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%11 = tail call i32 @free(i8* %5)
br label %14
12: ; preds = %2
%13 = tail call i32 @print_log(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %12, %8
ret void
}