#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 /*<<< orphan*/ printf(char *, short);
int /*<<< orphan*/ sum(short *, short *, int);
int main() {
  short Array[100];
  short Sum = 0;
  int i;
  for (i = 0; i != 100; ++i)
    Array[i] = i;
  sum(&Sum, Array, 100);
  printf("Sum is %d\n", Sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x0,-0xd2(%rbp)
movl   $0x0,-0xd8(%rbp)
cmpl   $0x64,-0xd8(%rbp)
je     117e <main+0x5e>
mov    -0xd8(%rbp),%eax
mov    %ax,%cx
movslq -0xd8(%rbp),%rax
mov    %cx,-0xd0(%rbp,%rax,2)
ff
mov    -0xd8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xd8(%rbp)
jmp    1145 <main+0x25>
lea    -0xd0(%rbp),%rsi
lea    -0xd2(%rbp),%rdi
mov    $0x64,%edx
call   1040 <sum@plt>
lea    0xe63(%rip),%rdi
movswl -0xd2(%rbp),%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xd8,%rsp
movw   $0x0,0xe(%rsp)
movaps 0xecb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xed3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed7(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xedb(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xedf(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xee3(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movaps 0xee7(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xee8(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xee9(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xeea(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movabs $0x63006200610060,%rax
mov    %rax,0xd0(%rsp)
lea    0xe(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x64,%edx
call   1040 <sum@plt>
movswl 0xe(%rsp),%esi
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Sum is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i16]
%3 = alloca i16
%4 = alloca i32
store i32 0, i32* %1
store i16 0, i16* %3
store i32 0, i32* %4
br label %5
5: ; preds = %14, %0
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 100
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %4
%10 = trunc i32 %9 to i16
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [100 x i16], [100 x i16]* %2, i64 0, i64 %12
store i16 %10, i16* %13
br label %14
14: ; preds = %8
%15 = load i32, i32* %4
%16 = add nsw i32 %15, 1
store i32 %16, i32* %4
br label %5
17: ; preds = %5
%18 = getelementptr inbounds [100 x i16], [100 x i16]* %2, i64 0, i64 0
%19 = call i32 @sum(i16* %3, i16* %18, i32 100)
%20 = load i16, i16* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i16 signext %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Sum is %d\0A\00"
define i32 @main() {
%1 = alloca [100 x i16]
%2 = alloca i16
%3 = bitcast [100 x i16]* %1 to i8*
%4 = bitcast i16* %2 to i8*
store i16 0, i16* %2
%5 = bitcast [100 x i16]* %1 to <8 x i16>*
store <8 x i16> <i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7>, <8 x i16>* %5
%6 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 8
%7 = bitcast i16* %6 to <8 x i16>*
store <8 x i16> <i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15>, <8 x i16>* %7
%8 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 16
%9 = bitcast i16* %8 to <8 x i16>*
store <8 x i16> <i16 16, i16 17, i16 18, i16 19, i16 20, i16 21, i16 22, i16 23>, <8 x i16>* %9
%10 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 24
%11 = bitcast i16* %10 to <8 x i16>*
store <8 x i16> <i16 24, i16 25, i16 26, i16 27, i16 28, i16 29, i16 30, i16 31>, <8 x i16>* %11
%12 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 32
%13 = bitcast i16* %12 to <8 x i16>*
store <8 x i16> <i16 32, i16 33, i16 34, i16 35, i16 36, i16 37, i16 38, i16 39>, <8 x i16>* %13
%14 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 40
%15 = bitcast i16* %14 to <8 x i16>*
store <8 x i16> <i16 40, i16 41, i16 42, i16 43, i16 44, i16 45, i16 46, i16 47>, <8 x i16>* %15
%16 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 48
%17 = bitcast i16* %16 to <8 x i16>*
store <8 x i16> <i16 48, i16 49, i16 50, i16 51, i16 52, i16 53, i16 54, i16 55>, <8 x i16>* %17
%18 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 56
%19 = bitcast i16* %18 to <8 x i16>*
store <8 x i16> <i16 56, i16 57, i16 58, i16 59, i16 60, i16 61, i16 62, i16 63>, <8 x i16>* %19
%20 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 64
%21 = bitcast i16* %20 to <8 x i16>*
store <8 x i16> <i16 64, i16 65, i16 66, i16 67, i16 68, i16 69, i16 70, i16 71>, <8 x i16>* %21
%22 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 72
%23 = bitcast i16* %22 to <8 x i16>*
store <8 x i16> <i16 72, i16 73, i16 74, i16 75, i16 76, i16 77, i16 78, i16 79>, <8 x i16>* %23
%24 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 80
%25 = bitcast i16* %24 to <8 x i16>*
store <8 x i16> <i16 80, i16 81, i16 82, i16 83, i16 84, i16 85, i16 86, i16 87>, <8 x i16>* %25
%26 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 88
%27 = bitcast i16* %26 to <8 x i16>*
store <8 x i16> <i16 88, i16 89, i16 90, i16 91, i16 92, i16 93, i16 94, i16 95>, <8 x i16>* %27
%28 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 96
store i16 96, i16* %28
%29 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 97
store i16 97, i16* %29
%30 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 98
store i16 98, i16* %30
%31 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 99
store i16 99, i16* %31
%32 = getelementptr inbounds [100 x i16], [100 x i16]* %1, i64 0, i64 0
%33 = call i32 @sum(i16* %2, i16* %32, i32 100)
%34 = load i16, i16* %2
%35 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i16 signext %34)
ret i32 0
}