#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*/ charset;

/* Variables and functions */
int /*<<< orphan*/ logMallocError();
int /*<<< orphan*/ registerProgramMemory(char *, char const **);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned long, char);
char *strdup(char *);
const char *getWcharCharset(void) {
  static const char *wcharCharset = NULL;
  if (!wcharCharset) {
    char charset[0X10];
    snprintf(charset, sizeof(charset), "UCS-%lu%cE",
             (unsigned long)sizeof(unsigned char), 'L');
    if ((wcharCharset = strdup(charset))) {
      registerProgramMemory("wchar-charset", &wcharCharset);
    } else {
      logMallocError();
    }
  }
  return wcharCharset;
}


x86 assembly (clang, -O0):
<getWcharCharset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpq   $0x0,0x2ef8(%rip)
jne    11b4 <getWcharCharset+0x74>
lea    -0x10(%rbp),%rdi
mov    $0x10,%esi
lea    0xe9a(%rip),%rdx
mov    $0x1,%ecx
mov    $0x4c,%r8d
call   1040 <snprintf@plt>
lea    -0x10(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,0x2ec2(%rip)
cmp    $0x0,%rax
je     11a8 <getWcharCharset+0x68>
lea    0xe74(%rip),%rdi
lea    0x2eaa(%rip),%rsi
call   1030 <registerProgramMemory@plt>
jmp    11af <getWcharCharset+0x6f>
mov    $0x0,%al
call   1050 <logMallocError@plt>
jmp    11b4 <getWcharCharset+0x74>
mov    0x2e8d(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWcharCharset>:
push   %rbx
sub    $0x10,%rsp
mov    0x2efc(%rip),%rax
test   %rax,%rax
jne    11aa <getWcharCharset+0x6a>
lea    0xea8(%rip),%rdx
mov    %rsp,%rbx
mov    $0x1,%ecx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x4c,%r8d
call   1040 <snprintf@plt>
mov    %rbx,%rdi
call   1060 <strdup@plt>
mov    %rax,0x2ec6(%rip)
test   %rax,%rax
je     119c <getWcharCharset+0x5c>
lea    0xe7d(%rip),%rdi
lea    0x2eb3(%rip),%rsi
call   1030 <registerProgramMemory@plt>
jmp    11a3 <getWcharCharset+0x63>
xor    %eax,%eax
call   1050 <logMallocError@plt>
mov    0x2e9e(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@getWcharCharset.wcharCharset = internal global i8* null
@.str = [11 x i8] c"UCS-%lu%cE\00"
@.str.1 = [14 x i8] c"wchar-charset\00"
define i8* @getWcharCharset() {
%1 = alloca [16 x i8]
%2 = load i8*, i8** @getWcharCharset.wcharCharset
%3 = icmp ne i8* %2, null
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 1, i8 signext 76)
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** @getWcharCharset.wcharCharset
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @registerProgramMemory(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** @getWcharCharset.wcharCharset)
br label %14
12: ; preds = %4
%13 = call i32 (...) @logMallocError()
br label %14
14: ; preds = %12, %10
br label %15
15: ; preds = %14, %0
%16 = load i8*, i8** @getWcharCharset.wcharCharset
ret i8* %16
}

LLVM IR (-O2):
@getWcharCharset.wcharCharset = internal global i8* null
@.str = [11 x i8] c"UCS-%lu%cE\00"
@.str.1 = [14 x i8] c"wchar-charset\00"
define i8* @getWcharCharset() {
%1 = alloca [16 x i8]
%2 = load i8*, i8** @getWcharCharset.wcharCharset
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %15
4: ; preds = %0
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i64 1, i8 signext 76)
%7 = call i8* @strdup(i8* %5)
store i8* %7, i8** @getWcharCharset.wcharCharset
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32 @registerProgramMemory(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8** @getWcharCharset.wcharCharset)
br label %13
11: ; preds = %4
%12 = call i32 (...) @logMallocError()
br label %13
13: ; preds = %11, %9
%14 = load i8*, i8** @getWcharCharset.wcharCharset
br label %15
15: ; preds = %13, %0
%16 = phi i8* [ %14, %13 ], [ %2, %0 ]
ret i8* %16
}