#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 */
struct timeval {
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct timeval stop, start;
  gettimeofday(&start, NULL);
  int i, acum = 0;
  for (i = 1; i < 1000; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      acum += i;
    }
  }
  printf("number = %d\n", acum);
  gettimeofday(&stop, NULL);
  printf("took %lu usec\n", stop.tv_usec - start.tv_usec);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    119b <main+0x7b>
mov    -0x14(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     117f <main+0x5f>
mov    -0x14(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1188 <main+0x68>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    118d <main+0x6d>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <main+0x2a>
mov    -0x18(%rbp),%esi
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xe49(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movdqa 0xec7(%rip),%xmm8
movdqa 0xecf(%rip),%xmm1
pxor   %xmm2,%xmm2
mov    $0x3e0,%eax
movdqa 0xeed(%rip),%xmm15
movdqa 0xef4(%rip),%xmm10
movdqa 0xefb(%rip),%xmm11
movdqa 0xf03(%rip),%xmm3
movdqa 0xf0a(%rip),%xmm12
movdqa 0xf11(%rip),%xmm13
movdqa 0xf18(%rip),%xmm14
pxor   %xmm6,%xmm6
pxor   %xmm4,%xmm4
movdqa %xmm8,%xmm0
pmullw 0xe93(%rip),%xmm0
movdqa %xmm0,%xmm5
psubusw %xmm15,%xmm5
pcmpeqw %xmm2,%xmm5
movdqa %xmm8,%xmm7
pmullw %xmm11,%xmm7
movdqa %xmm7,%xmm9
psubusw %xmm3,%xmm9
pcmpeqw %xmm2,%xmm9
por    %xmm5,%xmm9
paddw  %xmm10,%xmm0
psubusw %xmm15,%xmm0
pcmpeqw %xmm2,%xmm0
paddw  %xmm12,%xmm7
psubusw %xmm3,%xmm7
pcmpeqw %xmm2,%xmm7
por    %xmm0,%xmm7
movdqa %xmm1,%xmm0
paddd  0xe2d(%rip),%xmm0
punpcklwd %xmm7,%xmm5
psrad  $0x10,%xmm5
pand   %xmm0,%xmm5
paddd  %xmm5,%xmm4
punpcklwd %xmm9,%xmm0
psrad  $0x10,%xmm0
pand   %xmm1,%xmm0
paddd  %xmm0,%xmm6
paddd  %xmm13,%xmm1
paddw  %xmm14,%xmm8
add    $0xfffffff8,%eax
jne    1190 <main+0x70>
paddd  %xmm6,%xmm4
pshufd $0xee,%xmm4,%xmm0
paddd  %xmm4,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%esi
add    $0xf8f,%esi
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x10(%rsp),%esi
sub    0x8(%rsp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [13 x i8] c"number = %d\0A\00"
@.str.1 = [15 x i8] c"took %lu usec\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
br label %6
6: ; preds = %6, %0
%7 = phi i32 [ 0, %0 ], [ %28, %6 ]
%8 = phi <4 x i32> [ zeroinitializer, %0 ], [ %26, %6 ]
%9 = phi <4 x i32> [ zeroinitializer, %0 ], [ %27, %6 ]
%10 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %0 ], [ %29, %6 ]
%11 = phi <4 x i16> [ <i16 1, i16 2, i16 3, i16 4>, %0 ], [ %30, %6 ]
%12 = add <4 x i32> %10, <i32 4, i32 4, i32 4, i32 4>
%13 = add <4 x i16> %11, <i16 4, i16 4, i16 4, i16 4>
%14 = urem <4 x i16> %11, <i16 3, i16 3, i16 3, i16 3>
%15 = urem <4 x i16> %13, <i16 3, i16 3, i16 3, i16 3>
%16 = icmp eq <4 x i16> %14, zeroinitializer
%17 = icmp eq <4 x i16> %15, zeroinitializer
%18 = urem <4 x i16> %11, <i16 5, i16 5, i16 5, i16 5>
%19 = urem <4 x i16> %13, <i16 5, i16 5, i16 5, i16 5>
%20 = icmp eq <4 x i16> %18, zeroinitializer
%21 = icmp eq <4 x i16> %19, zeroinitializer
%22 = or <4 x i1> %16, %20
%23 = or <4 x i1> %17, %21
%24 = select <4 x i1> %22, <4 x i32> %10, <4 x i32> zeroinitializer
%25 = select <4 x i1> %23, <4 x i32> %12, <4 x i32> zeroinitializer
%26 = add <4 x i32> %24, %8
%27 = add <4 x i32> %25, %9
%28 = add nuw i32 %7, 8
%29 = add <4 x i32> %10, <i32 8, i32 8, i32 8, i32 8>
%30 = add <4 x i16> %11, <i16 8, i16 8, i16 8, i16 8>
%31 = icmp eq i32 %28, 992
br i1 %31, label %32, label %6
32: ; preds = %6
%33 = add <4 x i32> %27, %26
%34 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %33)
%35 = add nuw nsw i32 %34, 3983
%36 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%38 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%41 = load i32, i32* %40
%42 = sub nsw i32 %39, %41
%43 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %42)
ret i32 0
}