#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);
int main() {
  int sum = 0, i;
  int max_value = 1000;
  for (i = 1; i < max_value; i++) {
    if ((i % 3 == 0) || (i % 5 == 0))
      sum += i;
  }
  printf("Sum of all multiples of 3 or 5 below %d is %d\n", max_value, sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x3e8,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1184 <main+0x74>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1168 <main+0x58>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1171 <main+0x61>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1176 <main+0x66>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <main+0x24>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movdqa 0xee6(%rip),%xmm8
movdqa 0xeee(%rip),%xmm1
pxor   %xmm2,%xmm2
mov    $0x3e0,%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   %xmm6,%xmm6
pxor   %xmm4,%xmm4
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 %xmm2,%xmm5
movdqa %xmm8,%xmm7
pmullw %xmm11,%xmm7
movdqa %xmm7,%xmm9
psubusw %xmm3,%xmm9
pcmpeqw %xmm2,%xmm9
por    %xmm5,%xmm9
paddw  %xmm10,%xmm0
psubusw %xmm15,%xmm0
pcmpeqw %xmm2,%xmm0
paddw  %xmm12,%xmm7
psubusw %xmm3,%xmm7
pcmpeqw %xmm2,%xmm7
por    %xmm0,%xmm7
movdqa %xmm1,%xmm0
paddd  0xe3d(%rip),%xmm0
punpcklwd %xmm7,%xmm5
psrad  $0x10,%xmm5
pand   %xmm0,%xmm5
paddd  %xmm5,%xmm4
punpcklwd %xmm9,%xmm0
psrad  $0x10,%xmm0
pand   %xmm1,%xmm0
paddd  %xmm0,%xmm6
paddd  %xmm13,%xmm1
paddw  %xmm14,%xmm8
add    $0xfffffff8,%eax
jne    1180 <main+0x70>
paddd  %xmm6,%xmm4
pshufd $0xee,%xmm4,%xmm0
paddd  %xmm4,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
add    $0xf8f,%edx
lea    0xe70(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [47 x i8] c"Sum of all multiples of 3 or 5 below %d is %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %23, %1 ]
%3 = phi <4 x i32> [ zeroinitializer, %0 ], [ %21, %1 ]
%4 = phi <4 x i32> [ zeroinitializer, %0 ], [ %22, %1 ]
%5 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %0 ], [ %24, %1 ]
%6 = phi <4 x i16> [ <i16 1, i16 2, i16 3, i16 4>, %0 ], [ %25, %1 ]
%7 = add <4 x i32> %5, <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> %5, <4 x i32> zeroinitializer
%20 = select <4 x i1> %18, <4 x i32> %7, <4 x i32> zeroinitializer
%21 = add <4 x i32> %19, %3
%22 = add <4 x i32> %20, %4
%23 = add nuw i32 %2, 8
%24 = add <4 x i32> %5, <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, 992
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)
%30 = add nuw nsw i32 %29, 3983
%31 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 1000, i32 %30)
ret i32 0
}