#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 *, long, size_t);
int main(void) {
  size_t sum = 0;
  size_t bythree, byfive;
  for (bythree = 3, byfive = 5; bythree < 1000L; bythree += 3, byfive += 5) {
    if (byfive % 3 && byfive < 1000L)
      sum += byfive;
    sum += bythree;
  }
  printf("Sum of all multiples of 3 and 5 below %ld: %zu\n", 1000L, sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x3,-0x18(%rbp)
movq   $0x5,-0x20(%rbp)
cmpq   $0x3e8,-0x18(%rbp)
jae    11a0 <main+0x90>
mov    -0x20(%rbp),%rax
mov    $0x3,%ecx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
je     1177 <main+0x67>
cmpq   $0x3e8,-0x20(%rbp)
jae    1177 <main+0x67>
mov    -0x20(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x20(%rbp)
jmp    1137 <main+0x27>
mov    -0x10(%rbp),%rdx
lea    0xe55(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x3,%r8d
mov    $0x5,%ecx
mov    $0xfffffffffffffffb,%r9
mov    $0xa,%esi
mov    $0x9,%edi
xor    %r10d,%r10d
movabs $0xaaaaaaaaaaaaaaab,%r11
aa aa aa
xor    %r14d,%r14d
jmp    117d <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
cmp    $0x3e3,%rcx
cmovae %r10,%rax
add    $0x6,%r8
add    %rax,%rdx
add    %r14,%rdx
add    %rdi,%rdx
add    $0xfffffffffffffff6,%r9
add    $0xa,%rsi
add    $0xc,%rdi
add    $0xa,%rcx
mov    %rdx,%r14
mov    %rcx,%rax
mul    %r11
shr    %rdx
lea    (%rdx,%rdx,2),%rbx
mov    %rsi,%rax
mul    %r11
mov    %rdx,%rax
mov    %rcx,%rdx
add    %r9,%rbx
jne    119d <main+0x8d>
xor    %edx,%edx
cmp    $0x3e8,%rcx
cmovae %r10,%rdx
cmp    $0x3e4,%r8
ja     11cf <main+0xbf>
shr    %rax
lea    (%rax,%rax,2),%rax
mov    $0xa,%ebx
sub    %rax,%rbx
add    %rcx,%rbx
cmp    $0x5,%rbx
je     1150 <main+0x40>
lea    0x5(%rcx),%rax
jmp    1152 <main+0x42>
add    %r14,%rdx
add    %r8,%rdx
lea    0xe24(%rip),%rdi
mov    $0x3e8,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str = [48 x i8] c"Sum of all multiples of 3 and 5 below %ld: %zu\0A\00"
define i32 @main() {
br label %1
1: ; preds = %14, %0
%2 = phi i64 [ 5, %0 ], [ %24, %14 ]
%3 = phi i64 [ 3, %0 ], [ %23, %14 ]
%4 = phi i64 [ 0, %0 ], [ %22, %14 ]
%5 = urem i64 %2, 3
%6 = icmp ne i64 %5, 0
%7 = icmp ult i64 %2, 1000
%8 = and i1 %7, %6
%9 = select i1 %8, i64 %2, i64 0
%10 = add i64 %3, %4
%11 = add i64 %10, %9
%12 = add nuw nsw i64 %2, 5
%13 = icmp ult i64 %3, 997
br i1 %13, label %14, label %25
14: ; preds = %1
%15 = add nuw nsw i64 %3, 3
%16 = urem i64 %12, 3
%17 = icmp ne i64 %16, 0
%18 = icmp ult i64 %2, 995
%19 = and i1 %18, %17
%20 = select i1 %19, i64 %12, i64 0
%21 = add i64 %15, %11
%22 = add i64 %21, %20
%23 = add nuw nsw i64 %3, 6
%24 = add nuw nsw i64 %2, 10
br label %1
25: ; preds = %1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i64 1000, i64 %11)
ret i32 0
}