#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 *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main() {
  char str[10] = {'\0'};
  char str1[10] = {'\0'};
  int i = 0;
  for (i = 0; i < 9; i++) {
    str1[i] = 'a';
  }
  strcpy(str, str1);
  printf("str is :%s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xe(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <memset@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jge    118e <main+0x5e>
movslq -0x1c(%rbp),%rax
movb   $0x61,-0x18(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116d <main+0x3d>
lea    -0xe(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0xe(%rbp),%rsi
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movabs $0x6161616161616161,%rax
61 61 61
mov    %rax,(%rsp)
movw   $0x61,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"str is :%s\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
store i8 0, i8* %6
%7 = call i32 @strcpy(i8* %4, i8* %5)
%8 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}