#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 *, unsigned int);
int main() {
  unsigned upper_bound = 1000000, sum = 0, iteration = 0;
  for (int i = 3; i < upper_bound; i += 3)
    sum += i;
  for (int i = 5; i < upper_bound; i += 15)
    sum += i;
  for (int i = 10; i < upper_bound; i += 15)
    sum += i;
  printf("%i\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf4240,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    115e <main+0x4e>
mov    -0x14(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x14(%rbp)
jmp    113b <main+0x2b>
movl   $0x5,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1188 <main+0x78>
mov    -0x18(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
add    $0xf,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <main+0x55>
movl   $0xa,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11b2 <main+0xa2>
mov    -0x1c(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xf,%eax
mov    %eax,-0x1c(%rbp)
jmp    118f <main+0x7f>
mov    -0xc(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
mov    $0x53bd924c,%esi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1000000, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 3, i32* %5
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %5
%10 = load i32, i32* %2
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = add i32 %14, %13
store i32 %15, i32* %3
br label %16
16: ; preds = %12
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 3
store i32 %18, i32* %5
br label %8
19: ; preds = %8
store i32 5, i32* %6
br label %20
20: ; preds = %28, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %2
%23 = icmp ult i32 %21, %22
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %6
%26 = load i32, i32* %3
%27 = add i32 %26, %25
store i32 %27, i32* %3
br label %28
28: ; preds = %24
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 15
store i32 %30, i32* %6
br label %20
31: ; preds = %20
store i32 10, i32* %7
br label %32
32: ; preds = %40, %31
%33 = load i32, i32* %7
%34 = load i32, i32* %2
%35 = icmp ult i32 %33, %34
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %7
%38 = load i32, i32* %3
%39 = add i32 %38, %37
store i32 %39, i32* %3
br label %40
40: ; preds = %36
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 15
store i32 %42, i32* %7
br label %32
43: ; preds = %32
%44 = load i32, i32* %3
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [4 x i8] c"%i\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 1404932684)
ret i32 0
}