#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*/ copy1(char *, char *);
int /*<<< orphan*/ copy2(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
void fig07_21() {
  char string1[10];
  char *string2 = "Hello";
  char string3[10];
  char string4[] = "Good bye";
  copy1(string1, string2);
  printf("string1 = %s\n", string1);
  copy2(string3, string4);
  printf("string3 = %s\n", string3);
}


x86 assembly (clang, -O0):
<fig07_21>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xec1(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebc(%rip),%rax
mov    %rax,-0x2b(%rbp)
mov    0xeba(%rip),%al
mov    %al,-0x23(%rbp)
lea    -0xa(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <copy1@plt>
lea    -0xa(%rbp),%rsi
lea    0xea0(%rip),%rdi
call   1040 <printf@plt>
lea    -0x22(%rbp),%rdi
lea    -0x2b(%rbp),%rsi
call   1030 <copy2@plt>
lea    -0x22(%rbp),%rsi
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig07_21>:
push   %rbx
sub    $0x20,%rsp
movabs $0x65796220646f6f47,%rax
62 79 65
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
lea    0xeb1(%rip),%rsi
lea    0x16(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <copy1@plt>
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <copy2@plt>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Hello\00"
@__const.fig07_21.string4 = [9 x i8] c"Good bye\00"
@.str.1 = [14 x i8] c"string1 = %s\0A\00"
@.str.2 = [14 x i8] c"string3 = %s\0A\00"
define void @fig07_21() {
%1 = alloca [10 x i8]
%2 = alloca i8*
%3 = alloca [10 x i8]
%4 = alloca [9 x i8]
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%5 = bitcast [9 x i8]* %4 to i8*
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @copy1(i8* %6, i8* %7)
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%13 = call i32 @copy2(i8* %11, i8* %12)
%14 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %14)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"Hello\00"
@__const.fig07_21.string4 = [9 x i8] c"Good bye\00"
@.str.1 = [14 x i8] c"string1 = %s\0A\00"
@.str.2 = [14 x i8] c"string3 = %s\0A\00"
define void @fig07_21() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = alloca [9 x i8]
%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 [9 x i8], [9 x i8]* %3, i64 0, i64 0
%7 = call i32 @copy1(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @copy2(i8* %5, i8* %6)
%10 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret void
}