int main() {
  char show, samtest[] = {"This is a sample"};
  int strLength, strPtr;
  printf("\n\"%s\" is what is stored in the array samtest.\n", samtest);
  strLength = strlen(samtest);
  printf("\n");
  for (int i = 10; i < strLength; ++i) {
    printf("%c", *(samtest + i));
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xec5(%rip),%al
mov    %al,-0x10(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xa,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11b2 <main+0x92>
movslq -0x2c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1181 <main+0x61>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xec3(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    $0xb,%ebx
jl     1192 <main+0x62>
mov    %ebx,%r14d
mov    $0xa,%ebx
nopl   (%rax)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1180 <main+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.samtest = [17 x i8] c"This is a sample\00"
@.str = [47 x i8] c"\0A\22%s\22 is what is stored in the array samtest.\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [17 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [17 x i8]* %3 to i8*
%8 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%11 = call i64 @strlen(i8* %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 10, i32* %6
br label %14
14: ; preds = %26, %0
%15 = load i32, i32* %6
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %29
18: ; preds = %14
%19 = getelementptr inbounds [17 x i8], [17 x i8]* %3, i64 0, i64 0
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %14
29: ; preds = %14
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.samtest = [17 x i8] c"This is a sample\00"
@.str = [47 x i8] c"\0A\22%s\22 is what is stored in the array samtest.\0A\00"
define i32 @main() {
%1 = alloca [17 x i8]
%2 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @strlen(i8* %2)
%5 = trunc i64 %4 to i32
%6 = call i32 @putchar(i32 10)
%7 = icmp sgt i32 %5, 10
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = and i64 %4, 4294967295
br label %12
10: ; preds = %12, %0
%11 = call i32 @putchar(i32 10)
ret i32 0
12: ; preds = %8, %12
%13 = phi i64 [ 10, %8 ], [ %18, %12 ]
%14 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 @putchar(i32 %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %9
br i1 %19, label %10, label %12
}