#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, unsigned int, unsigned int,
                          unsigned int);
int main() {
  unsigned int alignedInts[4] = {0x01020304, 0x05060708, 0x090A0B0C,
                                 0x0D0E0F10};
  int offset;
  for (offset = 0; offset < 4; offset++) {
    unsigned char *misalignedPtr = ((unsigned char *)alignedInts) + offset;
    unsigned int *misalignedInts = (unsigned int *)misalignedPtr;
    printf("Offset %d: %8.8X %8.8X %8.8X\n", offset, misalignedInts[0],
           misalignedInts[1], misalignedInts[2]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed7(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    118f <main+0x7f>
lea    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x38(%rbp),%rax
mov    (%rax),%edx
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%r8d
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    113c <main+0x2c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1020304,%edx
mov    $0x5060708,%ecx
mov    $0x90a0b0c,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x8010203,%edx
mov    $0xc050607,%ecx
mov    $0x10090a0b,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x7080102,%edx
mov    $0xb0c0506,%ecx
mov    $0xf10090a,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x6070801,%edx
mov    $0xa0b0c05,%ecx
mov    $0xe0f1009,%r8d
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"Offset %d: %8.8X %8.8X %8.8X\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 0, i32 16909060, i32 84281096, i32 151653132)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 1, i32 134283779, i32 201655815, i32 269027851)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 2, i32 117965058, i32 185337094, i32 252709130)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 3, i32 101124097, i32 168496133, i32 235868169)
ret i32 0
}