#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 */
scalar_t__ check_prime(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
void main() {
  int number, answer1, answer2;
  printf("Enter a number:");
  scanf("%d", &number);
  if (number % 2 == 0 && number >= 2) {
    answer1 = number / 2;
    if (check_prime(answer1)) {
      printf("2 + %d = %d\n", answer1, number);
    } else {
      answer2 = answer1;
      while (!check_prime(answer1) || !check_prime(answer2)) {
        answer1 -= 1;
        answer2 += 1;
      }
      printf("%d + %d = %d\n", answer1, answer2, number);
    }
  } else {
    printf("Invalid number!\n");
  }
  system("pause");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1234 <main+0xf4>
cmpl   $0x2,-0x4(%rbp)
jl     1234 <main+0xf4>
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%rax
je     11bd <main+0x7d>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    122f <main+0xef>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <check_prime@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0xd(%rbp)
je     11f1 <main+0xb1>
mov    -0xc(%rbp),%edi
call   1030 <check_prime@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
test   $0x1,%al
jne    1201 <main+0xc1>
jmp    1218 <main+0xd8>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c3 <main+0x83>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1242 <main+0x102>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdf6(%rip),%rdi
call   1040 <system@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%ebx
cmp    $0x2,%ebx
jl     11a6 <main+0x56>
mov    %ebx,%eax
and    $0x1,%eax
jne    11a6 <main+0x56>
shr    %ebx
mov    %ebx,%edi
call   1030 <check_prime@plt>
test   %rax,%rax
je     11b4 <main+0x64>
mov    0x4(%rsp),%edx
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11f4 <main+0xa4>
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
jmp    11f4 <main+0xa4>
mov    %ebx,%ebp
jmp    11c6 <main+0x76>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
add    $0x1,%ebp
mov    %ebx,%edi
call   1030 <check_prime@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    %ebp,%edi
call   1030 <check_prime@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    0x4(%rsp),%ecx
lea    0xe37(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe33(%rip),%rdi
call   1050 <system@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"2 + %d = %d\0A\00"
@.str.3 = [14 x i8] c"%d + %d = %d\0A\00"
@.str.4 = [17 x i8] c"Invalid number!\0A\00"
@.str.5 = [6 x i8] c"pause\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = srem i32 %6, 2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %46
9: ; preds = %0
%10 = load i32, i32* %1
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %46
12: ; preds = %9
%13 = load i32, i32* %1
%14 = sdiv i32 %13, 2
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = call i64 @check_prime(i32 %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %12
%19 = load i32, i32* %2
%20 = load i32, i32* %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20)
br label %45
22: ; preds = %12
%23 = load i32, i32* %2
store i32 %23, i32* %3
br label %24
24: ; preds = %35, %22
%25 = load i32, i32* %2
%26 = call i64 @check_prime(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* %3
%30 = call i64 @check_prime(i32 %29)
%31 = icmp ne i64 %30, 0
%32 = xor i1 %31, true
br label %33
33: ; preds = %28, %24
%34 = phi i1 [ true, %24 ], [ %32, %28 ]
br i1 %34, label %35, label %40
35: ; preds = %33
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, 1
store i32 %37, i32* %2
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %24
40: ; preds = %33
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = load i32, i32* %1
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
br label %45
45: ; preds = %40, %18
br label %48
46: ; preds = %9, %0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %46, %45
%49 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter a number:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"2 + %d = %d\0A\00"
@.str.3 = [14 x i8] c"%d + %d = %d\0A\00"
@.str.5 = [6 x i8] c"pause\00"
@str = [16 x i8] c"Invalid number!\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = and i32 %5, 1
%7 = icmp eq i32 %6, 0
%8 = icmp sgt i32 %5, 1
%9 = and i1 %8, %7
br i1 %9, label %10, label %31
10: ; preds = %0
%11 = lshr i32 %5, 1
%12 = call i64 @check_prime(i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i32, i32* %1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %15)
br label %33
17: ; preds = %10, %25
%18 = phi i32 [ %26, %25 ], [ %11, %10 ]
%19 = phi i32 [ %27, %25 ], [ %11, %10 ]
%20 = call i64 @check_prime(i32 %18)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = call i64 @check_prime(i32 %19)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17, %22
%26 = add nsw i32 %18, -1
%27 = add nuw nsw i32 %19, 1
br label %17
28: ; preds = %22
%29 = load i32, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %19, i32 %29)
br label %33
31: ; preds = %0
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %33
33: ; preds = %14, %28, %31
%34 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret void
}