#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ str_copy(char *, char *);
int main(void) {
  char str[128] = "ABC";
  char tmp[128];
  printf("str = %s\n", str);
  printf("Will be copy: ", tmp);
  scanf("%s", tmp);
  str_copy(str, tmp);
  puts("Copy.");
  printf("str = %s\n", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
movb   $0x41,-0x90(%rbp)
movb   $0x42,-0x8f(%rbp)
movb   $0x43,-0x8e(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe5f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x90(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1070 <str_copy@plt>
lea    0xe3f(%rip),%rdi
call   1030 <puts@plt>
lea    -0x90(%rbp),%rsi
lea    0xe10(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movw   $0x4241,(%rsp)
movb   $0x43,0x2(%rsp)
lea    0xe78(%rip),%r14
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    0x80(%rsp),%rbx
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe65(%rip),%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <str_copy@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"str = %s\0A\00"
@.str.1 = [15 x i8] c"Will be copy: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"Copy.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
store i32 0, i32* %1
%4 = bitcast [128 x i8]* %2 to i8*
%5 = bitcast i8* %4 to [128 x i8]*
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 0
store i8 65, i8* %6
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 1
store i8 66, i8* %7
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i32 0, i32 2
store i8 67, i8* %8
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%12 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%17 = call i32 @str_copy(i8* %15, i8* %16)
%18 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"str = %s\0A\00"
@.str.1 = [15 x i8] c"Will be copy: \00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [6 x i8] c"Copy.\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
store i8 65, i8* %3
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
store i8 66, i8* %4
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 2
store i8 67, i8* %5
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%7 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3)
%8 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%10 = call i32 @str_copy(i8* %3, i8* %6)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 0
}