#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 *, ...);
int main(int argc, char *argv[]) {
  int areas[] = {10, 12, 13, 14, 20};
  char name[] = "Sam";
  char full_name[] = {'S', 'a', 'm', ' ', 'P', '.', ' ',
                      'D', 'a', 'v', 'i', 'e', 's', '\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);
  char name_bad[] = {'S', 'a', 'm'};
  printf("name without nul terminator: %s\n", name_bad);
  printf("out of bounds access: %c\n", name[10]);
  printf("out of bounds access: %c\n", areas[1000]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xece(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xecc(%rip),%eax
mov    %eax,-0x34(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x42(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0x3a(%rbp)
mov    0xebe(%rip),%ax
mov    %ax,-0x36(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0x14,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
mov    $0xe,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0xe,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x34(%rbp),%rsi
lea    -0x42(%rbp),%rdx
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xdde(%rip),%ax
mov    %ax,-0x45(%rbp)
mov    0xdd6(%rip),%al
mov    %al,-0x43(%rbp)
lea    -0x45(%rbp),%rsi
lea    0xeef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsbl -0x2a(%rbp),%esi
lea    0xefe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xf70(%rbp),%esi
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movl   $0x6d6153,0xc(%rsp)
movabs $0x73656976614420,%rax
mov    %rax,0x16(%rsp)
movabs $0x44202e50206d6153,%rax
2e 20 44
mov    %rax,0x10(%rsp)
lea    0xecc(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x14,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0xa,%esi
mov    $0xc,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeff(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf0c(%rip),%rbx
mov    $0x4,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf10(%rip),%rdi
mov    $0xe,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xe,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf13(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x6d,0xa(%rsp)
movw   $0x6153,0x8(%rsp)
lea    0xf0d(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
movsbl 0x16(%rsp),%esi
lea    0xf16(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.areas = [5 x i32] [i32 10, i32 12, i32 13, i32 14, i32 20]
@__const.main.name = [4 x i8] c"Sam\00"
@__const.main.full_name = [14 x i8] c"Sam P. Davies\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"
@__const.main.name_bad = [3 x i8] c"Sam"
@.str.9 = [33 x i8] c"name without nul terminator: %s\0A\00"
@.str.10 = [26 x i8] c"out of bounds access: %c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca [4 x i8]
%8 = alloca [14 x i8]
%9 = alloca [3 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [5 x i32]* %6 to i8*
%11 = bitcast [4 x i8]* %7 to i8*
%12 = bitcast [14 x i8]* %8 to i8*
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 4)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 20)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 5)
%16 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 1
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 %17, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 1)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 4)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 4)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i64 14)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 14)
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%27 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %26, i8* %27)
%29 = bitcast [3 x i8]* %9 to i8*
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 10
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 1000
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %37)
ret i32 0
}

LLVM IR (-O2):
@__const.main.full_name = [14 x i8] c"Sam P. Davies\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"
@__const.main.name_bad = [3 x i8] c"Sam"
@.str.9 = [33 x i8] c"name without nul terminator: %s\0A\00"
@.str.10 = [26 x i8] c"out of bounds access: %c\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to [4 x i8]*
%5 = alloca [14 x i8]
%6 = alloca [3 x i8]
%7 = bitcast i32* %3 to i8*
store i32 7168339, i32* %3
%8 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 4)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i64 20)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i64 5)
%12 = 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)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i64 1)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0), i64 4)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 4)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i64 14)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i64 14)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32* %3, i8* %8)
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %6, i64 0, i64 0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 10
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i32 poison)
ret i32 0
}