#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 char wchar_t;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ wprintf(char *);
int main(void) {
  wchar_t *s = L"你好，世界！\n";
  if (setlocale(LC_ALL, "zh_CN.UTF-8") == NULL) {
    printf("Could not set local!\n");
  } else {
    wprintf(s);
  }
  printf("A is %#x\n", 'A');
  printf("a is %#x\n", 'a');
  printf("<space> is %#x\n", ' ');
  printf("0 is %#x\n", '0');
  printf("<\\n> is %#x\n", '\n');
  printf("<\\r> is %#x\n", '\r');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xec6(%rip),%rsi
call   1050 <setlocale@plt>
cmp    $0x0,%rax
jne    117c <main+0x4c>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1185 <main+0x55>
mov    -0x10(%rbp),%rdi
call   1040 <wprintf@plt>
lea    0xeb6(%rip),%rdi
mov    $0x41,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
mov    $0x61,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
mov    $0x20,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x30,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0xd,%esi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e98(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1060 <setlocale@plt>
test   %rax,%rax
je     1169 <main+0x29>
lea    0xe9e(%rip),%rdi
call   1050 <wprintf@plt>
jmp    1175 <main+0x35>
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb0(%rip),%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
mov    $0x61,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9e(%rip),%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
mov    $0x30,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0xa,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [8 x i32] [i32 20320, i32 22909, i32 65292, i32 19990, i32 30028, i32 65281, i32 10, i32 0]
@LC_ALL = global i32 0
@.str.1 = [12 x i8] c"zh_CN.UTF-8\00"
@.str.2 = [22 x i8] c"Could not set local!\0A\00"
@.str.3 = [10 x i8] c"A is %#x\0A\00"
@.str.4 = [10 x i8] c"a is %#x\0A\00"
@.str.5 = [16 x i8] c"<space> is %#x\0A\00"
@.str.6 = [10 x i8] c"0 is %#x\0A\00"
@.str.7 = [13 x i8] c"<\\n> is %#x\0A\00"
@.str.8 = [13 x i8] c"<\\r> is %#x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* bitcast ([8 x i32]* @.str to i8*), i8** %2
%3 = load i32, i32* @LC_ALL
%4 = call i32* @setlocale(i32 %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %11
8: ; preds = %0
%9 = load i8*, i8** %2
%10 = call i32 @wprintf(i8* %9)
br label %11
11: ; preds = %8, %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 65)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 97)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 32)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 48)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 10)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 13)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i32] [i32 20320, i32 22909, i32 65292, i32 19990, i32 30028, i32 65281, i32 10, i32 0]
@LC_ALL = global i32 0
@.str.1 = [12 x i8] c"zh_CN.UTF-8\00"
@.str.3 = [10 x i8] c"A is %#x\0A\00"
@.str.4 = [10 x i8] c"a is %#x\0A\00"
@.str.5 = [16 x i8] c"<space> is %#x\0A\00"
@.str.6 = [10 x i8] c"0 is %#x\0A\00"
@.str.7 = [13 x i8] c"<\\n> is %#x\0A\00"
@.str.8 = [13 x i8] c"<\\r> is %#x\0A\00"
@str = [21 x i8] c"Could not set local!\00"
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32* @setlocale(i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @wprintf(i8* bitcast ([8 x i32]* @.str to i8*))
br label %8
8: ; preds = %6, %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 65)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 97)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 32)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 48)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i32 10)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 13)
ret i32 0
}