#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 */
typedef int uint64_t;

/* Variables and functions */
__attribute__((always_)) uint64_t f() {
  uint64_t ans = 0;
  uint64_t i;
  for (i = 0; i < 1000; i++)
    if (i % 3 == 0 || i % 5 == 0)
      ans += i;
  return ans;
}


x86 assembly (clang, -O0):
<f>:
push   %rbp
mov    %rsp,%rbp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    1163 <f+0x63>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1147 <f+0x47>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1150 <f+0x50>
mov    -0x8(%rbp),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1155 <f+0x55>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1112 <f+0x12>
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<f>:
movdqa 0xef7(%rip),%xmm8
pxor   %xmm1,%xmm1
movdqa 0xefb(%rip),%xmm2
mov    $0x3e8,%eax
movdqa 0xf1d(%rip),%xmm15
movdqa 0xf24(%rip),%xmm10
movdqa 0xf2b(%rip),%xmm11
movdqa 0xf33(%rip),%xmm3
movdqa 0xf3a(%rip),%xmm12
movdqa 0xf41(%rip),%xmm13
movdqa 0xf48(%rip),%xmm14
pxor   %xmm7,%xmm7
pxor   %xmm6,%xmm6
movdqa %xmm8,%xmm0
pmullw 0xec3(%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
paddw  %xmm12,%xmm4
psubusw %xmm3,%xmm4
pcmpeqw %xmm1,%xmm4
por    %xmm0,%xmm4
movdqa %xmm2,%xmm0
paddd  0xe5d(%rip),%xmm0
punpcklwd %xmm4,%xmm4
psrad  $0x10,%xmm4
pand   %xmm0,%xmm4
paddd  %xmm4,%xmm6
punpcklwd %xmm9,%xmm0
psrad  $0x10,%xmm0
pand   %xmm2,%xmm0
paddd  %xmm0,%xmm7
paddd  %xmm13,%xmm2
paddw  %xmm14,%xmm8
add    $0xfffffff8,%eax
jne    1160 <f+0x60>
paddd  %xmm7,%xmm6
pshufd $0xee,%xmm6,%xmm0
paddd  %xmm6,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
ret

LLVM IR (-O0):
define i32 @f() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %19, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 1000
br i1 %5, label %6, label %22
6: ; preds = %3
%7 = load i32, i32* %2
%8 = srem i32 %7, 3
%9 = icmp eq i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i32, i32* %2
%12 = srem i32 %11, 5
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10, %6
%15 = load i32, i32* %2
%16 = load i32, i32* %1
%17 = add nsw i32 %16, %15
store i32 %17, i32* %1
br label %18
18: ; preds = %14, %10
br label %19
19: ; preds = %18
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %3
22: ; preds = %3
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @f() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %23, %1 ]
%3 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %24, %1 ]
%4 = phi <4 x i32> [ zeroinitializer, %0 ], [ %21, %1 ]
%5 = phi <4 x i32> [ zeroinitializer, %0 ], [ %22, %1 ]
%6 = phi <4 x i16> [ <i16 0, i16 1, i16 2, i16 3>, %0 ], [ %25, %1 ]
%7 = add <4 x i32> %3, <i32 4, i32 4, i32 4, i32 4>
%8 = add <4 x i16> %6, <i16 4, i16 4, i16 4, i16 4>
%9 = urem <4 x i16> %6, <i16 3, i16 3, i16 3, i16 3>
%10 = urem <4 x i16> %8, <i16 3, i16 3, i16 3, i16 3>
%11 = icmp eq <4 x i16> %9, zeroinitializer
%12 = icmp eq <4 x i16> %10, zeroinitializer
%13 = urem <4 x i16> %6, <i16 5, i16 5, i16 5, i16 5>
%14 = urem <4 x i16> %8, <i16 5, i16 5, i16 5, i16 5>
%15 = icmp eq <4 x i16> %13, zeroinitializer
%16 = icmp eq <4 x i16> %14, zeroinitializer
%17 = or <4 x i1> %11, %15
%18 = or <4 x i1> %12, %16
%19 = select <4 x i1> %17, <4 x i32> %3, <4 x i32> zeroinitializer
%20 = select <4 x i1> %18, <4 x i32> %7, <4 x i32> zeroinitializer
%21 = add <4 x i32> %19, %4
%22 = add <4 x i32> %20, %5
%23 = add nuw i32 %2, 8
%24 = add <4 x i32> %3, <i32 8, i32 8, i32 8, i32 8>
%25 = add <4 x i16> %6, <i16 8, i16 8, i16 8, i16 8>
%26 = icmp eq i32 %23, 1000
br i1 %26, label %27, label %1
27: ; preds = %1
%28 = add <4 x i32> %22, %21
%29 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %28)
ret i32 %29
}