#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 *);
int main(void) {
  int array[10] = {};
  int i, sum = 0;
  for (i = 10 - 1; i > -1; i--) {
    scanf("%d", &array[i]);
  }
  for (i = 0; i < 10; i++) {
    if (0 == array[i] % 3)
      sum += array[i];
  }
  printf("%d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x9,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jle    1190 <main+0x60>
movslq -0x34(%rbp),%rax
lea    -0x30(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe83(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x34(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    115d <main+0x2d>
movl   $0x0,-0x34(%rbp)
cmpl   $0xa,-0x34(%rbp)
jge    11dc <main+0xac>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
xor    %eax,%eax
cmp    %edx,%eax
jne    11c9 <main+0x99>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11ce <main+0x9e>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1197 <main+0x67>
mov    -0x38(%rbp),%esi
lea    0xe1a(%rip),%rdi
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
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x10(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0x24(%rsp),%rsi
lea    0xeec(%rip),%rbx
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    (%rsp),%eax
imul   $0xaaaaaaab,%eax,%ecx
add    $0x2aaaaaaa,%ecx
xor    %edx,%edx
cmp    $0x55555555,%ecx
cmovae %edx,%eax
mov    0x4(%rsp),%ecx
imul   $0xaaaaaaab,%ecx,%esi
add    $0x2aaaaaaa,%esi
cmp    $0x55555555,%esi
cmovae %edx,%ecx
movdqu 0x18(%rsp),%xmm2
movdqu 0x8(%rsp),%xmm1
movdqa 0xdee(%rip),%xmm3
movdqa %xmm1,%xmm0
pmuludq %xmm3,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm1,%xmm4
pmuludq %xmm3,%xmm4
pshufd $0xe8,%xmm4,%xmm4
punpckldq %xmm4,%xmm0
movdqa 0xdd6(%rip),%xmm8
paddd  %xmm8,%xmm0
movdqa 0xdd9(%rip),%xmm5
pxor   %xmm5,%xmm0
movdqa 0xddd(%rip),%xmm6
pcmpgtd %xmm6,%xmm0
movdqa %xmm2,%xmm7
pmuludq %xmm3,%xmm7
pshufd $0xe8,%xmm7,%xmm7
pshufd $0xf5,%xmm2,%xmm4
pmuludq %xmm3,%xmm4
pshufd $0xe8,%xmm4,%xmm3
punpckldq %xmm3,%xmm7
paddd  %xmm8,%xmm7
pxor   %xmm5,%xmm7
pcmpgtd %xmm6,%xmm7
pandn  %xmm2,%xmm7
pandn  %xmm1,%xmm0
paddd  %xmm7,%xmm0
pshufd $0xee,%xmm0,%xmm1
paddd  %xmm0,%xmm1
pshufd $0x55,%xmm1,%xmm0
paddd  %xmm1,%xmm0
movd   %xmm0,%esi
add    %ecx,%esi
add    %eax,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\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 9
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 8
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 7
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 6
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 5
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 3
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %15)
%17 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 2
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 1
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = load i32, i32* %21
%24 = srem i32 %23, 3
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 %23, i32 0
%27 = load i32, i32* %19
%28 = srem i32 %27, 3
%29 = icmp eq i32 %28, 0
%30 = select i1 %29, i32 %27, i32 0
%31 = bitcast i32* %17 to <8 x i32>*
%32 = load <8 x i32>, <8 x i32>* %31
%33 = srem <8 x i32> %32, <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>
%34 = icmp eq <8 x i32> %33, zeroinitializer
%35 = select <8 x i1> %34, <8 x i32> %32, <8 x i32> zeroinitializer
%36 = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %35)
%37 = add nsw i32 %36, %30
%38 = add nsw i32 %37, %26
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %38)
ret i32 0
}