#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(long);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, long *);
long sqrt(long);
int main() {
  long n, i, f;
  while (scanf("%ld", &n) == 1) {
    f = 0;
    if (n == 0)
      break;
    if (n == 4) {
      printf("4:\n2+2\n");
      continue;
    }
    if (prime(n - 2) == 1) {
      printf("%ld:\n2+%ld\n", n, n - 2);
      continue;
    } else {
      for (i = 1; i <= sqrt(n); i += 2) {
        if (prime(i) == 1 && prime(n - i) == 1) {
          f = 1;
          goto end;
        }
      }
    }
  end:
    if (f == 1)
      printf("%lld is the sum of %lld and %lld.\n", n, i, n - i);
    else
      printf("%ld:\nNO WAY!\n", n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1296 <main+0x156>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1180 <main+0x40>
jmp    1296 <main+0x156>
cmpq   $0x4,-0x10(%rbp)
jne    119e <main+0x5e>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
mov    -0x10(%rbp),%rdi
sub    $0x2,%rdi
call   1050 <prime@plt>
cmp    $0x1,%eax
jne    11d3 <main+0x93>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rdx
sub    $0x2,%rdx
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sqrt@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jg     1247 <main+0x107>
mov    -0x18(%rbp),%rdi
call   1050 <prime@plt>
cmp    $0x1,%eax
jne    1231 <main+0xf1>
mov    -0x10(%rbp),%rdi
sub    -0x18(%rbp),%rdi
call   1050 <prime@plt>
cmp    $0x1,%eax
jne    1231 <main+0xf1>
movq   $0x1,-0x20(%rbp)
jmp    1251 <main+0x111>
jmp    1236 <main+0xf6>
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x18(%rbp)
jmp    11db <main+0x9b>
jmp    124c <main+0x10c>
jmp    1251 <main+0x111>
cmpq   $0x1,-0x20(%rbp)
jne    127f <main+0x13f>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
sub    -0x18(%rbp),%rcx
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1291 <main+0x151>
mov    -0x10(%rbp),%rsi
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    127b <main+0x12b>
lea    0xec7(%rip),%r14
lea    0xe7f(%rip),%r15
mov    %rsp,%rbx
lea    0xe79(%rip),%r12
jmp    11ac <main+0x5c>
nopl   (%rax)
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    127b <main+0x12b>
mov    (%rsp),%rdi
cmp    $0x4,%rdi
je     1190 <main+0x40>
test   %rdi,%rdi
je     127b <main+0x12b>
add    $0xfffffffffffffffe,%rdi
call   1060 <prime@plt>
mov    (%rsp),%rsi
cmp    $0x1,%eax
jne    11f0 <main+0xa0>
lea    -0x2(%rsi),%rdx
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rsi,%rdi
call   1070 <sqrt@plt>
test   %rax,%rax
jle    1264 <main+0x114>
mov    $0x1,%ebp
mov    $0xffffffffffffffff,%r13
jmp    1226 <main+0xd6>
nopl   0x0(%rax,%rax,1)
add    $0x2,%rbp
mov    (%rsp),%rdi
call   1070 <sqrt@plt>
add    $0xfffffffffffffffe,%r13
cmp    %rax,%rbp
jg     1264 <main+0x114>
mov    %rbp,%rdi
call   1060 <prime@plt>
cmp    $0x1,%eax
jne    1210 <main+0xc0>
mov    (%rsp),%rdi
add    %r13,%rdi
call   1060 <prime@plt>
cmp    $0x1,%eax
jne    1210 <main+0xc0>
mov    (%rsp),%rsi
mov    %rsi,%rcx
sub    %rbp,%rcx
lea    0xdbb(%rip),%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x48>
mov    (%rsp),%rsi
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x48>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [8 x i8] c"4:\0A2+2\0A\00"
@.str.2 = [12 x i8] c"%ld:\0A2+%ld\0A\00"
@.str.3 = [35 x i8] c"%lld is the sum of %lld and %lld.\0A\00"
@.str.4 = [14 x i8] c"%ld:\0ANO WAY!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i32 0, i32* %1
br label %5
5: ; preds = %63, %22, %15, %0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %64
8: ; preds = %5
store i64 0, i64* %4
%9 = load i64, i64* %2
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %64
12: ; preds = %8
%13 = load i64, i64* %2
%14 = icmp eq i64 %13, 4
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %5
17: ; preds = %12
%18 = load i64, i64* %2
%19 = sub nsw i64 %18, 2
%20 = call i32 @prime(i64 %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i64, i64* %2
%24 = load i64, i64* %2
%25 = sub nsw i64 %24, 2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %23, i64 %25)
br label %5
27: ; preds = %17
store i64 1, i64* %3
br label %28
28: ; preds = %45, %27
%29 = load i64, i64* %3
%30 = load i64, i64* %2
%31 = call i64 @sqrt(i64 %30)
%32 = icmp sle i64 %29, %31
br i1 %32, label %33, label %48
33: ; preds = %28
%34 = load i64, i64* %3
%35 = call i32 @prime(i64 %34)
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %44
37: ; preds = %33
%38 = load i64, i64* %2
%39 = load i64, i64* %3
%40 = sub nsw i64 %38, %39
%41 = call i32 @prime(i64 %40)
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %44
43: ; preds = %37
store i64 1, i64* %4
br label %50
44: ; preds = %37, %33
br label %45
45: ; preds = %44
%46 = load i64, i64* %3
%47 = add nsw i64 %46, 2
store i64 %47, i64* %3
br label %28
48: ; preds = %28
br label %49
49: ; preds = %48
br label %50
50: ; preds = %49, %43
%51 = load i64, i64* %4
%52 = icmp eq i64 %51, 1
br i1 %52, label %53, label %60
53: ; preds = %50
%54 = load i64, i64* %2
%55 = load i64, i64* %3
%56 = load i64, i64* %2
%57 = load i64, i64* %3
%58 = sub nsw i64 %56, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i64 %54, i64 %55, i64 %58)
br label %63
60: ; preds = %50
%61 = load i64, i64* %2
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %61)
br label %63
63: ; preds = %60, %53
br label %5
64: ; preds = %11, %5
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.2 = [12 x i8] c"%ld:\0A2+%ld\0A\00"
@.str.3 = [35 x i8] c"%lld is the sum of %lld and %lld.\0A\00"
@.str.4 = [14 x i8] c"%ld:\0ANO WAY!\0A\00"
@str = [7 x i8] c"4:\0A2+2\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %44
5: ; preds = %0, %9
%6 = load i64, i64* %1
switch i64 %6, label %12 [
i64 0, label %44
i64 4, label %7
]
7: ; preds = %5
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %9
9: ; preds = %37, %41, %7, %20
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %5, label %44
12: ; preds = %5
%13 = add nsw i64 %6, -2
%14 = call i32 @prime(i64 %13)
%15 = icmp eq i32 %14, 1
%16 = load i64, i64* %1
br i1 %15, label %20, label %17
17: ; preds = %12
%18 = call i64 @sqrt(i64 %16)
%19 = icmp slt i64 %18, 1
br i1 %19, label %41, label %23
20: ; preds = %12
%21 = add nsw i64 %16, -2
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i64 %16, i64 %21)
br label %9
23: ; preds = %17, %32
%24 = phi i64 [ %33, %32 ], [ 1, %17 ]
%25 = call i32 @prime(i64 %24)
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load i64, i64* %1
%29 = sub nsw i64 %28, %24
%30 = call i32 @prime(i64 %29)
%31 = icmp eq i32 %30, 1
br i1 %31, label %37, label %32
32: ; preds = %23, %27
%33 = add nuw nsw i64 %24, 2
%34 = load i64, i64* %1
%35 = call i64 @sqrt(i64 %34)
%36 = icmp sgt i64 %33, %35
br i1 %36, label %41, label %23
37: ; preds = %27
%38 = load i64, i64* %1
%39 = sub nsw i64 %38, %24
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i64 %38, i64 %24, i64 %39)
br label %9
41: ; preds = %32, %17
%42 = load i64, i64* %1
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i64 %42)
br label %9
44: ; preds = %9, %5, %0
ret i32 0
}