#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 *, ...);
void main() {
  char a[] = "I am a boy.", b[20], *p1, *p2;
  int i;
  p1 = a;
  p2 = b;
  for (; *p1 != '\0'; p1++, p2++) {
    *p2 = *p1;
  }
  *p2 = '\0';
  printf("string a is:%s\n", a);
  printf("string b is:");
  for (i = 0; b[i] != '\0'; i++) {
    printf("%c", b[i]);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x4(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1175 <main+0x65>
mov    -0x28(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    113c <main+0x2c>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
lea    -0xc(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11da <main+0xca>
movslq -0x34(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11a3 <main+0x93>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movabs $0x622061206d612049,%rax
61 20 62
mov    %rax,(%rsp)
movl   $0x2e796f,0x8(%rsp)
mov    $0x49,%cl
xor    %eax,%eax
mov    %cl,0x10(%rsp,%rax,1)
movzbl 0x1(%rsp,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1140 <main+0x20>
mov    0x10(%rsp),%bpl
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xeaa(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %bpl,%bpl
je     11a5 <main+0x85>
lea    0x11(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %bpl,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
jne    1190 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.main.a = [12 x i8] c"I am a boy.\00"
@.str = [16 x i8] c"string a is:%s\0A\00"
@.str.1 = [13 x i8] c"string b is:\00"
define void @main() {
%1 = alloca [12 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
br label %5
5: ; preds = %0, %5
%6 = phi i8 [ %11, %5 ], [ 73, %0 ]
%7 = phi i8* [ %10, %5 ], [ %4, %0 ]
%8 = phi i8* [ %9, %5 ], [ %3, %0 ]
store i8 %6, i8* %7
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = getelementptr inbounds i8, i8* %7, i64 1
%11 = load i8, i8* %9
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = load i8, i8* %4
store i8 0, i8* %10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i8 %14, 0
br i1 %17, label %27, label %18
18: ; preds = %13, %18
%19 = phi i64 [ %23, %18 ], [ 0, %13 ]
%20 = phi i8 [ %25, %18 ], [ %14, %13 ]
%21 = sext i8 %20 to i32
%22 = call i32 @putchar(i32 %21)
%23 = add nuw i64 %19, 1
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 0
br i1 %26, label %27, label %18
27: ; preds = %18, %13
%28 = call i32 @putchar(i32 10)
ret void
}