#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 *);
main() {
  char str2[100], str3[100], *pt1, *pt2;
  int i = 0;
  pt1 = str2;
  pt2 = str3;
  printf("文字列str2を入力 ===> ");
  scanf("%s", pt1);
  printf("***** コピー前 *****\n");
  printf("str2=%s\n", pt1);
  printf("str3=%s\n", pt2);
  while (*(pt1 + i) != '\0') {
    *(pt2 + i) = *(pt1 + i);
    i++;
  }
  printf("***** コピー後 *****\n");
  printf("str2=%s\n", pt1);
  printf("str3=%s\n", pt2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xf4(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1040 <scanf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%rsi
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xf0(%rbp),%rsi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%rax
movslq -0xf4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ff <main+0xdf>
mov    -0xe8(%rbp),%rax
movslq -0xf4(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0xf0(%rbp),%rax
movslq -0xf4(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    11ae <main+0x8e>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xe8(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xf0(%rbp),%rsi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xe0,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xed3(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb5(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%al
test   %al,%al
je     11b1 <main+0x81>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %al,0x70(%rsp,%rcx,1)
movzbl 0x1(%rsp,%rcx,1),%eax
add    $0x1,%rcx
test   %al,%al
jne    11a0 <main+0x70>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe54(%rip),%rdi
lea    0x70(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\E6\96\87\E5\AD\97\E5\88\97str2\E3\82\92\E5\85\A5\E5\8A\9B ===> \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [26 x i8] c"***** \E3\82\B3\E3\83\94\E3\83\BC\E5\89\8D *****\0A\00"
@.str.3 = [9 x i8] c"str2=%s\0A\00"
@.str.4 = [9 x i8] c"str3=%s\0A\00"
@.str.5 = [26 x i8] c"***** \E3\82\B3\E3\83\94\E3\83\BC\E5\BE\8C *****\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
store i8* %7, i8** %4
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
store i8* %8, i8** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %4
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %25, %0
%18 = load i8*, i8** %4
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %17
%26 = load i8*, i8** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = load i8*, i8** %5
%32 = load i32, i32* %6
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
store i8 %30, i8* %34
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %17
37: ; preds = %17
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%39 = load i8*, i8** %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %5
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = load i32, i32* %1
ret i32 %43
}

LLVM IR (-O2):
@.str = [29 x i8] c"\E6\96\87\E5\AD\97\E5\88\97str2\E3\82\92\E5\85\A5\E5\8A\9B ===> \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.3 = [9 x i8] c"str2=%s\0A\00"
@.str.4 = [9 x i8] c"str3=%s\0A\00"
@str = [25 x i8] c"***** \E3\82\B3\E3\83\94\E3\83\BC\E5\89\8D *****\00"
@str.6 = [25 x i8] c"***** \E3\82\B3\E3\83\94\E3\83\BC\E5\BE\8C *****\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%10 = load i8, i8* %3
%11 = icmp eq i8 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %0, %12
%13 = phi i64 [ %16, %12 ], [ 0, %0 ]
%14 = phi i8 [ %18, %12 ], [ %10, %0 ]
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %13
store i8 %14, i8* %15
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %12, %0
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.6, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret i32 0
}