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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
long sum(int *, int);
long sump(int *, int *);
int main(void) {
  int marbles[10] = {20, 10, 5, 39, 4, 16, 19, 26, 31, 20};
  long answer, answer2;
  answer = sum(marbles, 10);
  answer2 = sump(marbles, marbles + 10);
  printf("Total marbles: %ld\n", answer);
  printf("Total marbles: %ld\n", answer2);
  printf("Size of marbles: %zd bytes\n", sizeof(marbles));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1040 <memcpy@plt>
lea    -0x30(%rbp),%rdi
mov    $0xa,%esi
call   1050 <sum@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
add    $0x28,%rsi
call   1060 <sump@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%esi
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    -0x40(%rbp),%rax
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
lea    0xe86(%rip),%rdi
mov    $0x28,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    0xee0(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xa,%esi
call   1040 <sum@plt>
mov    %rax,%r15
lea    0x28(%rsp),%rsi
mov    %r14,%rdi
call   1050 <sump@plt>
mov    %rax,%rbx
lea    0xea2(%rip),%r14
mov    %r14,%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe9a(%rip),%rdi
mov    $0x28,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.marbles = [10 x i32] [i32 20, i32 10, i32 5, i32 39, i32 4, i32 16, i32 19, i32 26, i32 31, i32 20]
@.str = [20 x i8] c"Total marbles: %ld\0A\00"
@.str.1 = [28 x i8] c"Size of marbles: %zd bytes\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
%5 = bitcast [10 x i32]* %2 to i8*
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%7 = call i64 @sum(i32* %6, i32 10)
store i64 %7, i64* %3
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%10 = getelementptr inbounds i32, i32* %9, i64 10
%11 = call i64 @sump(i32* %8, i32* %10)
store i64 %11, i64* %4
%12 = load i64, i64* %3
%13 = trunc i64 %12 to i32
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i64, i64* %4
%16 = trunc i64 %15 to i32
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 40)
ret i32 0
}

LLVM IR (-O2):
@__const.main.marbles = [10 x i32] [i32 20, i32 10, i32 5, i32 39, i32 4, i32 16, i32 19, i32 26, i32 31, i32 20]
@.str = [20 x i8] c"Total marbles: %ld\0A\00"
@.str.1 = [28 x i8] c"Size of marbles: %zd bytes\0A\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%4 = call i64 @sum(i32* %3, i32 10)
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 10
%6 = call i64 @sump(i32* %3, i32* %5)
%7 = trunc i64 %4 to i32
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = trunc i64 %6 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 40)
ret i32 0
}