#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__ floor(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sqrt(double);
void band() {
  int i, j, num;
  int p, q, flagp, flagq;
  printf("Place input a even number: ");
  scanf("%d", &num);
  if (((num % 2) != 0) || (num <= 4))
    printf("data error \n");
  else {
    p = 1;
    do {
      p = p + 1;
      q = num - p;
      flagp = 1;
      flagq = 1;
      for (i = 2; i <= (int)(floor(sqrt((double)(p)))); i++) {
        if ((p % i) == 0) {
          flagp = 0;
          break;
        }
      }
      j = 2;
      while (j <= (int)(floor(sqrt((double)(q))))) {
        if ((q % j) == 0) {
          flagq = 0;
          break;
        }
        j++;
      }
    } while (flagp * flagq == 0);
    printf("%d = %d + %d \n", num, p, q);
  }
}


x86 assembly (clang, -O0):
<band>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1184 <band+0x44>
cmpl   $0x4,-0xc(%rbp)
jg     1197 <band+0x57>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129b <band+0x15b>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x20(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1060 <floor@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jg     1219 <band+0xd9>
mov    -0x10(%rbp),%eax
cltd
idivl  -0x4(%rbp)
cmp    $0x0,%edx
jne    1206 <band+0xc6>
movl   $0x0,-0x18(%rbp)
jmp    1219 <band+0xd9>
jmp    120b <band+0xcb>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c5 <band+0x85>
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%edi
call   1060 <floor@plt>
mov    %rax,%rcx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     126f <band+0x12f>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cmp    $0x0,%edx
jne    1261 <band+0x121>
movl   $0x0,-0x1c(%rbp)
jmp    126f <band+0x12f>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1220 <band+0xe0>
jmp    1274 <band+0x134>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cmp    $0x0,%eax
je     119e <band+0x5e>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<band>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe9f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x5,%esi
jl     1281 <band+0x131>
mov    %esi,%eax
and    $0x1,%eax
jne    1281 <band+0x131>
mov    $0x1,%r14d
jmp    11b1 <band+0x61>
nopl   0x0(%rax)
xor    %ecx,%ecx
imul   %ebx,%ecx
mov    0xc(%rsp),%esi
test   %ecx,%ecx
jne    128f <band+0x13f>
add    $0x1,%r14d
mov    %esi,%r15d
sub    %r14d,%r15d
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    $0x1,%ebx
cmp    $0x2,%eax
jl     121b <band+0xcb>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
xor    %ebx,%ebx
mov    %r14d,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
je     121b <band+0xcb>
movsd  0x10(%rsp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
cmp    %eax,%ebp
jl     11f0 <band+0xa0>
mov    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
mov    $0x1,%ecx
cmp    $0x2,%eax
jl     11a2 <band+0x52>
mov    $0x1,%ebp
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %r15d,%eax
cltd
idiv   %ebp
test   %edx,%edx
je     11a0 <band+0x50>
movsd  0x10(%rsp),%xmm0
call   1060 <sqrt@plt>
mov    %eax,%edi
call   1070 <floor@plt>
cmp    %eax,%ebp
jl     1250 <band+0x100>
mov    $0x1,%ecx
jmp    11a2 <band+0x52>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
jmp    12a3 <band+0x153>
lea    0xd89(%rip),%rdi
mov    %r14d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Place input a even number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"data error \0A\00"
@.str.3 = [15 x i8] c"%d = %d + %d \0A\00"
define void @band() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp sle i32 %14, 4
br i1 %15, label %16, label %18
16: ; preds = %13, %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %72
18: ; preds = %13
store i32 1, i32* %4
br label %19
19: ; preds = %62, %18
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = sub nsw i32 %22, %23
store i32 %24, i32* %5
store i32 1, i32* %6
store i32 1, i32* %7
store i32 2, i32* %1
br label %25
25: ; preds = %40, %19
%26 = load i32, i32* %1
%27 = load i32, i32* %4
%28 = sitofp i32 %27 to double
%29 = call i32 @sqrt(double %28)
%30 = call i64 @floor(i32 %29)
%31 = trunc i64 %30 to i32
%32 = icmp sle i32 %26, %31
br i1 %32, label %33, label %43
33: ; preds = %25
%34 = load i32, i32* %4
%35 = load i32, i32* %1
%36 = srem i32 %34, %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 0, i32* %6
br label %43
39: ; preds = %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %1
%42 = add nsw i32 %41, 1
store i32 %42, i32* %1
br label %25
43: ; preds = %38, %25
store i32 2, i32* %2
br label %44
44: ; preds = %58, %43
%45 = load i32, i32* %2
%46 = load i32, i32* %5
%47 = sitofp i32 %46 to double
%48 = call i32 @sqrt(double %47)
%49 = call i64 @floor(i32 %48)
%50 = trunc i64 %49 to i32
%51 = icmp sle i32 %45, %50
br i1 %51, label %52, label %61
52: ; preds = %44
%53 = load i32, i32* %5
%54 = load i32, i32* %2
%55 = srem i32 %53, %54
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
store i32 0, i32* %7
br label %61
58: ; preds = %52
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
store i32 %60, i32* %2
br label %44
61: ; preds = %57, %44
br label %62
62: ; preds = %61
%63 = load i32, i32* %6
%64 = load i32, i32* %7
%65 = mul nsw i32 %63, %64
%66 = icmp eq i32 %65, 0
br i1 %66, label %19, label %67
67: ; preds = %62
%68 = load i32, i32* %3
%69 = load i32, i32* %4
%70 = load i32, i32* %5
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %68, i32 %69, i32 %70)
br label %72
72: ; preds = %67, %16
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Place input a even number: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [15 x i8] c"%d = %d + %d \0A\00"
@str = [12 x i8] c"data error \00"
define void @band() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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 ne i32 %6, 0
%8 = icmp slt i32 %5, 5
%9 = or i1 %8, %7
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %56
12: ; preds = %0, %49
%13 = phi i32 [ %53, %49 ], [ %5, %0 ]
%14 = phi i32 [ %15, %49 ], [ 1, %0 ]
%15 = add nuw nsw i32 %14, 1
%16 = sub nsw i32 %13, %15
%17 = sitofp i32 %15 to double
%18 = call i32 @sqrt(double %17)
%19 = call i64 @floor(i32 %18)
%20 = trunc i64 %19 to i32
%21 = icmp slt i32 %20, 2
br i1 %21, label %32, label %28
22: ; preds = %28
%23 = add nuw nsw i32 %29, 1
%24 = call i32 @sqrt(double %17)
%25 = call i64 @floor(i32 %24)
%26 = trunc i64 %25 to i32
%27 = icmp slt i32 %29, %26
br i1 %27, label %28, label %32
28: ; preds = %12, %22
%29 = phi i32 [ %23, %22 ], [ 2, %12 ]
%30 = urem i32 %15, %29
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %22
32: ; preds = %22, %28, %12
%33 = phi i32 [ 1, %12 ], [ 0, %28 ], [ 1, %22 ]
%34 = sitofp i32 %16 to double
%35 = call i32 @sqrt(double %34)
%36 = call i64 @floor(i32 %35)
%37 = trunc i64 %36 to i32
%38 = icmp slt i32 %37, 2
br i1 %38, label %49, label %45
39: ; preds = %45
%40 = add nuw nsw i32 %46, 1
%41 = call i32 @sqrt(double %34)
%42 = call i64 @floor(i32 %41)
%43 = trunc i64 %42 to i32
%44 = icmp slt i32 %46, %43
br i1 %44, label %45, label %49
45: ; preds = %32, %39
%46 = phi i32 [ %40, %39 ], [ 2, %32 ]
%47 = srem i32 %16, %46
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %39
49: ; preds = %39, %45, %32
%50 = phi i32 [ 1, %32 ], [ 0, %45 ], [ 1, %39 ]
%51 = mul nuw nsw i32 %50, %33
%52 = icmp eq i32 %51, 0
%53 = load i32, i32* %1
br i1 %52, label %12, label %54
54: ; preds = %49
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 %15, i32 %16)
br label %56
56: ; preds = %54, %10
ret void
}