#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 main() {
  int sum = 0;
  int multiples = 3;
  while (multiples < 1000) {
    if (multiples % 5 != 0) {
      sum += multiples;
    }
    multiples += 3;
  }
  multiples = 5;
  while (multiples < 1000) {
    sum += multiples;
    multiples += 5;
  }
  printf("result: %d", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    1165 <main+0x55>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1157 <main+0x47>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <main+0x1d>
movl   $0x5,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    1190 <main+0x80>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    116c <main+0x5c>
mov    -0x8(%rbp),%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movdqa 0xee7(%rip),%xmm1
pxor   %xmm13,%xmm13
movdqa 0xeea(%rip),%xmm2
mov    $0x148,%eax
movdqa 0xeec(%rip),%xmm8
movdqa 0xef3(%rip),%xmm9
movdqa 0xefb(%rip),%xmm5
movdqa 0xf02(%rip),%xmm10
movdqa 0xf09(%rip),%xmm11
movdqa 0xf10(%rip),%xmm12
pxor   %xmm6,%xmm6
pxor   %xmm7,%xmm7
nopl   0x0(%rax,%rax,1)
movdqa %xmm2,%xmm3
paddd  %xmm8,%xmm3
movdqa %xmm1,%xmm4
pmullw %xmm9,%xmm4
movdqa %xmm4,%xmm0
psubusw %xmm5,%xmm0
pcmpeqw %xmm13,%xmm0
punpcklwd %xmm0,%xmm0
psrad  $0x10,%xmm0
paddw  %xmm10,%xmm4
psubusw %xmm5,%xmm4
pcmpeqw %xmm13,%xmm4
punpcklwd %xmm4,%xmm4
psrad  $0x10,%xmm4
pandn  %xmm3,%xmm4
paddd  %xmm4,%xmm7
pandn  %xmm2,%xmm0
paddd  %xmm0,%xmm6
paddd  %xmm11,%xmm2
paddw  %xmm12,%xmm1
add    $0xfffffff8,%eax
jne    1170 <main+0x60>
paddd  %xmm6,%xmm7
pshufd $0xee,%xmm7,%xmm0
paddd  %xmm7,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
add    $0x19433,%esi
lea    0xe8b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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