#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 main() {
  int sum = 0;
  int i;
  int count_3, count_5 = 0;
  for (i = 1; i < 100; i++) {
    count_3++;
    count_5++;
    if (count_5 == 5) {
      count_5 = 0;
      if (count_3 == 3)
        count_3 = 0;
      sum += i;
    } else {
      if (count_3 == 3) {
        count_3 = 0;
        sum += i;
      }
    }
  }
  printf("SUM is: %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11b2 <main+0xa2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jne    1180 <main+0x70>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x10(%rbp)
jne    1172 <main+0x62>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    119f <main+0x8f>
cmpl   $0x3,-0x10(%rbp)
jne    119a <main+0x8a>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    119f <main+0x8f>
jmp    11a4 <main+0x94>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1134 <main+0x24>
mov    -0x8(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x1,%r8d
xor    %r9d,%r9d
xor    %edi,%edi
mov    $0x1,%edx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %edx,%esi
cmp    $0x2,%ecx
je     1139 <main+0x29>
xor    %esi,%esi
cmp    $0x4,%edi
cmove  %edx,%esi
add    %eax,%esi
add    $0x1,%edx
cmp    $0x64,%edx
je     117d <main+0x6d>
cmp    $0x2,%ecx
lea    0x2(%rcx),%ecx
cmove  %r8d,%ecx
cmp    $0x4,%edi
lea    0x2(%rdi),%edi
cmove  %r8d,%edi
cmp    $0x3,%ecx
mov    $0x0,%eax
cmove  %edx,%eax
cmove  %r9d,%ecx
cmp    $0x5,%edi
cmove  %edx,%eax
cmove  %r9d,%edi
add    %esi,%eax
add    $0x1,%edx
jmp    1130 <main+0x20>
push   %rax
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"SUM is: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %13, %0
%2 = phi i32 [ 0, %0 ], [ %22, %13 ]
%3 = phi i32 [ undef, %0 ], [ %23, %13 ]
%4 = phi i32 [ 1, %0 ], [ %25, %13 ]
%5 = phi i32 [ 0, %0 ], [ %24, %13 ]
%6 = icmp eq i32 %2, 4
%7 = icmp eq i32 %3, 2
%8 = select i1 %6, i1 true, i1 %7
%9 = select i1 %8, i32 %4, i32 0
%10 = add nuw nsw i32 %9, %5
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %26, label %13
13: ; preds = %1
%14 = add nsw i32 %3, 2
%15 = select i1 %7, i32 1, i32 %14
%16 = add nsw i32 %2, 2
%17 = select i1 %6, i32 1, i32 %16
%18 = icmp eq i32 %17, 5
%19 = icmp eq i32 %15, 3
%20 = select i1 %18, i1 true, i1 %19
%21 = select i1 %20, i32 %11, i32 0
%22 = select i1 %18, i32 0, i32 %17
%23 = select i1 %19, i32 0, i32 %15
%24 = add nuw nsw i32 %21, %10
%25 = add nuw nsw i32 %4, 2
br label %1
26: ; preds = %1
%27 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %10)
ret i32 0
}