#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  uint16_t sum = 0;
  for (int i = 999; i > 2; i--) {
    if (!(i % 5) || !(i % 3))
      sum += i;
  }
  printf("The sum of all the multiples of 3 or 5 below %d is: %d\n", 999, 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   $0x3e7,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jle    117b <main+0x6b>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     115f <main+0x4f>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1168 <main+0x58>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x5d>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    112d <main+0x1d>
mov    -0x8(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x3e7,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
pxor   %xmm0,%xmm0
movdqa 0xee2(%rip),%xmm8
mov    $0x3e0,%eax
movdqa 0xef4(%rip),%xmm10
movdqa 0xefc(%rip),%xmm4
movdqa 0xf03(%rip),%xmm13
pcmpeqd %xmm6,%xmm6
movdqa 0xf06(%rip),%xmm9
movdqa 0xf0d(%rip),%xmm14
movdqa 0xf14(%rip),%xmm15
movdqa 0xf1b(%rip),%xmm11
movdqa 0xf22(%rip),%xmm12
pxor   %xmm3,%xmm3
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movdqa %xmm8,%xmm5
pmuludq %xmm10,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm8,%xmm7
movdqa %xmm7,%xmm2
pmuludq %xmm10,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm5
movdqa %xmm5,%xmm2
pxor   %xmm4,%xmm2
pcmpgtd %xmm13,%xmm2
pxor   %xmm6,%xmm2
movdqa %xmm8,%xmm1
pmuludq %xmm14,%xmm1
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm14,%xmm7
pshufd $0xe8,%xmm7,%xmm7
punpckldq %xmm7,%xmm1
movdqa %xmm1,%xmm7
pxor   %xmm4,%xmm7
pcmpgtd %xmm15,%xmm7
pxor   %xmm6,%xmm7
por    %xmm2,%xmm7
paddd  %xmm9,%xmm5
pxor   %xmm4,%xmm5
pcmpgtd %xmm13,%xmm5
pxor   %xmm6,%xmm5
paddd  %xmm11,%xmm1
pxor   %xmm4,%xmm1
pcmpgtd %xmm15,%xmm1
pxor   %xmm6,%xmm1
por    %xmm5,%xmm1
movdqa %xmm8,%xmm2
paddd  0xdf1(%rip),%xmm2
pand   %xmm2,%xmm1
paddd  %xmm1,%xmm3
pand   %xmm8,%xmm7
paddd  %xmm7,%xmm0
paddd  %xmm12,%xmm8
add    $0xfffffff8,%eax
jne    1180 <main+0x70>
paddd  %xmm0,%xmm3
pshufd $0xee,%xmm3,%xmm0
paddd  %xmm3,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
add    $0xe,%edx
lea    0xe3e(%rip),%rdi
mov    $0x3e7,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [56 x i8] c"The sum of all the multiples of 3 or 5 below %d is: %d\0A\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 999, i32* %3
br label %4
4: ; preds = %20, %0
%5 = load i32, i32* %3
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %23
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 = srem i32 %12, 3
%14 = icmp ne i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %11, %7
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = add nsw i32 %17, %16
store i32 %18, i32* %2
br label %19
19: ; preds = %15, %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
br label %4
23: ; preds = %4
%24 = load i32, i32* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 999, i32 %24)
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"The sum of all the 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 ], [ %21, %1 ]
%3 = phi <4 x i32> [ <i32 999, i32 998, i32 997, i32 996>, %0 ], [ %22, %1 ]
%4 = phi <4 x i32> [ zeroinitializer, %0 ], [ %19, %1 ]
%5 = phi <4 x i32> [ zeroinitializer, %0 ], [ %20, %1 ]
%6 = add <4 x i32> %3, <i32 -4, i32 -4, i32 -4, i32 -4>
%7 = urem <4 x i32> %3, <i32 5, i32 5, i32 5, i32 5>
%8 = urem <4 x i32> %6, <i32 5, i32 5, i32 5, i32 5>
%9 = icmp eq <4 x i32> %7, zeroinitializer
%10 = icmp eq <4 x i32> %8, zeroinitializer
%11 = urem <4 x i32> %3, <i32 3, i32 3, i32 3, i32 3>
%12 = urem <4 x i32> %6, <i32 3, i32 3, i32 3, i32 3>
%13 = icmp eq <4 x i32> %11, zeroinitializer
%14 = icmp eq <4 x i32> %12, zeroinitializer
%15 = or <4 x i1> %9, %13
%16 = or <4 x i1> %10, %14
%17 = select <4 x i1> %15, <4 x i32> %3, <4 x i32> zeroinitializer
%18 = select <4 x i1> %16, <4 x i32> %6, <4 x i32> zeroinitializer
%19 = add <4 x i32> %17, %4
%20 = add <4 x i32> %18, %5
%21 = add nuw i32 %2, 8
%22 = add <4 x i32> %3, <i32 -8, i32 -8, i32 -8, i32 -8>
%23 = icmp eq i32 %21, 992
br i1 %23, label %24, label %1
24: ; preds = %1
%25 = add <4 x i32> %20, %19
%26 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %25)
%27 = add nsw i32 %26, 14
%28 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i32 999, i32 %27)
ret i32 0
}