#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 */
typedef int /*<<< orphan*/ name;
typedef int /*<<< orphan*/ full_name;
typedef int /*<<< orphan*/ areas;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void exercise8() {
  int areas[] = {10, 12, 13, 14, 20};
  char name[] = "Zed";
  char full_name[] = {'Z', 'e', 'd', ' ', 'A', '.',
                      ' ', 'S', 'h', 'a', 'w', '\0'};
  printf("The size of an int: %ld\n", sizeof(int));
  printf("The size of areas (int[]): %ld\n", sizeof(areas));
  printf("The number of ints in areas: %ld\n", sizeof(areas) / sizeof(int));
  printf("The first area is %d, the 2nd %d.\n", areas[0], areas[1]);
  printf("The size of a char: %ld\n", sizeof(char));
  printf("The size of name (char[]): %ld\n", sizeof(name));
  printf("The number of chars: %ld\n", sizeof(name) / sizeof(char));
  printf("The size of full_name (char[]): %ld\n", sizeof(full_name));
  printf("The number of chars: %ld\n", sizeof(full_name) / sizeof(char));
  printf("name=\"%s\" and full_name=\"%s\"\n", name, full_name);
}


x86 assembly (clang, -O0):
<exercise8>:
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    0xedc(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xed7(%rip),%eax
mov    %eax,-0x24(%rbp)
mov    0xed1(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x28(%rbp)
lea    0xec9(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf14(%rip),%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
mov    $0xc,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x24(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    0xf0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exercise8>:
push   %rbx
sub    $0x20,%rsp
movl   $0x64655a,0xc(%rsp)
movabs $0x53202e412064655a,%rax
2e 20 53
mov    %rax,0x10(%rsp)
movl   $0x776168,0x18(%rsp)
lea    0xed1(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
mov    $0xa,%esi
mov    $0xc,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefe(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf11(%rip),%rbx
mov    $0x4,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf15(%rip),%rdi
mov    $0xc,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xc,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf18(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.exercise8.areas = [5 x i32] [i32 10, i32 12, i32 13, i32 14, i32 20]
@__const.exercise8.name = [4 x i8] c"Zed\00"
@__const.exercise8.full_name = [12 x i8] c"Zed A. Shaw\00"
@.str = [25 x i8] c"The size of an int: %ld\0A\00"
@.str.1 = [32 x i8] c"The size of areas (int[]): %ld\0A\00"
@.str.2 = [34 x i8] c"The number of ints in areas: %ld\0A\00"
@.str.3 = [35 x i8] c"The first area is %d, the 2nd %d.\0A\00"
@.str.4 = [25 x i8] c"The size of a char: %ld\0A\00"
@.str.5 = [32 x i8] c"The size of name (char[]): %ld\0A\00"
@.str.6 = [26 x i8] c"The number of chars: %ld\0A\00"
@.str.7 = [37 x i8] c"The size of full_name (char[]): %ld\0A\00"
@.str.8 = [30 x i8] c"name=\22%s\22 and full_name=\22%s\22\0A\00"
define void @exercise8() {
%1 = alloca [5 x i32]
%2 = alloca [4 x i8]
%3 = alloca [12 x i8]
%4 = bitcast [5 x i32]* %1 to i8*
%5 = bitcast [4 x i8]* %2 to i8*
%6 = bitcast [12 x i8]* %3 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 4)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 20)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 5)
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %11, i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 1)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 4)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 4)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i64 12)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 12)
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %20, i8* %21)
ret void
}

LLVM IR (-O2):
@__const.exercise8.full_name = [12 x i8] c"Zed A. Shaw\00"
@.str = [25 x i8] c"The size of an int: %ld\0A\00"
@.str.1 = [32 x i8] c"The size of areas (int[]): %ld\0A\00"
@.str.2 = [34 x i8] c"The number of ints in areas: %ld\0A\00"
@.str.3 = [35 x i8] c"The first area is %d, the 2nd %d.\0A\00"
@.str.4 = [25 x i8] c"The size of a char: %ld\0A\00"
@.str.5 = [32 x i8] c"The size of name (char[]): %ld\0A\00"
@.str.6 = [26 x i8] c"The number of chars: %ld\0A\00"
@.str.7 = [37 x i8] c"The size of full_name (char[]): %ld\0A\00"
@.str.8 = [30 x i8] c"name=\22%s\22 and full_name=\22%s\22\0A\00"
define void @exercise8() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = bitcast i32* %1 to i8*
store i32 6579546, i32* %1
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 20)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 5)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 12)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 1)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 4)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 4)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i64 12)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32* %1, i8* %4)
ret void
}