#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 /*<<< orphan*/ strncpy(char *, char *, int);
int main(void) {
  char x[] = "Happy Birthday to You";
  char y[25];
  char z[15];
  printf("%s%s\n%s%s\n", "The string in array x is: ", x,
         "The string in array y is: ", strcpy(y, x));
  strncpy(z, x, 14);
  z[14] = '\0';
  printf("The string in array z is: %s\n", z);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeaf(%rip),%ax
mov    %ax,-0xc(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x58(%rbp),%rdx
mov    %eax,%r8d
lea    0xe8a(%rip),%rdi
lea    0xe8e(%rip),%rsi
lea    0xea2(%rip),%rcx
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x4f(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xe,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x41(%rbp)
lea    -0x4f(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x756f59206f7420,%rax
mov    %rax,0xe(%rsp)
lea    0x30(%rsp),%rdi
mov    %rsp,%r14
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xeae(%rip),%rdi
lea    0xeb2(%rip),%rsi
lea    0xec6(%rip),%rcx
mov    %r14,%rdx
mov    %eax,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x21(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xe,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x2f(%rsp)
lea    0xeb3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.x = [22 x i8] c"Happy Birthday to You\00"
@.str = [11 x i8] c"%s%s\0A%s%s\0A\00"
@.str.1 = [27 x i8] c"The string in array x is: \00"
@.str.2 = [27 x i8] c"The string in array y is: \00"
@.str.3 = [30 x i8] c"The string in array z is: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [22 x i8]
%3 = alloca [25 x i8]
%4 = alloca [15 x i8]
store i32 0, i32* %1
%5 = bitcast [22 x i8]* %2 to i8*
%6 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcpy(i8* %7, i8* %8)
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%13 = call i32 @strncpy(i8* %11, i8* %12, i32 14)
%14 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 14
store i8 0, i8* %14
%15 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.x = [22 x i8] c"Happy Birthday to You\00"
@.str = [11 x i8] c"%s%s\0A%s%s\0A\00"
@.str.1 = [27 x i8] c"The string in array x is: \00"
@.str.2 = [27 x i8] c"The string in array y is: \00"
@.str.3 = [30 x i8] c"The string in array z is: %s\0A\00"
define i32 @main() {
%1 = alloca [22 x i8]
%2 = alloca [25 x i8]
%3 = alloca [15 x i8]
%4 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%7 = call i32 @strcpy(i8* %5, i8* %4)
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = call i32 @strncpy(i8* %6, i8* %4, i32 14)
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 14
store i8 0, i8* %10
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %6)
ret i32 0
}