#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 */
typedef int /*<<< orphan*/ mpz_t;

/* Variables and functions */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ initarray();
scalar_t__ isprime(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_add_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
scalar_t__ mpz_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ mpz_set_ui(int /*<<< orphan*/, int);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int main(int ac, char *av[]) {
  mpz_t n, min_n, max_n, m1, m2;
  if (ac < 3) {
    printf("usage : gmpgoldbach2 min_n max_n\n");
    return (1);
  }
  mpz_init_set_str(min_n, av[1], 10);
  mpz_init_set_str(max_n, av[2], 10);
  initarray();
  mpz_init_set(n, min_n);
  mpz_init(m1);
  mpz_init(m2);
  while (mpz_cmp(n, max_n) <= 0) {
    mpz_set_ui(m1, 3);
    mpz_sub_ui(m2, n, 3);
    while (mpz_cmp(m1, m2) <= 0) {
      if (isprime(m1) && isprime(m2))
        break;
      mpz_add_ui(m1, m1, 2);
      mpz_sub_ui(m2, m2, 2);
    }
    if (mpz_cmp(m1, m2) > 0)
      gmp_printf("%Zd NG\n", n);
    mpz_add_ui(n, n, 2);
  }
  mpz_clear(max_n);
  mpz_clear(n);
  mpz_clear(m1);
  mpz_clear(m2);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11f8 <main+0x38>
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1339 <main+0x179>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    $0x0,%al
call   1060 <initarray@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   10e0 <mpz_init_set@plt>
mov    -0x20(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x24(%rbp),%edi
call   1070 <mpz_init@plt>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jg     1312 <main+0x152>
mov    -0x20(%rbp),%edi
mov    $0x3,%esi
call   10b0 <mpz_set_ui@plt>
mov    -0x24(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x3,%edx
call   1090 <mpz_sub_ui@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jg     12d9 <main+0x119>
mov    -0x20(%rbp),%edi
call   1080 <isprime@plt>
cmp    $0x0,%rax
je     12b4 <main+0xf4>
mov    -0x24(%rbp),%edi
call   1080 <isprime@plt>
cmp    $0x0,%rax
je     12b4 <main+0xf4>
jmp    12d9 <main+0x119>
mov    -0x20(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    $0x2,%edx
call   1030 <mpz_add_ui@plt>
mov    -0x24(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x2,%edx
call   1090 <mpz_sub_ui@plt>
jmp    1276 <main+0xb6>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10a0 <mpz_cmp@plt>
cmp    $0x0,%rax
jle    12fd <main+0x13d>
mov    -0x14(%rbp),%esi
lea    0xd2a(%rip),%rdi
call   10d0 <gmp_printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    $0x2,%edx
call   1030 <mpz_add_ui@plt>
jmp    1244 <main+0x84>
mov    -0x1c(%rbp),%edi
call   10c0 <mpz_clear@plt>
mov    -0x14(%rbp),%edi
call   10c0 <mpz_clear@plt>
mov    -0x20(%rbp),%edi
call   10c0 <mpz_clear@plt>
mov    -0x24(%rbp),%edi
call   10c0 <mpz_clear@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jg     11db <main+0x1b>
lea    0xe39(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
jmp    1230 <main+0x70>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
mov    0x10(%rbx),%rsi
mov    $0xa,%edx
call   1050 <mpz_init_set_str@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <initarray@plt>
call   10e0 <mpz_init_set@plt>
call   1070 <mpz_init@plt>
call   1070 <mpz_init@plt>
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
jle    1239 <main+0x79>
call   10c0 <mpz_clear@plt>
call   10c0 <mpz_clear@plt>
call   10c0 <mpz_clear@plt>
call   10c0 <mpz_clear@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xdc0(%rip),%rbx
jmp    1264 <main+0xa4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
jg     121c <main+0x5c>
mov    $0x3,%esi
call   10b0 <mpz_set_ui@plt>
mov    $0x3,%edx
jmp    128f <main+0xcf>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2,%edx
call   1040 <mpz_add_ui@plt>
mov    $0x2,%edx
call   1090 <mpz_sub_ui@plt>
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
jg     12c0 <main+0x100>
call   1080 <isprime@plt>
test   %rax,%rax
je     1280 <main+0xc0>
call   1080 <isprime@plt>
test   %rax,%rax
je     1280 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   10a0 <mpz_cmp@plt>
test   %rax,%rax
jle    1250 <main+0x90>
mov    %rbx,%rdi
call   10d0 <gmp_printf@plt>
jmp    1250 <main+0x90>

LLVM IR (-O0):
@.str = [34 x i8] c"usage : gmpgoldbach2 min_n max_n\0A\00"
@.str.1 = [8 x i8] c"%Zd NG\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %87
15: ; preds = %2
%16 = load i32, i32* %7
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @mpz_init_set_str(i32 %16, i8* %19, i32 10)
%21 = load i32, i32* %8
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @mpz_init_set_str(i32 %21, i8* %24, i32 10)
%26 = call i32 (...) @initarray()
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = call i32 @mpz_init_set(i32 %27, i32 %28)
%30 = load i32, i32* %9
%31 = call i32 @mpz_init(i32 %30)
%32 = load i32, i32* %10
%33 = call i32 @mpz_init(i32 %32)
br label %34
34: ; preds = %74, %15
%35 = load i32, i32* %6
%36 = load i32, i32* %8
%37 = call i64 @mpz_cmp(i32 %35, i32 %36)
%38 = icmp sle i64 %37, 0
br i1 %38, label %39, label %78
39: ; preds = %34
%40 = load i32, i32* %9
%41 = call i32 @mpz_set_ui(i32 %40, i32 3)
%42 = load i32, i32* %10
%43 = load i32, i32* %6
%44 = call i32 @mpz_sub_ui(i32 %42, i32 %43, i32 3)
br label %45
45: ; preds = %59, %39
%46 = load i32, i32* %9
%47 = load i32, i32* %10
%48 = call i64 @mpz_cmp(i32 %46, i32 %47)
%49 = icmp sle i64 %48, 0
br i1 %49, label %50, label %66
50: ; preds = %45
%51 = load i32, i32* %9
%52 = call i64 @isprime(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %50
%55 = load i32, i32* %10
%56 = call i64 @isprime(i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
br label %66
59: ; preds = %54, %50
%60 = load i32, i32* %9
%61 = load i32, i32* %9
%62 = call i32 @mpz_add_ui(i32 %60, i32 %61, i32 2)
%63 = load i32, i32* %10
%64 = load i32, i32* %10
%65 = call i32 @mpz_sub_ui(i32 %63, i32 %64, i32 2)
br label %45
66: ; preds = %58, %45
%67 = load i32, i32* %9
%68 = load i32, i32* %10
%69 = call i64 @mpz_cmp(i32 %67, i32 %68)
%70 = icmp sgt i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %66
%72 = load i32, i32* %6
%73 = call i32 @gmp_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %71, %66
%75 = load i32, i32* %6
%76 = load i32, i32* %6
%77 = call i32 @mpz_add_ui(i32 %75, i32 %76, i32 2)
br label %34
78: ; preds = %34
%79 = load i32, i32* %8
%80 = call i32 @mpz_clear(i32 %79)
%81 = load i32, i32* %6
%82 = call i32 @mpz_clear(i32 %81)
%83 = load i32, i32* %9
%84 = call i32 @mpz_clear(i32 %83)
%85 = load i32, i32* %10
%86 = call i32 @mpz_clear(i32 %85)
store i32 0, i32* %3
br label %87
87: ; preds = %78, %13
%88 = load i32, i32* %3
ret i32 %88
}

LLVM IR (-O2):
@.str.1 = [8 x i8] c"%Zd NG\0A\00"
@str = [33 x i8] c"usage : gmpgoldbach2 min_n max_n\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %49
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @mpz_init_set_str(i32 undef, i8* %8, i32 10)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @mpz_init_set_str(i32 undef, i8* %11, i32 10)
%13 = tail call i32 (...) @initarray()
%14 = tail call i32 @mpz_init_set(i32 undef, i32 undef)
%15 = tail call i32 @mpz_init(i32 undef)
%16 = tail call i32 @mpz_init(i32 undef)
%17 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%18 = icmp slt i64 %17, 1
br i1 %18, label %19, label %44
19: ; preds = %6, %40
%20 = tail call i32 @mpz_set_ui(i32 undef, i32 3)
%21 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 3)
%22 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%23 = icmp slt i64 %22, 1
br i1 %23, label %24, label %35
24: ; preds = %19, %30
%25 = tail call i64 @isprime(i32 undef)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i64 @isprime(i32 undef)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27, %24
%31 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 2)
%32 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 2)
%33 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%34 = icmp slt i64 %33, 1
br i1 %34, label %24, label %35
35: ; preds = %30, %27, %19
%36 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%37 = icmp sgt i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 undef)
br label %40
40: ; preds = %38, %35
%41 = tail call i32 @mpz_add_ui(i32 undef, i32 undef, i32 2)
%42 = tail call i64 @mpz_cmp(i32 undef, i32 undef)
%43 = icmp slt i64 %42, 1
br i1 %43, label %19, label %44
44: ; preds = %40, %6
%45 = tail call i32 @mpz_clear(i32 undef)
%46 = tail call i32 @mpz_clear(i32 undef)
%47 = tail call i32 @mpz_clear(i32 undef)
%48 = tail call i32 @mpz_clear(i32 undef)
br label %49
49: ; preds = %44, %4
%50 = phi i32 [ 1, %4 ], [ 0, %44 ]
ret i32 %50
}