#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 */
scalar_t__ is_factor3(int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int i, calc_result = 0;
  for (i = 1; i <= 1000; i++)
    if (is_factor3(i))
      calc_result += i;
  printf("1부터 1000사이의 모든 3의 배수의 합은 %d입니다.\n", calc_result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x3e8,-0x8(%rbp)
jg     1178 <main+0x58>
mov    -0x8(%rbp),%edi
call   1040 <is_factor3@plt>
cmp    $0x0,%rax
je     1165 <main+0x45>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    116a <main+0x4a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113d <main+0x1d>
mov    -0xc(%rbp),%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebp
xor    %ebx,%ebx
jmp    113d <main+0x1d>
nopl   0x0(%rax)
add    %ecx,%ebx
add    $0x1,%ebp
cmp    $0x3e9,%ebp
je     1152 <main+0x32>
mov    %ebp,%edi
call   1040 <is_factor3@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     1130 <main+0x10>
mov    %ebp,%ecx
jmp    1130 <main+0x10>
lea    0xea7(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"1\EB\B6\80\ED\84\B0 1000\EC\82\AC\EC\9D\B4\EC\9D\98 \EB\AA\A8\EB\93\A0 3\EC\9D\98 \EB\B0\B0\EC\88\98\EC\9D\98 \ED\95\A9\EC\9D\80 %d\EC\9E\85\EB\8B\88\EB\8B\A4.\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 1, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 1000
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = load i32, i32* %2
%9 = call i64 @is_factor3(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = load i32, i32* %2
%13 = load i32, i32* %3
%14 = add nsw i32 %13, %12
store i32 %14, i32* %3
br label %15
15: ; preds = %11, %7
br label %16
16: ; preds = %15
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
%20 = load i32, i32* %3
%21 = call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [65 x i8] c"1\EB\B6\80\ED\84\B0 1000\EC\82\AC\EC\9D\B4\EC\9D\98 \EB\AA\A8\EB\93\A0 3\EC\9D\98 \EB\B0\B0\EC\88\98\EC\9D\98 \ED\95\A9\EC\9D\80 %d\EC\9E\85\EB\8B\88\EB\8B\A4.\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %7, %1 ]
%3 = phi i32 [ 1, %0 ], [ %8, %1 ]
%4 = tail call i64 @is_factor3(i32 %3)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i32 0, i32 %3
%7 = add nuw nsw i32 %6, %2
%8 = add nuw nsw i32 %3, 1
%9 = icmp eq i32 %8, 1001
br i1 %9, label %10, label %1
10: ; preds = %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %7)
ret i32 0
}