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

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int wscanf(char *, scalar_t__ *);
int main(void) {
  wchar_t buffer[256];
  setlocale(LC_ALL, "");
  printf("日本語を含む文字列を1文字ずつに分割して表示します\n");
  printf("入力: ");
  if (wscanf(L"%255l[^\n]%*[^\n]", buffer) != 1) {
    return 1;
  }
  scanf("%*c");
  printf("出力: ");
  for (wchar_t *c = buffer; *c; ++c) {
    printf("「%lc」", *c);
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xed8(%rip),%rsi
call   1060 <setlocale@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x810(%rbp),%rsi
lea    0xecb(%rip),%rdi
call   1050 <wscanf@plt>
cmp    $0x1,%eax
je     11bb <main+0x6b>
movl   $0x1,-0x4(%rbp)
jmp    1234 <main+0xe4>
lea    0xe92(%rip),%rdi
call   1070 <scanf@plt>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x810(%rbp),%rax
mov    %rax,-0x818(%rbp)
mov    -0x818(%rbp),%rax
cmpq   $0x0,(%rax)
je     1223 <main+0xd3>
mov    -0x818(%rbp),%rax
mov    (%rax),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x818(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x818(%rbp)
jmp    11e3 <main+0x93>
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1070 <setlocale@plt>
lea    0xe99(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rsi
call   1060 <wscanf@plt>
mov    $0x1,%r14d
cmp    $0x1,%eax
jne    1211 <main+0xb1>
lea    0xe4e(%rip),%rdi
call   1080 <scanf@plt>
lea    0xe46(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     1207 <main+0xa7>
lea    0x8(%rsp),%rbp
lea    0xe30(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%rsi
add    $0x8,%rbp
test   %rsi,%rsi
jne    11f0 <main+0x90>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14d,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [75 x i8] c"\E6\97\A5\E6\9C\AC\E8\AA\9E\E3\82\92\E5\90\AB\E3\82\80\E6\96\87\E5\AD\97\E5\88\97\E3\82\921\E6\96\87\E5\AD\97\E3\81\9A\E3\81\A4\E3\81\AB\E5\88\86\E5\89\B2\E3\81\97\E3\81\A6\E8\A1\A8\E7\A4\BA\E3\81\97\E3\81\BE\E3\81\99\0A\00"
@.str.2 = [9 x i8] c"\E5\85\A5\E5\8A\9B: \00"
@.str.3 = [16 x i32] [i32 37, i32 50, i32 53, i32 53, i32 108, i32 91, i32 94, i32 10, i32 93, i32 37, i32 42, i32 91, i32 94, i32 10, i32 93, i32 0]
@.str.4 = [4 x i8] c"%*c\00"
@.str.5 = [9 x i8] c"\E5\87\BA\E5\8A\9B: \00"
@.str.6 = [10 x i8] c"\E3\80\8C%lc\E3\80\8D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i64]
%3 = alloca i64*
store i32 0, i32* %1
%4 = load i32, i32* @LC_ALL
%5 = call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%8 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%9 = call i32 @wscanf(i8* bitcast ([16 x i32]* @.str.3 to i8*), i64* %8)
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %0
store i32 1, i32* %1
br label %29
12: ; preds = %0
%13 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%15 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
store i64* %15, i64** %3
br label %16
16: ; preds = %24, %12
%17 = load i64*, i64** %3
%18 = load i64, i64* %17
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %16
%21 = load i64*, i64** %3
%22 = load i64, i64* %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %22)
br label %24
24: ; preds = %20
%25 = load i64*, i64** %3
%26 = getelementptr inbounds i64, i64* %25, i32 1
store i64* %26, i64** %3
br label %16
27: ; preds = %16
%28 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %1
br label %29
29: ; preds = %27, %11
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.2 = [9 x i8] c"\E5\85\A5\E5\8A\9B: \00"
@.str.3 = [16 x i32] [i32 37, i32 50, i32 53, i32 53, i32 108, i32 91, i32 94, i32 10, i32 93, i32 37, i32 42, i32 91, i32 94, i32 10, i32 93, i32 0]
@.str.4 = [4 x i8] c"%*c\00"
@.str.5 = [9 x i8] c"\E5\87\BA\E5\8A\9B: \00"
@.str.6 = [10 x i8] c"\E3\80\8C%lc\E3\80\8D\00"
@str = [74 x i8] c"\E6\97\A5\E6\9C\AC\E8\AA\9E\E3\82\92\E5\90\AB\E3\82\80\E6\96\87\E5\AD\97\E5\88\97\E3\82\921\E6\96\87\E5\AD\97\E3\81\9A\E3\81\A4\E3\81\AB\E5\88\86\E5\89\B2\E3\81\97\E3\81\A6\E8\A1\A8\E7\A4\BA\E3\81\97\E3\81\BE\E3\81\99\00"
define i32 @main() {
%1 = alloca [256 x i64]
%2 = bitcast [256 x i64]* %1 to i8*
%3 = load i32, i32* @LC_ALL
%4 = tail call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 0
%8 = call i32 @wscanf(i8* bitcast ([16 x i32]* @.str.3 to i8*), i64* %7)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %24
10: ; preds = %0
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%13 = load i64, i64* %7
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %17, %10
%16 = call i32 @putchar(i8 signext 10)
br label %24
17: ; preds = %10, %17
%18 = phi i64 [ %22, %17 ], [ %13, %10 ]
%19 = phi i64* [ %21, %17 ], [ %7, %10 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i64 %18)
%21 = getelementptr inbounds i64, i64* %19, i64 1
%22 = load i64, i64* %21
%23 = icmp eq i64 %22, 0
br i1 %23, label %15, label %17
24: ; preds = %0, %15
%25 = phi i32 [ 0, %15 ], [ 1, %0 ]
ret i32 %25
}