#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  scanf("%d", &n);
  int i;
  int res = 0;
  for (i = 0; i < n; i++) {
    if (i % 3 == 0 || i % 5 == 0)
      res += i;
  }
  printf("The sum of all multiples of 3 and 5 below %d is %d\n", n, res);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    119d <main+0x7d>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1181 <main+0x61>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118a <main+0x6a>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    118f <main+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <main+0x2d>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xf78(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
xor    %edx,%edx
test   %esi,%esi
jle    129d <main+0x17d>
mov    $0x0,%r10d
cmp    $0x8,%esi
jb     12ad <main+0x18d>
mov    %esi,%r10d
and    $0xfffffff8,%r10d
movdqa 0xea1(%rip),%xmm8
pxor   %xmm0,%xmm0
movdqa 0xeb4(%rip),%xmm10
movdqa 0xebc(%rip),%xmm4
movdqa 0xec3(%rip),%xmm13
pcmpeqd %xmm6,%xmm6
movdqa 0xec6(%rip),%xmm9
movdqa 0xecd(%rip),%xmm14
movdqa 0xed4(%rip),%xmm15
movdqa 0xedb(%rip),%xmm11
movdqa 0xee2(%rip),%xmm12
mov    %r10d,%ecx
pxor   %xmm7,%xmm7
cs nopw 0x0(%rax,%rax,1)
nop
movdqa %xmm8,%xmm5
pmuludq %xmm10,%xmm5
pshufd $0xe8,%xmm5,%xmm5
pshufd $0xf5,%xmm8,%xmm3
movdqa %xmm3,%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,%xmm3
pshufd $0xe8,%xmm3,%xmm3
punpckldq %xmm3,%xmm1
movdqa %xmm1,%xmm3
pxor   %xmm4,%xmm3
pcmpgtd %xmm15,%xmm3
pxor   %xmm6,%xmm3
por    %xmm2,%xmm3
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  0xdb1(%rip),%xmm2
pand   %xmm2,%xmm1
paddd  %xmm1,%xmm7
pand   %xmm8,%xmm3
paddd  %xmm3,%xmm0
paddd  %xmm12,%xmm8
add    $0xfffffff8,%ecx
jne    11c0 <main+0xa0>
paddd  %xmm0,%xmm7
pshufd $0xee,%xmm7,%xmm0
paddd  %xmm7,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%edx
cmp    %r10d,%esi
jne    12ad <main+0x18d>
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    $0xaaaaaaab,%r8d
mov    $0xcccccccd,%r9d
jmp    12d5 <main+0x1b5>
nopl   0x0(%rax,%rax,1)
lea    (%rcx,%rcx,2),%ecx
cmp    %r10d,%ecx
cmove  %r10d,%eax
add    %eax,%edx
add    $0x1,%r10d
cmp    %r10d,%esi
je     129d <main+0x17d>
mov    %r10d,%eax
mov    %rax,%rcx
imul   %r8,%rcx
shr    $0x21,%rcx
imul   %r9,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%edi
mov    %r10d,%eax
cmp    %r10d,%edi
je     12c0 <main+0x1a0>
xor    %eax,%eax
jmp    12c0 <main+0x1a0>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [52 x i8] c"The sum of all multiples of 3 and 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
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
store i32 0, i32* %3
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i32, i32* %3
%12 = srem i32 %11, 3
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i32, i32* %3
%16 = srem i32 %15, 5
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %14, %10
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
br label %22
22: ; preds = %18, %14
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %6
26: ; preds = %6
%27 = load i32, i32* %2
%28 = load i32, i32* %4
%29 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %28)
%30 = load i32, i32* %1
ret i32 %30
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [52 x i8] c"The sum of all multiples of 3 and 5 below %d is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %52
6: ; preds = %0
%7 = icmp ult i32 %4, 8
br i1 %7, label %37, label %8
8: ; preds = %6
%9 = and i32 %4, -8
br label %10
10: ; preds = %10, %8
%11 = phi i32 [ 0, %8 ], [ %30, %10 ]
%12 = phi <4 x i32> [ zeroinitializer, %8 ], [ %28, %10 ]
%13 = phi <4 x i32> [ zeroinitializer, %8 ], [ %29, %10 ]
%14 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %8 ], [ %31, %10 ]
%15 = add <4 x i32> %14, <i32 4, i32 4, i32 4, i32 4>
%16 = urem <4 x i32> %14, <i32 3, i32 3, i32 3, i32 3>
%17 = urem <4 x i32> %15, <i32 3, i32 3, i32 3, i32 3>
%18 = icmp eq <4 x i32> %16, zeroinitializer
%19 = icmp eq <4 x i32> %17, zeroinitializer
%20 = urem <4 x i32> %14, <i32 5, i32 5, i32 5, i32 5>
%21 = urem <4 x i32> %15, <i32 5, i32 5, i32 5, i32 5>
%22 = icmp eq <4 x i32> %20, zeroinitializer
%23 = icmp eq <4 x i32> %21, zeroinitializer
%24 = or <4 x i1> %18, %22
%25 = or <4 x i1> %19, %23
%26 = select <4 x i1> %24, <4 x i32> %14, <4 x i32> zeroinitializer
%27 = select <4 x i1> %25, <4 x i32> %15, <4 x i32> zeroinitializer
%28 = add <4 x i32> %26, %12
%29 = add <4 x i32> %27, %13
%30 = add nuw i32 %11, 8
%31 = add <4 x i32> %14, <i32 8, i32 8, i32 8, i32 8>
%32 = icmp eq i32 %30, %9
br i1 %32, label %33, label %10
33: ; preds = %10
%34 = add <4 x i32> %29, %28
%35 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %34)
%36 = icmp eq i32 %4, %9
br i1 %36, label %52, label %37
37: ; preds = %6, %33
%38 = phi i32 [ 0, %6 ], [ %35, %33 ]
%39 = phi i32 [ 0, %6 ], [ %9, %33 ]
br label %40
40: ; preds = %37, %40
%41 = phi i32 [ %49, %40 ], [ %38, %37 ]
%42 = phi i32 [ %50, %40 ], [ %39, %37 ]
%43 = urem i32 %42, 3
%44 = icmp eq i32 %43, 0
%45 = urem i32 %42, 5
%46 = icmp eq i32 %45, 0
%47 = or i1 %44, %46
%48 = select i1 %47, i32 %42, i32 0
%49 = add nuw nsw i32 %48, %41
%50 = add nuw nsw i32 %42, 1
%51 = icmp eq i32 %50, %4
br i1 %51, label %52, label %40
52: ; preds = %40, %33, %0
%53 = phi i32 [ 0, %0 ], [ %35, %33 ], [ %49, %40 ]
%54 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %53)
ret i32 0
}