#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 gcd(int, int);
int /*<<< orphan*/ printf(char *, int);
int main() {
  int count = 0;
  for (int d = 2; d <= 12000; d++) {
    for (int n = d / 3 + 1; n < (d % 2 == 0 ? d / 2 : d / 2 + 1); n++) {
      if (gcd(d, n) == 1) {
        count++;
      }
    }
  }
  printf("%d\n", count);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
cmpl   $0x2ee0,-0xc(%rbp)
jg     11ea <main+0xca>
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1188 <main+0x68>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x79>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    11d7 <main+0xb7>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <gcd@plt>
cmp    $0x1,%eax
jne    11c4 <main+0xa4>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c9 <main+0xa9>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <main+0x3b>
jmp    11dc <main+0xbc>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
mov    -0x8(%rbp),%esi
lea    0xe0c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
mov    $0x2,%r14d
jmp    114d <main+0x2d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14d
cmp    $0x2ee1,%r14d
je     119e <main+0x7e>
movzwl %r14w,%eax
imul   $0xaaab,%eax,%ebp
shr    $0x11,%ebp
mov    %r14d,%eax
and    $0x1,%eax
mov    %r14d,%r15d
shr    %r15d
add    %eax,%r15d
add    $0x1,%ebp
cmp    %ebp,%r15d
jbe    1140 <main+0x20>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebp,%esi
call   1040 <gcd@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%ebx
add    $0x1,%ebp
cmp    %r15d,%ebp
jb     1180 <main+0x60>
jmp    1140 <main+0x20>
lea    0xe5b(%rip),%rdi
mov    %ebx,%esi
call   1030 <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"%d\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
store i32 2, i32* %3
br label %5
5: ; preds = %40, %0
%6 = load i32, i32* %3
%7 = icmp sle i32 %6, 12000
br i1 %7, label %8, label %43
8: ; preds = %5
%9 = load i32, i32* %3
%10 = sdiv i32 %9, 3
%11 = add nsw i32 %10, 1
store i32 %11, i32* %4
br label %12
12: ; preds = %36, %8
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = srem i32 %14, 2
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 2
br label %24
20: ; preds = %12
%21 = load i32, i32* %3
%22 = sdiv i32 %21, 2
%23 = add nsw i32 %22, 1
br label %24
24: ; preds = %20, %17
%25 = phi i32 [ %19, %17 ], [ %23, %20 ]
%26 = icmp slt i32 %13, %25
br i1 %26, label %27, label %39
27: ; preds = %24
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = call i32 @gcd(i32 %28, i32 %29)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %35
35: ; preds = %32, %27
br label %36
36: ; preds = %35
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %12
39: ; preds = %24
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %5
43: ; preds = %5
%44 = load i32, i32* %2
%45 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %1
ret i32 %46
}

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