#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 main(void) {
  printf("Find the sum of all the multiples of 3 or 5 below 1000.\n");
  unsigned long int intSum = 0;
  unsigned int intMax = 1000;
  unsigned int i;
  for (i = 1; i < intMax; i++) {
    if ((i % 3 == 0) || (i % 5 == 0)) {
      intSum += i;
    }
  }
  printf("The sum is: %i", intSum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
movl   $0x3e8,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1197 <main+0x87>
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
je     1179 <main+0x69>
mov    -0x18(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
cmp    $0x0,%edx
jne    1184 <main+0x74>
mov    -0x18(%rbp),%eax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1189 <main+0x79>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <main+0x33>
mov    -0x10(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf97(%rip),%rdi
call   1030 <puts@plt>
movdqa 0xeca(%rip),%xmm8
pxor   %xmm1,%xmm1
movdqa 0xece(%rip),%xmm2
mov    $0x3e4,%eax
movdqa 0xef0(%rip),%xmm15
movdqa 0xef7(%rip),%xmm10
movdqa 0xefe(%rip),%xmm11
movdqa 0xf06(%rip),%xmm3
movdqa 0xf0d(%rip),%xmm12
movdqa 0xf14(%rip),%xmm13
movdqa 0xf1b(%rip),%xmm14
pxor   %xmm7,%xmm7
pxor   %xmm6,%xmm6
nopl   (%rax)
movdqa %xmm8,%xmm0
pmullw 0xe93(%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  0xe02(%rip),%xmm4
pand   %xmm4,%xmm0
paddq  %xmm0,%xmm6
pand   %xmm2,%xmm5
paddq  %xmm5,%xmm7
paddq  %xmm13,%xmm2
paddw  %xmm14,%xmm8
add    $0xfffffffffffffffc,%rax
jne    1190 <main+0x70>
paddq  %xmm7,%xmm6
pshufd $0xee,%xmm6,%xmm0
paddq  %xmm6,%xmm0
movq   %xmm0,%rsi
add    $0x3e7,%rsi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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