#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 prime(int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, int *);
int /*<<< orphan*/ sieve();
int main() {
  int n, count, p;
  sieve();
  while (scanf("%d", &n) == 1) {
    int half = n / 2;
    count = 0;
    if (n == 0)
      break;
    for (p = 1; p <= half; p++) {
      if (prime(p) == 1 && prime(n - p) == 1)
        count++;
    }
    printf("%d\n", count);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <sieve@plt>
lea    0xea3(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11fb <main+0xbb>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1193 <main+0x53>
jmp    11fb <main+0xbb>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11e7 <main+0xa7>
mov    -0x10(%rbp),%edi
call   1060 <prime@plt>
cmp    $0x1,%eax
jne    11d4 <main+0x94>
mov    -0x8(%rbp),%edi
sub    -0x10(%rbp),%edi
call   1060 <prime@plt>
cmp    $0x1,%eax
jne    11d4 <main+0x94>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d9 <main+0x99>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <main+0x5a>
mov    -0xc(%rbp),%esi
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
jmp    1156 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <sieve@plt>
lea    0xea7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    120b <main+0xcb>
lea    0xe8d(%rip),%r15
lea    0x4(%rsp),%r12
jmp    119f <main+0x5f>
nopw   0x0(%rax,%rax,1)
lea    0xe7c(%rip),%rdi
mov    %r13d,%esi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    120b <main+0xcb>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     120b <main+0xcb>
xor    %r13d,%r13d
cmp    $0x2,%eax
jl     1180 <main+0x40>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
neg    %ebp
xor    %r13d,%r13d
mov    $0x1,%ebx
mov    $0xffffffff,%r14d
jmp    11e6 <main+0xa6>
nopw   0x0(%rax,%rax,1)
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
add    $0xffffffff,%r14d
mov    %ecx,%ebx
cmp    $0x1,%eax
je     1180 <main+0x40>
mov    %ebx,%edi
call   1060 <prime@plt>
cmp    $0x1,%eax
jne    11d0 <main+0x90>
mov    0x4(%rsp),%edi
add    %r14d,%edi
call   1060 <prime@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%r13d
jmp    11d0 <main+0x90>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (...) @sieve()
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %33
6: ; preds = %0, %28
%7 = load i32, i32* %1
%8 = sdiv i32 %7, 2
%9 = icmp eq i32 %7, 0
br i1 %9, label %33, label %10
10: ; preds = %6
%11 = icmp slt i32 %7, 2
br i1 %11, label %28, label %12
12: ; preds = %10, %24
%13 = phi i32 [ %26, %24 ], [ 1, %10 ]
%14 = phi i32 [ %25, %24 ], [ 0, %10 ]
%15 = call i32 @prime(i32 %13)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i32, i32* %1
%19 = sub nsw i32 %18, %13
%20 = call i32 @prime(i32 %19)
%21 = icmp eq i32 %20, 1
%22 = zext i1 %21 to i32
%23 = add nsw i32 %14, %22
br label %24
24: ; preds = %17, %12
%25 = phi i32 [ %14, %12 ], [ %23, %17 ]
%26 = add nuw nsw i32 %13, 1
%27 = icmp eq i32 %13, %8
br i1 %27, label %28, label %12
28: ; preds = %24, %10
%29 = phi i32 [ 0, %10 ], [ %25, %24 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%32 = icmp eq i32 %31, 1
br i1 %32, label %6, label %33
33: ; preds = %28, %6, %0
ret i32 0
}