#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, unsigned long);
int main() {
  unsigned long sum = 0;
  for (unsigned short i = 0; i < 1000; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      sum += i;
    }
  }
  printf("%lu\n", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movw   $0x0,-0x12(%rbp)
movzwl -0x12(%rbp),%eax
cmp    $0x3e8,%eax
jge    1188 <main+0x78>
movzwl -0x12(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1166 <main+0x56>
movzwl -0x12(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1172 <main+0x62>
movzwl -0x12(%rbp),%eax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1177 <main+0x67>
mov    -0x12(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x12(%rbp)
jmp    112d <main+0x1d>
mov    -0x10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movdqa 0xee6(%rip),%xmm8
pxor   %xmm1,%xmm1
movdqa 0xeea(%rip),%xmm2
mov    $0x3e8,%eax
movdqa 0xf0c(%rip),%xmm15
movdqa 0xf13(%rip),%xmm10
movdqa 0xf1a(%rip),%xmm11
movdqa 0xf22(%rip),%xmm3
movdqa 0xf29(%rip),%xmm12
movdqa 0xf30(%rip),%xmm13
movdqa 0xf37(%rip),%xmm14
pxor   %xmm7,%xmm7
pxor   %xmm6,%xmm6
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movdqa %xmm8,%xmm0
pmullw 0xea3(%rip),%xmm0
movdqa %xmm0,%xmm5
psubusw %xmm15,%xmm5
pcmpeqw %xmm1,%xmm5
movdqa %xmm8,%xmm4
pmullw %xmm11,%xmm4
movdqa %xmm4,%xmm9
psubusw %xmm3,%xmm9
pcmpeqw %xmm1,%xmm9
por    %xmm5,%xmm9
paddw  %xmm10,%xmm0
psubusw %xmm15,%xmm0
pcmpeqw %xmm1,%xmm0
punpcklwd %xmm9,%xmm5
paddw  %xmm12,%xmm4
psubusw %xmm3,%xmm4
pcmpeqw %xmm1,%xmm4
por    %xmm0,%xmm4
punpcklwd %xmm4,%xmm0
pxor   %xmm4,%xmm4
pcmpgtd %xmm5,%xmm4
psrad  $0x10,%xmm5
punpckldq %xmm4,%xmm5
pxor   %xmm4,%xmm4
pcmpgtd %xmm0,%xmm4
psrad  $0x10,%xmm0
punpckldq %xmm4,%xmm0
movdqa %xmm2,%xmm4
paddq  0xe12(%rip),%xmm4
pand   %xmm4,%xmm0
paddq  %xmm0,%xmm6
pand   %xmm2,%xmm5
paddq  %xmm5,%xmm7
paddq  %xmm13,%xmm2
paddw  %xmm14,%xmm8
add    $0xfffffffffffffffc,%rax
jne    1180 <main+0x70>
paddq  %xmm7,%xmm6
pshufd $0xee,%xmm6,%xmm0
paddq  %xmm6,%xmm0
movq   %xmm0,%rsi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d89(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%lu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i64 [ 0, %0 ], [ %23, %1 ]
%3 = phi <2 x i64> [ <i64 0, i64 1>, %0 ], [ %24, %1 ]
%4 = phi <2 x i64> [ zeroinitializer, %0 ], [ %21, %1 ]
%5 = phi <2 x i64> [ zeroinitializer, %0 ], [ %22, %1 ]
%6 = phi <2 x i16> [ <i16 0, i16 1>, %0 ], [ %25, %1 ]
%7 = add <2 x i64> %3, <i64 2, i64 2>
%8 = add <2 x i16> %6, <i16 2, i16 2>
%9 = urem <2 x i16> %6, <i16 3, i16 3>
%10 = urem <2 x i16> %8, <i16 3, i16 3>
%11 = icmp eq <2 x i16> %9, zeroinitializer
%12 = icmp eq <2 x i16> %10, zeroinitializer
%13 = urem <2 x i16> %6, <i16 5, i16 5>
%14 = urem <2 x i16> %8, <i16 5, i16 5>
%15 = icmp eq <2 x i16> %13, zeroinitializer
%16 = icmp eq <2 x i16> %14, zeroinitializer
%17 = or <2 x i1> %11, %15
%18 = or <2 x i1> %12, %16
%19 = select <2 x i1> %17, <2 x i64> %3, <2 x i64> zeroinitializer
%20 = select <2 x i1> %18, <2 x i64> %7, <2 x i64> zeroinitializer
%21 = add <2 x i64> %19, %4
%22 = add <2 x i64> %20, %5
%23 = add nuw i64 %2, 4
%24 = add <2 x i64> %3, <i64 4, i64 4>
%25 = add <2 x i16> %6, <i16 4, i16 4>
%26 = icmp eq i64 %23, 1000
br i1 %26, label %27, label %1
27: ; preds = %1
%28 = add <2 x i64> %22, %21
%29 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %28)
%30 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %29)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}