#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*/ flushall();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int sum_array(int *);
main() {
  int values[10];
  int local_sum = 0;
  int i;
  printf("Enter the values\n");
  for (i = 0; i < 10; i++) {
    scanf("%d", &values[i]);
    flushall();
  }
  local_sum = sum_array(values);
  printf("\nSum of array is %d", local_sum);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x38(%rbp)
cmpl   $0xa,-0x38(%rbp)
jge    11b5 <main+0x65>
movslq -0x38(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe88(%rip),%rdi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <flushall@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    117b <main+0x2b>
lea    -0x30(%rbp),%rdi
call   1030 <sum_array@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xea6(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
lea    0x24(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf@plt>
xor    %eax,%eax
call   1060 <flushall@plt>
mov    %r14,%rdi
call   1030 <sum_array@plt>
lea    0xdae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter the values\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0ASum of array is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i32]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 %11
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %12)
%14 = call i32 (...) @flushall()
br label %15
15: ; preds = %9
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %6
18: ; preds = %6
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
%20 = call i32 @sum_array(i32* %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = call i32 (...) @getchar()
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [20 x i8] c"\0ASum of array is %d\00"
@str = [17 x i8] c"Enter the values\00"
define i32 @main() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%6 = call i32 (...) @flushall()
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%9 = call i32 (...) @flushall()
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %10)
%12 = call i32 (...) @flushall()
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%15 = call i32 (...) @flushall()
%16 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = call i32 (...) @flushall()
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %19)
%21 = call i32 (...) @flushall()
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = call i32 (...) @flushall()
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %25)
%27 = call i32 (...) @flushall()
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
%30 = call i32 (...) @flushall()
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 9
%32 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %31)
%33 = call i32 (...) @flushall()
%34 = call i32 @sum_array(i32* %4)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = call i32 (...) @getchar()
ret i32 0
}