#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);
int fun(int n) {
  int j = 0, i = n + 1;
  while (i--) {
    if (i % 3 == 2 && i % 5 == 3 && i % 7 == 2)
      ++j;
  }
  printf("[%i, %i]\n", n, j);
  return j;
}


x86 assembly (clang, -O0):
<fun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     1189 <fun+0x79>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1184 <fun+0x74>
mov    -0xc(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x3,%edx
jne    1184 <fun+0x74>
mov    -0xc(%rbp),%eax
mov    $0x7,%ecx
cltd
idiv   %ecx
cmp    $0x2,%edx
jne    1184 <fun+0x74>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112b <fun+0x1b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fun>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%esi
cmp    $0xffffffff,%edi
je     1497 <fun+0x387>
lea    0x1(%rsi),%ecx
xor    %ebx,%ebx
mov    %esi,%eax
cmp    $0x8,%ecx
jb     1420 <fun+0x310>
mov    %ecx,%edx
and    $0xfffffff8,%edx
mov    %esi,%eax
sub    %edx,%eax
movd   %esi,%xmm0
pshufd $0x0,%xmm0,%xmm5
paddd  0xeb6(%rip),%xmm5
pxor   %xmm0,%xmm0
mov    %edx,%edi
pxor   %xmm12,%xmm12
movdqa 0xef2(%rip),%xmm14
movdqa 0xef9(%rip),%xmm15
nopw   0x0(%rax,%rax,1)
movdqa %xmm0,(%rsp)
movdqa %xmm5,%xmm7
paddd  0xe8f(%rip),%xmm7
movdqa %xmm5,%xmm0
movdqa 0xe92(%rip),%xmm10
pmuludq %xmm10,%xmm0
pshufd $0xed,%xmm0,%xmm0
pshufd $0xf5,%xmm5,%xmm13
movdqa %xmm13,%xmm1
pmuludq %xmm10,%xmm1
pshufd $0xed,%xmm1,%xmm1
punpckldq %xmm1,%xmm0
pxor   %xmm3,%xmm3
pcmpgtd %xmm5,%xmm3
movdqa %xmm3,%xmm1
pand   %xmm10,%xmm1
psubd  %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrld  $0x1f,%xmm1
paddd  %xmm0,%xmm1
movdqa %xmm1,%xmm0
paddd  %xmm1,%xmm0
paddd  %xmm1,%xmm0
movdqa %xmm5,%xmm6
psubd  %xmm0,%xmm6
pshufd $0xf5,%xmm7,%xmm8
pxor   %xmm1,%xmm1
pcmpgtd %xmm7,%xmm1
movdqa %xmm7,%xmm9
movdqa %xmm7,%xmm2
movdqa %xmm7,%xmm0
pmuludq %xmm10,%xmm0
pshufd $0xed,%xmm0,%xmm0
movdqa %xmm8,%xmm4
pmuludq %xmm10,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm0
movdqa %xmm1,%xmm4
pand   %xmm10,%xmm4
psubd  %xmm4,%xmm0
movdqa %xmm0,%xmm4
psrld  $0x1f,%xmm4
paddd  %xmm0,%xmm4
movdqa %xmm4,%xmm0
paddd  %xmm4,%xmm0
paddd  %xmm4,%xmm0
psubd  %xmm0,%xmm9
movdqa %xmm5,%xmm0
pmuludq %xmm14,%xmm0
pshufd $0xed,%xmm0,%xmm0
movdqa %xmm13,%xmm4
pmuludq %xmm14,%xmm4
pshufd $0xed,%xmm4,%xmm4
punpckldq %xmm4,%xmm0
movdqa %xmm3,%xmm4
pand   %xmm14,%xmm4
psubd  %xmm4,%xmm0
movdqa %xmm0,%xmm4
psrld  $0x1f,%xmm4
psrad  $0x1,%xmm0
paddd  %xmm4,%xmm0
movdqa %xmm0,%xmm4
pslld  $0x2,%xmm4
paddd  %xmm0,%xmm4
movdqa %xmm5,%xmm0
psubd  %xmm4,%xmm0
pmuludq %xmm14,%xmm2
pshufd $0xed,%xmm2,%xmm10
movdqa %xmm8,%xmm2
pmuludq %xmm14,%xmm2
pshufd $0xed,%xmm2,%xmm2
punpckldq %xmm2,%xmm10
movdqa %xmm7,%xmm2
pmuludq %xmm15,%xmm2
pshufd $0xed,%xmm2,%xmm11
pmuludq %xmm15,%xmm8
pshufd $0xed,%xmm8,%xmm2
punpckldq %xmm2,%xmm11
movdqa %xmm1,%xmm2
pand   %xmm15,%xmm1
paddd  %xmm7,%xmm1
psubd  %xmm1,%xmm11
paddd  %xmm7,%xmm11
pand   %xmm14,%xmm2
psubd  %xmm2,%xmm10
movdqa %xmm10,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x1,%xmm10
paddd  %xmm1,%xmm10
movdqa %xmm10,%xmm1
pslld  $0x2,%xmm1
paddd  %xmm10,%xmm1
movdqa %xmm11,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x2,%xmm11
paddd  %xmm2,%xmm11
movdqa %xmm11,%xmm2
pslld  $0x3,%xmm2
psubd  %xmm2,%xmm11
paddd  %xmm7,%xmm11
psubd  %xmm1,%xmm7
movdqa 0xce9(%rip),%xmm4
pcmpeqd %xmm4,%xmm6
movdqa 0xccd(%rip),%xmm1
pcmpeqd %xmm1,%xmm0
pand   %xmm6,%xmm0
pcmpeqd %xmm4,%xmm9
pcmpeqd %xmm1,%xmm7
pand   %xmm9,%xmm7
movdqa %xmm5,%xmm1
pmuludq %xmm15,%xmm1
pshufd $0xed,%xmm1,%xmm1
pmuludq %xmm15,%xmm13
pshufd $0xed,%xmm13,%xmm2
punpckldq %xmm2,%xmm1
pand   %xmm15,%xmm3
paddd  %xmm5,%xmm3
psubd  %xmm3,%xmm1
paddd  %xmm5,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x2,%xmm1
paddd  %xmm2,%xmm1
movdqa %xmm1,%xmm2
pslld  $0x3,%xmm2
psubd  %xmm2,%xmm1
paddd  %xmm5,%xmm1
pcmpeqd %xmm4,%xmm1
pand   %xmm0,%xmm1
movdqa (%rsp),%xmm0
psubd  %xmm1,%xmm0
pcmpeqd %xmm4,%xmm11
pand   %xmm7,%xmm11
psubd  %xmm11,%xmm12
paddd  0xc7e(%rip),%xmm5
add    $0xfffffff8,%edi
jne    1170 <fun+0x60>
paddd  %xmm0,%xmm12
pshufd $0xee,%xmm12,%xmm0
paddd  %xmm12,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%ebx
cmp    %edx,%ecx
je     1499 <fun+0x389>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
mov    %eax,%edx
sub    %ecx,%edx
xor    $0x2,%edx
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdi
shr    $0x3f,%rdi
shr    $0x20,%rcx
sar    %ecx
add    %edi,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%edi
sub    %ecx,%edi
xor    $0x3,%edi
or     %edx,%edi
imul   $0xffffffff92492493,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x2,%ecx
add    %edx,%ecx
lea    0x0(,%rcx,8),%edx
sub    %edx,%ecx
add    %eax,%ecx
xor    $0x2,%ecx
xor    %edx,%edx
or     %edi,%ecx
sete   %dl
add    %edx,%ebx
add    $0xffffffff,%eax
jb     1420 <fun+0x310>
jmp    1499 <fun+0x389>
xor    %ebx,%ebx
lea    0xbe0(%rip),%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"[%i, %i]\0A\00"
define i32 @fun(i32 %0) {
%2 = icmp eq i32 %0, -1
br i1 %2, label %63, label %3
3: ; preds = %1
%4 = add i32 %0, 1
%5 = icmp ult i32 %4, 8
br i1 %5, label %45, label %6
6: ; preds = %3
%7 = and i32 %4, -8
%8 = sub i32 %0, %7
%9 = insertelement <4 x i32> poison, i32 %0, i64 0
%10 = shufflevector <4 x i32> %9, <4 x i32> poison, <4 x i32> zeroinitializer
%11 = add <4 x i32> %10, <i32 0, i32 -1, i32 -2, i32 -3>
br label %12
12: ; preds = %12, %6
%13 = phi i32 [ 0, %6 ], [ %38, %12 ]
%14 = phi <4 x i32> [ %11, %6 ], [ %39, %12 ]
%15 = phi <4 x i32> [ zeroinitializer, %6 ], [ %36, %12 ]
%16 = phi <4 x i32> [ zeroinitializer, %6 ], [ %37, %12 ]
%17 = add <4 x i32> %14, <i32 -4, i32 -4, i32 -4, i32 -4>
%18 = srem <4 x i32> %14, <i32 3, i32 3, i32 3, i32 3>
%19 = srem <4 x i32> %17, <i32 3, i32 3, i32 3, i32 3>
%20 = icmp eq <4 x i32> %18, <i32 2, i32 2, i32 2, i32 2>
%21 = icmp eq <4 x i32> %19, <i32 2, i32 2, i32 2, i32 2>
%22 = srem <4 x i32> %14, <i32 5, i32 5, i32 5, i32 5>
%23 = srem <4 x i32> %17, <i32 5, i32 5, i32 5, i32 5>
%24 = icmp eq <4 x i32> %22, <i32 3, i32 3, i32 3, i32 3>
%25 = icmp eq <4 x i32> %23, <i32 3, i32 3, i32 3, i32 3>
%26 = and <4 x i1> %20, %24
%27 = and <4 x i1> %21, %25
%28 = srem <4 x i32> %14, <i32 7, i32 7, i32 7, i32 7>
%29 = srem <4 x i32> %17, <i32 7, i32 7, i32 7, i32 7>
%30 = icmp eq <4 x i32> %28, <i32 2, i32 2, i32 2, i32 2>
%31 = icmp eq <4 x i32> %29, <i32 2, i32 2, i32 2, i32 2>
%32 = select <4 x i1> %26, <4 x i1> %30, <4 x i1> zeroinitializer
%33 = select <4 x i1> %27, <4 x i1> %31, <4 x i1> zeroinitializer
%34 = zext <4 x i1> %32 to <4 x i32>
%35 = zext <4 x i1> %33 to <4 x i32>
%36 = add <4 x i32> %15, %34
%37 = add <4 x i32> %16, %35
%38 = add nuw i32 %13, 8
%39 = add <4 x i32> %14, <i32 -8, i32 -8, i32 -8, i32 -8>
%40 = icmp eq i32 %38, %7
br i1 %40, label %41, label %12
41: ; preds = %12
%42 = add <4 x i32> %37, %36
%43 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %42)
%44 = icmp eq i32 %4, %7
br i1 %44, label %63, label %45
45: ; preds = %3, %41
%46 = phi i32 [ %0, %3 ], [ %8, %41 ]
%47 = phi i32 [ 0, %3 ], [ %43, %41 ]
br label %48
48: ; preds = %45, %48
%49 = phi i32 [ %61, %48 ], [ %46, %45 ]
%50 = phi i32 [ %60, %48 ], [ %47, %45 ]
%51 = srem i32 %49, 3
%52 = icmp eq i32 %51, 2
%53 = srem i32 %49, 5
%54 = icmp eq i32 %53, 3
%55 = and i1 %52, %54
%56 = srem i32 %49, 7
%57 = icmp eq i32 %56, 2
%58 = select i1 %55, i1 %57, i1 false
%59 = zext i1 %58 to i32
%60 = add nuw nsw i32 %50, %59
%61 = add nsw i32 %49, -1
%62 = icmp eq i32 %49, 0
br i1 %62, label %63, label %48
63: ; preds = %48, %41, %1
%64 = phi i32 [ 0, %1 ], [ %43, %41 ], [ %60, %48 ]
%65 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %64)
ret i32 %64
}