#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*/ strArray;
typedef int /*<<< orphan*/ intArray;
typedef int /*<<< orphan*/ fltArray;
typedef int /*<<< orphan*/ charArray;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int intArray[] = {1, 2, 3, 4, 5};
  float fltArray[5] = {0.0};
  fltArray[0] = 4.8;
  fltArray[1] = 5.1;
  fltArray[2] = 9.2;
  fltArray[3] = 2.2;
  fltArray[4] = 1.6;
  char charArray[5] = {'h', 'e', 'l', 'l', 'o'};
  char strArray[5] = {'h', 'o', 'l', 'a', '\0'};
  printf("Welcome to the Size-of-Array program!");
  printf("\nHere, we will demonstrate the sizes of various arrays.");
  printf("\nThe size of %s, with %d elements, is: %d", "intArray", 5,
         sizeof(intArray));
  printf("\nThe size of %s, with %d elements, is: %d", "fltArray", 5,
         sizeof(fltArray));
  printf("\nThe size of %s, with %d elements, is: %d", "charArray", 5,
         sizeof(charArray));
  printf("\nThe size of %s, with %d elements, is: %d", "strArray", 5,
         sizeof(strArray));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeea(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xee7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xee5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <memset@plt>
movss  0xeaa(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  0xe99(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe88(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
movss  0xe77(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xe66(%rip),%xmm0
movss  %xmm0,-0x30(%rbp)
mov    0xe8f(%rip),%eax
mov    %eax,-0x45(%rbp)
mov    0xe8a(%rip),%al
mov    %al,-0x41(%rbp)
mov    0xe82(%rip),%eax
mov    %eax,-0x4a(%rbp)
mov    0xe7d(%rip),%al
mov    %al,-0x46(%rbp)
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb6(%rip),%rdi
lea    0xed9(%rip),%rsi
mov    $0x5,%edx
mov    $0x14,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe97(%rip),%rdi
lea    0xec3(%rip),%rsi
mov    $0x5,%edx
mov    $0x14,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe78(%rip),%rdi
lea    0xead(%rip),%rsi
mov    $0x5,%edx
mov    $0x5,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe59(%rip),%rdi
lea    0xe98(%rip),%rsi
mov    $0x5,%edx
mov    $0x5,%ecx
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf00(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf2a(%rip),%rbx
lea    0xf4d(%rip),%rsi
mov    $0x14,%ecx
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf3b(%rip),%rsi
mov    $0x14,%ecx
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf29(%rip),%rsi
mov    $0x5,%ecx
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf18(%rip),%rsi
mov    $0x5,%ecx
mov    %rbx,%rdi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.intArray = [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]
@__const.main.charArray = [5 x i8] c"hello"
@__const.main.strArray = [5 x i8] c"hola\00"
@.str = [38 x i8] c"Welcome to the Size-of-Array program!\00"
@.str.1 = [56 x i8] c"\0AHere, we will demonstrate the sizes of various arrays.\00"
@.str.2 = [42 x i8] c"\0AThe size of %s, with %d elements, is: %d\00"
@.str.3 = [9 x i8] c"intArray\00"
@.str.4 = [9 x i8] c"fltArray\00"
@.str.5 = [10 x i8] c"charArray\00"
@.str.6 = [9 x i8] c"strArray\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca [5 x float]
%4 = alloca [5 x i8]
%5 = alloca [5 x i8]
store i32 0, i32* %1
%6 = bitcast [5 x i32]* %2 to i8*
%7 = bitcast [5 x float]* %3 to i8*
%8 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 0
store float 0x4013333340000000, float* %8
%9 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 1
store float 0x4014666660000000, float* %9
%10 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 2
store float 0x4022666660000000, float* %10
%11 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 3
store float 0x40019999A0000000, float* %11
%12 = getelementptr inbounds [5 x float], [5 x float]* %3, i64 0, i64 4
store float 0x3FF99999A0000000, float* %12
%13 = bitcast [5 x i8]* %4 to i8*
%14 = bitcast [5 x i8]* %5 to i8*
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 5, i64 20)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 5, i64 20)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 5, i64 5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 5, i64 5)
ret i32 0
}

LLVM IR (-O2):
@.str = [38 x i8] c"Welcome to the Size-of-Array program!\00"
@.str.1 = [56 x i8] c"\0AHere, we will demonstrate the sizes of various arrays.\00"
@.str.2 = [42 x i8] c"\0AThe size of %s, with %d elements, is: %d\00"
@.str.3 = [9 x i8] c"intArray\00"
@.str.4 = [9 x i8] c"fltArray\00"
@.str.5 = [10 x i8] c"charArray\00"
@.str.6 = [9 x i8] c"strArray\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 5, i64 20)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 5, i64 20)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 5, i64 5)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 5, i64 5)
ret i32 0
}