int main(void) {
  char *all = "안녕하세요";
  char buf[16];
  buf[0] = all[3];
  buf[1] = all[4];
  buf[2] = all[5];
  buf[3] = '\0';
  printf("%s\n", all);
  printf("length= %d\n", strlen(all));
  printf("all[3]= %c\n", all[3]);
  printf("all[3][4][5]= %c%c%c\n", all[3], all[4], all[5]);
  printf("buf = %s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x3(%rax),%al
mov    %al,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%al
mov    %al,-0x1f(%rbp)
mov    -0x10(%rbp),%rax
mov    0x5(%rax),%al
mov    %al,-0x1e(%rbp)
movb   $0x0,-0x1d(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rsi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%esi
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%edx
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%ecx
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x9585eb,(%rsp)
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xed2(%rip),%rdi
mov    $0xf,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0xffffffeb,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0xffffffeb,%esi
mov    $0xffffff85,%edx
mov    $0xffffff95,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\EC\95\88\EB\85\95\ED\95\98\EC\84\B8\EC\9A\94\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [12 x i8] c"length= %d\0A\00"
@.str.3 = [12 x i8] c"all[3]= %c\0A\00"
@.str.4 = [22 x i8] c"all[3][4][5]= %c%c%c\0A\00"
@.str.5 = [10 x i8] c"buf = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [16 x i8]
store i32 0, i32* %1
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 3
%6 = load i8, i8* %5
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
store i8 %6, i8* %7
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 4
%10 = load i8, i8* %9
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 1
store i8 %10, i8* %11
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 5
%14 = load i8, i8* %13
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 2
store i8 %14, i8* %15
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 3
store i8 0, i8* %16
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %2
%20 = call i64 @strlen(i8* %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %20)
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i64 4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i64 5
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %30, i32 %34, i32 %38)
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"\EC\95\88\EB\85\95\ED\95\98\EC\84\B8\EC\9A\94\00"
@.str.2 = [12 x i8] c"length= %d\0A\00"
@.str.3 = [12 x i8] c"all[3]= %c\0A\00"
@.str.4 = [22 x i8] c"all[3][4][5]= %c%c%c\0A\00"
@.str.5 = [10 x i8] c"buf = %s\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
store i8 -21, i8* %2
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 1
store i8 -123, i8* %3
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 2
store i8 -107, i8* %4
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 3
store i8 0, i8* %5
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 15)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 -21)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 -21, i32 -123, i32 -107)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i8* %2)
ret i32 0
}