#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 main(void) {
  unsigned int sum = 0;
  printf("3:\n");
  for (int i = 3; i < 1000; i += 3) {
    sum += i;
    printf("%.3d -> %d\n", i, sum);
  }
  printf("5:\n");
  for (int i = 5; i < 1000; i += 5) {
    if (i % 3 != 0) {
      sum += i;
      printf("%.3d -> %d\n", i, sum);
    } else {
      printf("%.3d -> skip\n", i);
    }
  }
  printf("sum: %u\n", sum);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3,-0xc(%rbp)
cmpl   $0x3e8,-0xc(%rbp)
jge    1173 <main+0x63>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0xc(%rbp)
jmp    113b <main+0x2b>
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x5,-0x10(%rbp)
cmpl   $0x3e8,-0x10(%rbp)
jge    11ef <main+0xdf>
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11cb <main+0xbb>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xcc>
mov    -0x10(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e1 <main+0xd1>
mov    -0x10(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x10(%rbp)
jmp    1188 <main+0x78>
mov    -0x8(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
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   %rbx
push   %rax
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%r14
xor    %eax,%eax
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %eax,%ebx
add    $0x3,%ebx
add    %eax,%ebp
add    $0x3,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
cmp    $0x3e5,%ebx
jb     1140 <main+0x20>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x28bb1,%ebp
mov    $0x5,%ebx
lea    0xe8d(%rip),%r14
lea    0xe7a(%rip),%r15
jmp    11a9 <main+0x89>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x5(%rbx),%eax
cmp    $0x3e3,%ebx
mov    %eax,%ebx
jae    11d1 <main+0xb1>
movzwl %bx,%eax
imul   $0xaaab,%eax,%ecx
shr    $0x11,%ecx
lea    (%rcx,%rcx,2),%ecx
neg    %ecx
add    %cx,%ax
je     1190 <main+0x70>
add    %ebx,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    119c <main+0x7c>
lea    0xe42(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str.1 = [12 x i8] c"%.3d -> %d\0A\00"
@.str.3 = [14 x i8] c"%.3d -> skip\0A\00"
@.str.4 = [9 x i8] c"sum: %u\0A\00"
@str = [3 x i8] c"3:\00"
@str.5 = [3 x i8] c"5:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %4
2: ; preds = %4
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0))
br label %13
4: ; preds = %0, %4
%5 = phi i32 [ 3, %0 ], [ %9, %4 ]
%6 = phi i32 [ 0, %0 ], [ %7, %4 ]
%7 = add i32 %5, %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %7)
%9 = add nuw nsw i32 %5, 3
%10 = icmp ult i32 %5, 997
br i1 %10, label %4, label %2
11: ; preds = %24
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %25)
ret i32 0
13: ; preds = %2, %24
%14 = phi i32 [ 5, %2 ], [ %26, %24 ]
%15 = phi i32 [ 166833, %2 ], [ %25, %24 ]
%16 = trunc i32 %14 to i16
%17 = urem i16 %16, 3
%18 = icmp eq i16 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %13
%20 = add i32 %14, %15
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %20)
br label %24
22: ; preds = %13
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %24
24: ; preds = %19, %22
%25 = phi i32 [ %20, %19 ], [ %15, %22 ]
%26 = add nuw nsw i32 %14, 5
%27 = icmp ult i32 %14, 995
br i1 %27, label %13, label %11
}