#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 wchar_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ *_wfopen(char *, char *);
int /*<<< orphan*/ _wsetlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fwprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int main() {
  wchar_t ch;
  unsigned char buf[2];
  _wsetlocale(LC_ALL, L"");
  FILE *fp = _wfopen(L"colon.txt", L"w+");
  if (fp != NULL) {
    int ret = fwprintf(fp, L"：");
    assert(ret != -1);
    rewind(fp);
    fwscanf(fp, L"%c", &ch);
    fwprintf(stdout, L"%c\n", ch);
    rewind(fp);
    fclose(fp);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
lea    0xec5(%rip),%rsi
call   1070 <_wsetlocale@plt>
lea    0xe65(%rip),%rdi
lea    0xe86(%rip),%rsi
call   1090 <_wfopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1227 <main+0xb7>
mov    -0x18(%rbp),%rax
mov    %eax,%edi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1080 <fwprintf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x18(%rbp),%rdi
lea    0xe4a(%rip),%rsi
lea    -0x8(%rbp),%rdx
call   1060 <fwscanf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1080 <fwprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1070 <_wsetlocale@plt>
lea    0xe6f(%rip),%rdi
lea    0xe90(%rip),%rsi
call   1090 <_wfopen@plt>
test   %rax,%rax
je     120a <main+0x9a>
mov    %rax,%rbx
lea    0xe88(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1080 <fwprintf@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
setne  %dil
call   1050 <assert@plt>
mov    %rbx,%rdi
call   1040 <rewind@plt>
lea    0xe6a(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1060 <fwscanf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
mov    0xc(%rsp),%edx
lea    0xe55(%rip),%rsi
xor    %eax,%eax
call   1080 <fwprintf@plt>
mov    %rbx,%rdi
call   1040 <rewind@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i32] zeroinitializer
@.str.1 = [10 x i32] [i32 99, i32 111, i32 108, i32 111, i32 110, i32 46, i32 116, i32 120, i32 116, i32 0]
@.str.2 = [3 x i32] [i32 119, i32 43, i32 0]
@.str.3 = [2 x i32] [i32 65306, i32 0]
@.str.4 = [3 x i32] [i32 37, i32 99, i32 0]
@stdout = global i32 0
@.str.5 = [4 x i32] [i32 37, i32 99, i32 10, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i8]
%4 = alloca i32*
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @LC_ALL
%7 = call i32 @_wsetlocale(i32 %6, i8* bitcast ([1 x i32]* @.str to i8*))
%8 = call i32* @_wfopen(i8* bitcast ([10 x i32]* @.str.1 to i8*), i8* bitcast ([3 x i32]* @.str.2 to i8*))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %30
11: ; preds = %0
%12 = load i32*, i32** %4
%13 = ptrtoint i32* %12 to i32
%14 = call i32 (i32, i8*, ...) @fwprintf(i32 %13, i8* bitcast ([2 x i32]* @.str.3 to i8*))
store i32 %14, i32* %5
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, -1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %4
%20 = call i32 @rewind(i32* %19)
%21 = load i32*, i32** %4
%22 = call i32 @fwscanf(i32* %21, i8* bitcast ([3 x i32]* @.str.4 to i8*), i32* %2)
%23 = load i32, i32* @stdout
%24 = load i32, i32* %2
%25 = call i32 (i32, i8*, ...) @fwprintf(i32 %23, i8* bitcast ([4 x i32]* @.str.5 to i8*), i32 %24)
%26 = load i32*, i32** %4
%27 = call i32 @rewind(i32* %26)
%28 = load i32*, i32** %4
%29 = call i32 @fclose(i32* %28)
br label %30
30: ; preds = %11, %0
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i32] zeroinitializer
@.str.1 = [10 x i32] [i32 99, i32 111, i32 108, i32 111, i32 110, i32 46, i32 116, i32 120, i32 116, i32 0]
@.str.2 = [3 x i32] [i32 119, i32 43, i32 0]
@.str.3 = [2 x i32] [i32 65306, i32 0]
@.str.4 = [3 x i32] [i32 37, i32 99, i32 0]
@stdout = global i32 0
@.str.5 = [4 x i32] [i32 37, i32 99, i32 10, i32 0]
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @_wsetlocale(i32 %3, i8* bitcast ([1 x i32]* @.str to i8*))
%5 = tail call i32* @_wfopen(i8* bitcast ([10 x i32]* @.str.1 to i8*), i8* bitcast ([3 x i32]* @.str.2 to i8*))
%6 = icmp eq i32* %5, null
br i1 %6, label %21, label %7
7: ; preds = %0
%8 = ptrtoint i32* %5 to i64
%9 = trunc i64 %8 to i32
%10 = tail call i32 (i32, i8*, ...) @fwprintf(i32 %9, i8* bitcast ([2 x i32]* @.str.3 to i8*))
%11 = icmp ne i32 %10, -1
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i32 @rewind(i32* %5)
%15 = call i32 @fwscanf(i32* %5, i8* bitcast ([3 x i32]* @.str.4 to i8*), i32* %1)
%16 = load i32, i32* @stdout
%17 = load i32, i32* %1
%18 = call i32 (i32, i8*, ...) @fwprintf(i32 %16, i8* bitcast ([4 x i32]* @.str.5 to i8*), i32 %17)
%19 = call i32 @rewind(i32* %5)
%20 = call i32 @fclose(i32* %5)
br label %21
21: ; preds = %7, %0
ret i32 0
}