#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*/ array;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
int main() {
  char array[] = "Hello";
  int a_len = strlen(array);
  int x = 0;
  char *a, *e;
  printf("\t%s\n", array);
  puts("\n\n");
  printf("Array 'array' is %d bytes long and is located\n\tat the adress %p.",
         sizeof(array), a);
  puts("\n");
  for (x = 0; x <= a_len; x++) {
    e = &array[x];
    switch (x) {
    case 0:
      printf("First element of 'array' is %d byte long and is located at %p "
             "adress.\n",
             sizeof(array[x]), e);
      break;
    case 1:
      printf("The %dnd element of 'array' is %d byte long and is located at %p "
             "adress.\n",
             x + 1, sizeof(array[x]), e);
      break;
    default:
      printf("The %dth element of 'array' is %d byte long and is located at %p "
             "adress.\n",
             x + 1, sizeof(array[x + 1]), e);
      break;
    }
  }
  x = 0;
  putchar('\n');
  for (x = 0; x < a_len; x++)
    printf("Adress %p says \"%c\"\n", &array[x], array[x]);
  getchar();
  exit(975342);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x6(%rbp)
lea    -0xa(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xa(%rbp),%rsi
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
mov    -0x20(%rbp),%rdx
lea    0xe4f(%rip),%rdi
mov    $0x6,%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe3a(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1289 <main+0x129>
movslq -0x14(%rbp),%rax
lea    -0xa(%rbp,%rax,1),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     121b <main+0xbb>
jmp    120a <main+0xaa>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
je     1237 <main+0xd7>
jmp    1259 <main+0xf9>
mov    -0x28(%rbp),%rdx
lea    0xe29(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1276 <main+0x116>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rcx
lea    0xe4e(%rip),%rdi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1276 <main+0x116>
mov    -0x14(%rbp),%esi
add    $0x1,%esi
mov    -0x28(%rbp),%rcx
lea    0xe76(%rip),%rdi
mov    $0x1,%edx
mov    $0x0,%al
call   1060 <printf@plt>
jmp    127b <main+0x11b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11de <main+0x7e>
movl   $0x0,-0x14(%rbp)
mov    $0xa,%edi
call   1030 <putchar@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    12dd <main+0x17d>
movslq -0x14(%rbp),%rax
lea    -0xa(%rbp),%rsi
add    %rax,%rsi
movslq -0x14(%rbp),%rax
movsbl -0xa(%rbp,%rax,1),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a1 <main+0x141>
mov    $0x0,%al
call   1070 <getchar@plt>
mov    $0xee1ee,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x6f,0xc(%rsp)
movl   $0x6c6c6548,0x8(%rsp)
6c
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5e(%rip),%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jns    11db <main+0x7b>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    129a <main+0x13a>
mov    %rbp,0x10(%rsp)
lea    0x1(%rbp),%r14d
lea    0xeab(%rip),%r15
lea    0xe5d(%rip),%r12
lea    0xee7(%rip),%r13
xor    %ebp,%ebp
jmp    121a <main+0xba>
nopl   (%rax)
add    $0x1,%rbp
mov    $0x1,%edx
mov    %r13,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r14,%rbp
je     125e <main+0xfe>
lea    (%rsp,%rbp,1),%rcx
add    $0x8,%rcx
cmp    $0x1,%ebp
je     1250 <main+0xf0>
test   %ebp,%ebp
jne    1200 <main+0xa0>
mov    $0x1,%esi
mov    %r12,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbp
cmp    %r14,%rbp
jne    121a <main+0xba>
jmp    125e <main+0xfe>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    $0x1,%edx
mov    %r15,%rdi
jmp    120c <main+0xac>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%rax
test   %eax,%eax
jle    129a <main+0x13a>
mov    %eax,%ebp
lea    0xeb0(%rip),%r14
nopw   0x0(%rax,%rax,1)
movsbl (%rbx),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1280 <main+0x120>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    $0xee1ee,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@__const.main.array = [6 x i8] c"Hello\00"
@.str = [5 x i8] c"\09%s\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [65 x i8] c"Array 'array' is %d bytes long and is located\0A\09at the adress %p.\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [71 x i8] c"First element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.5 = [74 x i8] c"The %dnd element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.6 = [74 x i8] c"The %dth element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.7 = [21 x i8] c"Adress %p says \22%c\22\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [6 x i8]* %2 to i8*
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %3
store i32 0, i32* %4
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = load i8*, i8** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i64 6, i8* %13)
%15 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %4
br label %16
16: ; preds = %39, %0
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %42
20: ; preds = %16
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %22
store i8* %23, i8** %6
%24 = load i32, i32* %4
switch i32 %24, label %33 [
i32 0, label %25
i32 1, label %28
]
25: ; preds = %20
%26 = load i8*, i8** %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i64 1, i8* %26)
br label %38
28: ; preds = %20
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
%31 = load i8*, i8** %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i32 %30, i64 1, i8* %31)
br label %38
33: ; preds = %20
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
%36 = load i8*, i8** %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i32 %35, i64 1, i8* %36)
br label %38
38: ; preds = %33, %28, %25
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %16
42: ; preds = %16
store i32 0, i32* %4
%43 = call i32 @putchar(i8 signext 10)
store i32 0, i32* %4
br label %44
44: ; preds = %58, %42
%45 = load i32, i32* %4
%46 = load i32, i32* %3
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %61
48: ; preds = %44
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %50
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %51, i32 %56)
br label %58
58: ; preds = %48
%59 = load i32, i32* %4
%60 = add nsw i32 %59, 1
store i32 %60, i32* %4
br label %44
61: ; preds = %44
%62 = call i32 (...) @getchar()
%63 = call i32 @exit(i32 975342)
unreachable
}

LLVM IR (-O2):
@__const.main.array = [6 x i8] c"Hello\00"
@.str = [5 x i8] c"\09%s\0A\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
@.str.2 = [65 x i8] c"Array 'array' is %d bytes long and is located\0A\09at the adress %p.\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [71 x i8] c"First element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.5 = [74 x i8] c"The %dnd element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.6 = [74 x i8] c"The %dth element of 'array' is %d byte long and is located at %p adress.\0A\00"
@.str.7 = [21 x i8] c"Adress %p says \22%c\22\0A\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %2)
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i64 6, i8* undef)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp slt i32 %3, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @putchar(i8 signext 10)
br label %45
11: ; preds = %0
%12 = add nuw i32 %3, 1
%13 = zext i32 %12 to i64
br label %14
14: ; preds = %11, %29
%15 = phi i64 [ 0, %11 ], [ %30, %29 ]
%16 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %15
%17 = trunc i64 %15 to i32
switch i32 %17, label %25 [
i32 0, label %18
i32 1, label %21
]
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0), i64 1, i8* %16)
%20 = add nuw nsw i64 %15, 1
br label %29
21: ; preds = %14
%22 = add nuw nsw i64 %15, 1
%23 = trunc i64 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.5, i64 0, i64 0), i32 %23, i64 1, i8* %16)
br label %29
25: ; preds = %14
%26 = add nuw nsw i64 %15, 1
%27 = trunc i64 %26 to i32
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0), i32 %27, i64 1, i8* %16)
br label %29
29: ; preds = %18, %21, %25
%30 = phi i64 [ %20, %18 ], [ %22, %21 ], [ %26, %25 ]
%31 = icmp eq i64 %30, %13
br i1 %31, label %32, label %14
32: ; preds = %29
%33 = call i32 @putchar(i8 signext 10)
%34 = icmp sgt i32 %3, 0
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = zext i32 %3 to i64
br label %37
37: ; preds = %35, %37
%38 = phi i64 [ 0, %35 ], [ %43, %37 ]
%39 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %39, i32 %41)
%43 = add nuw nsw i64 %38, 1
%44 = icmp eq i64 %43, %36
br i1 %44, label %45, label %37
45: ; preds = %37, %9, %32
%46 = call i32 (...) @getchar()
%47 = call i32 @exit(i32 975342)
unreachable
}