#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 is_divisible_by(int, int);
int solution() {
  int list[1000], i, s;
  s = 0;
  for (i = 0; i < 1000; i++) {
    if (is_divisible_by(i, 3) == 1 || is_divisible_by(i, 5) == 1) {
      list[i] = i;
      s += i;
    }
  }
  return s;
}


x86 assembly (clang, -O0):
<solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfb0,%rsp
movl   $0x0,-0xfa8(%rbp)
movl   $0x0,-0xfa4(%rbp)
cmpl   $0x3e8,-0xfa4(%rbp)
jge    11b0 <solution+0xa0>
mov    -0xfa4(%rbp),%edi
mov    $0x3,%esi
call   1030 <is_divisible_by@plt>
cmp    $0x1,%eax
je     1171 <solution+0x61>
mov    -0xfa4(%rbp),%edi
mov    $0x5,%esi
call   1030 <is_divisible_by@plt>
cmp    $0x1,%eax
jne    1197 <solution+0x87>
mov    -0xfa4(%rbp),%ecx
movslq -0xfa4(%rbp),%rax
mov    %ecx,-0xfa0(%rbp,%rax,4)
mov    -0xfa4(%rbp),%eax
add    -0xfa8(%rbp),%eax
mov    %eax,-0xfa8(%rbp)
jmp    119c <solution+0x8c>
mov    -0xfa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xfa4(%rbp)
jmp    112f <solution+0x1f>
mov    -0xfa8(%rbp),%eax
add    $0xfb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<solution>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    112d <solution+0x1d>
nopl   0x0(%rax)
add    %ebp,%ebx
add    $0x1,%ebp
cmp    $0x3e8,%ebp
je     1151 <solution+0x41>
mov    %ebp,%edi
mov    $0x3,%esi
call   1030 <is_divisible_by@plt>
cmp    $0x1,%eax
je     1120 <solution+0x10>
mov    %ebp,%edi
mov    $0x5,%esi
call   1030 <is_divisible_by@plt>
cmp    $0x1,%eax
je     1120 <solution+0x10>
jmp    1122 <solution+0x12>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @solution() {
%1 = alloca [1000 x i32]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %3
store i32 0, i32* %2
br label %4
4: ; preds = %24, %0
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1000
br i1 %6, label %7, label %27
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i32 @is_divisible_by(i32 %8, i32 3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i32 @is_divisible_by(i32 %12, i32 5)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %23
15: ; preds = %11, %7
%16 = load i32, i32* %2
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x i32], [1000 x i32]* %1, i64 0, i64 %18
store i32 %16, i32* %19
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
br label %23
23: ; preds = %15, %11
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = add nsw i32 %25, 1
store i32 %26, i32* %2
br label %4
27: ; preds = %4
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @solution() {
br label %1
1: ; preds = %0, %11
%2 = phi i32 [ 0, %0 ], [ %12, %11 ]
%3 = phi i32 [ 0, %0 ], [ %13, %11 ]
%4 = tail call i32 @is_divisible_by(i32 %3, i32 3)
%5 = icmp eq i32 %4, 1
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = tail call i32 @is_divisible_by(i32 %3, i32 5)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %6, %1
%10 = add nsw i32 %2, %3
br label %11
11: ; preds = %6, %9
%12 = phi i32 [ %10, %9 ], [ %2, %6 ]
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 1000
br i1 %14, label %15, label %1
15: ; preds = %11
ret i32 %12
}