#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 EXIT_SUCCESS;
int *multiply_pointer_array_by(int *, int, int);
int /*<<< orphan*/ print_array(int *, int, char *);
int /*<<< orphan*/ printf(char *, ...);
int sum_nonsized_array(int *, int);
int sum_pointer_array(int *, int);
int sum_sized_array(int *);
int main(int argc, char const *argv[]) {
  printf("================================\n");
  printf("ARRAYS #2\n");
  printf("================================\n");
  int a[] = {0, 1, 2, 3, 4}, b[3] = {0, 1, 2}, c[] = {10, 20, 30};
  int *cp = c;
  int sum_a = sum_nonsized_array(a, 5), sum_b = sum_sized_array(b),
      sum_c = sum_pointer_array(cp, 3);
  int *double_a = multiply_pointer_array_by(a, 5, 2);
  printf("Sum of 'a': %i\n", sum_a);
  printf("Sum of 'b': %i\n", sum_b);
  printf("Sum of 'c': %i\n", sum_c);
  printf("Double of 'a': ");
  print_array(double_a, 5, "%i");
  printf("\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xec9(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xec4(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x3c(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x34(%rbp)
mov    0xeb6(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xeb4(%rip),%eax
mov    %eax,-0x40(%rbp)
lea    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1070 <sum_nonsized_array@plt>
mov    %eax,-0x54(%rbp)
lea    -0x3c(%rbp),%rdi
call   1030 <sum_sized_array@plt>
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%rdi
mov    $0x3,%esi
call   1060 <sum_pointer_array@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
mov    $0x2,%edx
call   1080 <multiply_pointer_array_by@plt>
mov    %rax,-0x68(%rbp)
mov    -0x54(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x5c(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x68(%rbp),%rdi
mov    $0x5,%esi
lea    0xde8(%rip),%rdx
call   1040 <print_array@plt>
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0xee8(%rip),%rbx
mov    %rbx,%rdi
call   1050 <puts@plt>
lea    0xecf(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    0xe5d(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xe42(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    0xe53(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xe40(%rip),%rax
mov    %rax,0x10(%rsp)
mov    0xe49(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xe36(%rip),%rax
mov    %rax,(%rsp)
lea    0x20(%rsp),%r14
mov    %r14,%rdi
mov    $0x5,%esi
call   1090 <sum_nonsized_array@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
call   1030 <sum_sized_array@plt>
mov    %eax,%r15d
mov    %rsp,%rdi
mov    $0x3,%esi
call   1080 <sum_pointer_array@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    $0x5,%esi
mov    $0x2,%edx
call   10a0 <multiply_pointer_array_by@plt>
mov    %rax,%r14
lea    0xdf2(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf2(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdf3(%rip),%rdx
mov    %r14,%rdi
mov    $0x5,%esi
call   1060 <print_array@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x2d49(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"================================\0A\00"
@.str.1 = [11 x i8] c"ARRAYS\0A\00"
@__const.main.a = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.b = [3 x i32] [i32 0, i32 1, i32 2]
@__const.main.c = [3 x i32] [i32 10, i32 20, i32 30]
@.str.2 = [16 x i8] c"Sum of 'a': %i\0A\00"
@.str.3 = [16 x i8] c"Sum of 'b': %i\0A\00"
@.str.4 = [16 x i8] c"Sum of 'c': %i\0A\00"
@.str.5 = [16 x i8] c"Double of 'a': \00"
@.str.6 = [3 x i8] c"%i\00"
@.str.7 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [5 x i32]
%7 = alloca [3 x i32]
%8 = alloca [3 x i32]
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%17 = bitcast [5 x i32]* %6 to i8*
%18 = bitcast [3 x i32]* %7 to i8*
%19 = bitcast [3 x i32]* %8 to i8*
%20 = getelementptr inbounds [3 x i32], [3 x i32]* %8, i64 0, i64 0
store i32* %20, i32** %9
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%22 = call i32 @sum_nonsized_array(i32* %21, i32 5)
store i32 %22, i32* %10
%23 = getelementptr inbounds [3 x i32], [3 x i32]* %7, i64 0, i64 0
%24 = call i32 @sum_sized_array(i32* %23)
store i32 %24, i32* %11
%25 = load i32*, i32** %9
%26 = call i32 @sum_pointer_array(i32* %25, i32 3)
store i32 %26, i32* %12
%27 = getelementptr inbounds [5 x i32], [5 x i32]* %6, i64 0, i64 0
%28 = call i32* @multiply_pointer_array_by(i32* %27, i32 5, i32 2)
store i32* %28, i32** %13
%29 = load i32, i32* %10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %11
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %12
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%36 = load i32*, i32** %13
%37 = call i32 @print_array(i32* %36, i32 5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%39 = load i32, i32* @EXIT_SUCCESS
ret i32 %39
}

LLVM IR (-O2):
@__const.main.a = [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4]
@__const.main.b = [3 x i32] [i32 0, i32 1, i32 2]
@__const.main.c = [3 x i32] [i32 10, i32 20, i32 30]
@.str.2 = [16 x i8] c"Sum of 'a': %i\0A\00"
@.str.3 = [16 x i8] c"Sum of 'b': %i\0A\00"
@.str.4 = [16 x i8] c"Sum of 'c': %i\0A\00"
@.str.5 = [16 x i8] c"Double of 'a': \00"
@.str.6 = [3 x i8] c"%i\00"
@EXIT_SUCCESS = global i32 0
@str.8 = [10 x i8] c"ARRAYS\00"
@str.9 = [33 x i8] c"================================\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5 x i32]
%4 = alloca [3 x i32]
%5 = alloca [3 x i32]
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.8, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.9, i64 0, i64 0))
%9 = bitcast [5 x i32]* %3 to i8*
%10 = bitcast [3 x i32]* %4 to i8*
%11 = bitcast [3 x i32]* %5 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %3, i64 0, i64 0
%14 = call i32 @sum_nonsized_array(i32* %13, i32 5)
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%16 = call i32 @sum_sized_array(i32* %15)
%17 = call i32 @sum_pointer_array(i32* %12, i32 3)
%18 = call i32* @multiply_pointer_array_by(i32* %13, i32 5, i32 2)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 @print_array(i32* %18, i32 5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 @putchar(i32 10)
%25 = load i32, i32* @EXIT_SUCCESS
ret i32 %25
}