#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 *, int);
int /*<<< orphan*/ scanf(char *, int *);
main() {
  int a[5], *p, *q, i, s = 0;
  for (i = 0; i < 5; i++)
    scanf("%d", &a[i]);
  p = &a[0];
  for (i = 0; i < 5; i++) {
    s = s + *p;
    p++;
  }
  printf("\nsum%d", (s));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    1170 <main+0x50>
movslq -0x34(%rbp),%rax
lea    -0x20(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xea7(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    113d <main+0x1d>
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x5,-0x34(%rbp)
jge    11af <main+0x8f>
mov    -0x38(%rbp),%eax
mov    -0x28(%rbp),%rcx
add    (%rcx),%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    117f <main+0x5f>
mov    -0x38(%rbp),%esi
lea    0xe47(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed8(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movdqu 0x4(%rsp),%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%esi
add    (%rsp),%esi
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"\0Asum%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %15, %0
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 5
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %12
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
store i32 %17, i32* %5
br label %7
18: ; preds = %7
%19 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 0
store i32* %19, i32** %3
store i32 0, i32* %5
br label %20
20: ; preds = %30, %18
%21 = load i32, i32* %5
%22 = icmp slt i32 %21, 5
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %6
%25 = load i32*, i32** %3
%26 = load i32, i32* %25
%27 = add nsw i32 %24, %26
store i32 %27, i32* %6
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i32 1
store i32* %29, i32** %3
br label %30
30: ; preds = %23
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %20
33: ; preds = %20
%34 = load i32, i32* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"\0Asum%d\00"
define i32 @main() {
%1 = alloca [5 x i32]
%2 = bitcast [5 x i32]* %1 to i8*
%3 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 2
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 3
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 4
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i32, i32* %3
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %1, i64 0, i64 1
%15 = bitcast i32* %14 to <4 x i32>*
%16 = load <4 x i32>, <4 x i32>* %15
%17 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %16)
%18 = add nsw i32 %17, %13
%19 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret i32 0
}