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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char string_1[21];
  char string_2[21];
  printf("You want to say:");
  scanf("%20s", string_1);
  int index = 0;
  while ((string_2[index] = string_1[index]) != '\0') {
    index += 1;
  }
  printf("string_2 = %s\n", string_2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x44(%rbp)
movslq -0x44(%rbp),%rax
mov    -0x20(%rbp,%rax,1),%al
movslq -0x44(%rbp),%rcx
mov    %al,-0x40(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0x0,%eax
je     117e <main+0x5e>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1154 <main+0x34>
lea    -0x40(%rbp),%rsi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    0x20(%rsp),%rsi
call   1040 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
movzbl 0x20(%rsp,%rbx,1),%eax
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
test   %al,%al
jne    1150 <main+0x30>
lea    0xeaf(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"You want to say:\00"
@.str.1 = [5 x i8] c"%20s\00"
@.str.2 = [15 x i8] c"string_2 = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca [21 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %6)
store i32 0, i32* %4
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %4
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %10
%12 = load i8, i8* %11
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %14
store i8 %12, i8* %15
%16 = sext i8 %12 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %8
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"You want to say:\00"
@.str.1 = [5 x i8] c"%20s\00"
@.str.2 = [15 x i8] c"string_2 = %s\0A\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = alloca [21 x i8]
%3 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %7
7: ; preds = %7, %0
%8 = phi i64 [ %13, %7 ], [ 0, %0 ]
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %8
store i8 %10, i8* %11
%12 = icmp eq i8 %10, 0
%13 = add nuw i64 %8, 1
br i1 %12, label %14, label %7
14: ; preds = %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}