void main() {
  char *a = "I love China!";
  int i;
  char *forp;
  char fora[] = "\n%s";
  forp = "\n%s";
  printf("%s\n", a);
  printf("The sixth character is:%c\n", a[5]);
  for (i = 0; a[i] != '\0'; i++) {
    printf("%c", a[i]);
  }
  printf(forp, a);
  printf(fora, a);
  printf("\n%d %d", a, &a[0]);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xee5(%rip),%eax
mov    %eax,-0x1c(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11a3 <main+0x93>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <main+0x56>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1c(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x73250a,0xc(%rsp)
lea    0xebc(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xebf(%rip),%rdi
mov    $0x65,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x49,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x6c,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1030 <putchar@plt>
mov    $0x76,%edi
call   1030 <putchar@plt>
mov    $0x65,%edi
call   1030 <putchar@plt>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    $0x43,%edi
call   1030 <putchar@plt>
mov    $0x68,%edi
call   1030 <putchar@plt>
mov    $0x69,%edi
call   1030 <putchar@plt>
mov    $0x6e,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x21,%edi
call   1030 <putchar@plt>
lea    0xe26(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe25(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1050 <printf@plt>

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

LLVM IR (-O2):
@.str = [14 x i8] c"I love China!\00"
@.str.1 = [4 x i8] c"\0A%s\00"
@.str.3 = [27 x i8] c"The sixth character is:%c\0A\00"
@.str.5 = [7 x i8] c"\0A%d %d\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 7546122, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 101)
%5 = tail call i32 @putchar(i32 73)
%6 = tail call i32 @putchar(i32 32)
%7 = tail call i32 @putchar(i32 108)
%8 = tail call i32 @putchar(i32 111)
%9 = tail call i32 @putchar(i32 118)
%10 = tail call i32 @putchar(i32 101)
%11 = tail call i32 @putchar(i32 32)
%12 = tail call i32 @putchar(i32 67)
%13 = tail call i32 @putchar(i32 104)
%14 = tail call i32 @putchar(i32 105)
%15 = tail call i32 @putchar(i32 110)
%16 = tail call i32 @putchar(i32 97)
%17 = tail call i32 @putchar(i32 33)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret void
}