#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 *);
int main() {
  char dst[20], src[10] = {0};
  int i = 0;
  int j;
  printf("Enter src: ");
  scanf("%s", src);
  printf("src : %s\n", src);
  printf("Enter dst: ");
  scanf("%s", dst);
  printf("dst : %s\n", dst);
  while ((dst[i]) != '\0') {
    i++;
  }
  printf("i %d\n", i);
  j = 0;
  while ((dst[i] = src[j]) != '\0') {
    i++;
    j++;
  }
  printf("i %d j %d\n", i, j);
  printf("dst : %s\n", dst);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2a(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x30(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x2a(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x2a(%rbp),%rsi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x30(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d6 <main+0xa6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b6 <main+0x86>
mov    -0x30(%rbp),%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
mov    -0x2a(%rbp,%rax,1),%al
movslq -0x30(%rbp),%rcx
mov    %al,-0x20(%rbp,%rcx,1)
movsbl %al,%eax
cmp    $0x0,%eax
je     1221 <main+0xf1>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11ee <main+0xbe>
mov    -0x30(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movw   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec1(%rip),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffffffffffff,%rbx
cmpb   $0x0,0x11(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    11a0 <main+0x80>
lea    0xe7d(%rip),%rdi
xor    %r14d,%r14d
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rsp),%al
mov    %ebx,%ecx
mov    %al,0x10(%rsp,%rcx,1)
test   %al,%al
je     11f5 <main+0xd5>
mov    %ebx,%eax
add    %rsp,%rax
add    $0x11,%rax
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
movzbl 0x1(%rsp,%r14,1),%ecx
mov    %cl,(%rax,%r14,1)
add    $0x1,%r14
add    $0x1,%ebx
test   %cl,%cl
jne    11e0 <main+0xc0>
lea    0xe39(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe16(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Enter src: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [10 x i8] c"src : %s\0A\00"
@.str.3 = [12 x i8] c"Enter dst: \00"
@.str.4 = [10 x i8] c"dst : %s\0A\00"
@.str.5 = [6 x i8] c"i %d\0A\00"
@.str.6 = [11 x i8] c"i %d j %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [10 x i8]* %3 to i8*
store i32 0, i32* %4
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br label %17
17: ; preds = %24, %0
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %17
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %17
27: ; preds = %17
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %28)
store i32 0, i32* %5
br label %30
30: ; preds = %40, %27
%31 = load i32, i32* %5
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %36
store i8 %34, i8* %37
%38 = sext i8 %34 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %30
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %30
45: ; preds = %30
%46 = load i32, i32* %4
%47 = load i32, i32* %5
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %46, i32 %47)
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %49)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Enter src: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [10 x i8] c"src : %s\0A\00"
@.str.3 = [12 x i8] c"Enter dst: \00"
@.str.4 = [10 x i8] c"dst : %s\0A\00"
@.str.5 = [6 x i8] c"i %d\0A\00"
@.str.6 = [11 x i8] c"i %d j %d\0A\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 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* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %11
11: ; preds = %11, %0
%12 = phi i64 [ %16, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = add nuw i64 %12, 1
br i1 %15, label %17, label %11
17: ; preds = %11
%18 = trunc i64 %12 to i32
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %18)
%20 = load i8, i8* %4
%21 = and i64 %12, 4294967295
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %21
store i8 %20, i8* %22
%23 = icmp eq i8 %20, 0
br i1 %23, label %36, label %24
24: ; preds = %17, %24
%25 = phi i64 [ %27, %24 ], [ %21, %17 ]
%26 = phi i64 [ %28, %24 ], [ 0, %17 ]
%27 = add nuw i64 %25, 1
%28 = add nuw nsw i64 %26, 1
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %27
store i8 %30, i8* %31
%32 = icmp eq i8 %30, 0
br i1 %32, label %33, label %24
33: ; preds = %24
%34 = trunc i64 %27 to i32
%35 = trunc i64 %28 to i32
br label %36
36: ; preds = %33, %17
%37 = phi i32 [ %18, %17 ], [ %34, %33 ]
%38 = phi i32 [ 0, %17 ], [ %35, %33 ]
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %37, i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %3)
ret i32 0
}