#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];
  int i;
  for (i = 0; *(a + i) != '\0'; i++) {
    *(b + i) = *(a + i);
  }
  *(b + i) = '\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%s", b);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xc(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0xc(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1163 <main+0x53>
movslq -0x24(%rbp),%rax
mov    -0xc(%rbp,%rax,1),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1133 <main+0x23>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x20(%rbp,%rax,1)
lea    -0xc(%rbp),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ca <main+0xba>
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1193 <main+0x83>
lea    -0x20(%rbp),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
movabs $0x622061206d612049,%rax
61 20 62
mov    %rax,(%rsp)
movl   $0x2e796f,0x8(%rsp)
mov    $0x49,%cl
xor    %eax,%eax
nop
mov    %cl,0x10(%rsp,%rax,1)
movzbl 0x1(%rsp,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1140 <main+0x20>
mov    %eax,%eax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xead(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeac(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11a3 <main+0x83>
lea    0x11(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <main+0x70>
lea    0xe7f(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbx
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 = [4 x i8] c"\0A%s\00"
define void @main() {
%1 = alloca [12 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = bitcast [12 x i8]* %1 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %23, %0
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %5
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 %18, i8* %22
br label %23
23: ; preds = %13
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %5
26: ; preds = %5
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 0, i8* %30
%31 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %34
34: ; preds = %48, %26
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %51
41: ; preds = %34
%42 = load i32, i32* %3
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %41
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %34
51: ; preds = %34
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %52)
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"
@.str.3 = [4 x i8] c"\0A%s\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 i64 [ 0, %0 ], [ %9, %5 ]
%7 = phi i8 [ 73, %0 ], [ %11, %5 ]
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %6
store i8 %7, i8* %8
%9 = add nuw nsw i64 %6, 1
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %5
13: ; preds = %5
%14 = and i64 %9, 4294967295
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %14
store i8 0, i8* %15
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %3)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8, i8* %4
%19 = icmp eq i8 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %13, %20
%21 = phi i64 [ %25, %20 ], [ 0, %13 ]
%22 = phi i8 [ %27, %20 ], [ %18, %13 ]
%23 = sext i8 %22 to i32
%24 = call i32 @putchar(i32 %23)
%25 = add nuw i64 %21, 1
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %20
29: ; preds = %20, %13
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret void
}