#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(void) {
  int i;
  int sum = 0;
  for (i = 0; i < 1000; i++) {
    printf("Current i = %d\n", i);
    if (i % 3 == 0 || i % 5 == 0) {
      sum += i;
      printf("Current Sum = %d\n", sum);
    }
  }
  printf("Sum = %d\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jge    119c <main+0x8c>
mov    -0x8(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1171 <main+0x61>
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1189 <main+0x79>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe8c(%rip),%rdi
call   1030 <printf@plt>
jmp    118e <main+0x7e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r12d,%r12d
lea    0xedb(%rip),%r14
lea    0xee4(%rip),%r15
xor    %ebp,%ebp
jmp    1149 <main+0x39>
add    %ebp,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0x3e8,%ebp
je     1184 <main+0x74>
movzwl %bp,%r13d
imul   $0xaaab,%r13d,%eax
shr    $0x11,%eax
lea    (%rax,%rax,2),%ebx
neg    %ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    %r13w,%bx
je     1130 <main+0x20>
imul   $0xcccd,%r13d,%eax
shr    $0x12,%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%ecx
sub    %eax,%ecx
test   %cx,%cx
jne    113e <main+0x2e>
jmp    1130 <main+0x20>
lea    0xe8d(%rip),%rdi
mov    %r12d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"Current i = %d\0A\00"
@.str.1 = [18 x i8] c"Current Sum = %d\0A\00"
@.str.2 = [10 x i8] c"Sum = %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %14
%2 = phi i32 [ 0, %0 ], [ %15, %14 ]
%3 = phi i32 [ 0, %0 ], [ %16, %14 ]
%4 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = trunc i32 %3 to i16
%6 = urem i16 %5, 3
%7 = icmp eq i16 %6, 0
%8 = urem i16 %5, 5
%9 = icmp eq i16 %8, 0
%10 = or i1 %7, %9
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = add nsw i32 %2, %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %1, %11
%15 = phi i32 [ %12, %11 ], [ %2, %1 ]
%16 = add nuw nsw i32 %3, 1
%17 = icmp eq i32 %16, 1000
br i1 %17, label %18, label %1
18: ; preds = %14
%19 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %15)
ret i32 0
}