#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, ...);
void sample1() {
  char a[26] = "abcdefghijklmnopqretuvwxyz";
  for (int i = 0; i < 4; ++i) {
    printf("a[%d]=%c\n", i, a[i]);
  }
  int *ptr = (int *)a;
  printf("*ptr = %c\n", *ptr);
  ptr++;
  printf("*ptr = %c\n", *ptr);
}


x86 assembly (clang, -O0):
<sample1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xed8(%rip),%ax
mov    %ax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    117d <sample1+0x6d>
mov    -0x24(%rbp),%esi
movslq -0x24(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%edx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114b <sample1+0x3b>
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample1>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x61,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x62,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x63,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x64,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rbx
mov    %rbx,%rdi
mov    $0x64636261,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x68676665,%esi
xor    %eax,%eax
pop    %rbx
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [10 x i8] c"a[%d]=%c\0A\00"
@.str.1 = [11 x i8] c"*ptr = %c\0A\00"
define void @sample1() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 0, i32 97)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 1, i32 98)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 2, i32 99)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 3, i32 100)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 1684234849)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 1751606885)
ret void
}