#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 Sieve(int, int *, int *);
int *calloc(int, int);
int *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ scanf(char *, int *);
int main(void) {
  int i, n, t, d;
  int *prime = malloc(79000 * sizeof(int));
  int *arr = calloc(1000000 + 1, sizeof(int));
  d = Sieve(1000000, arr, prime);
  while (scanf("%d", &n) && n != 0) {
    for (i = 0; i < d; i++) {
      t = n - prime[i];
      if (!(arr[t])) {
        printf("%d = %d + %d\n", n, prime[i], t);
        break;
      }
    }
    if (i == d)
      printf("Goldbach's conjecture is wrong.\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4d260,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    $0xf4241,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0xf4240,%edi
call   1030 <Sieve@plt>
mov    %eax,-0x14(%rbp)
lea    0xe64(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     11c1 <main+0x71>
cmpl   $0x0,-0xc(%rbp)
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11d1 <main+0x81>
jmp    125d <main+0x10d>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123e <main+0xee>
mov    -0xc(%rbp),%eax
mov    -0x20(%rbp),%rcx
movslq -0x8(%rbp),%rdx
sub    (%rcx,%rdx,4),%eax
mov    %eax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    122b <main+0xdb>
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%ecx
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123e <main+0xee>
jmp    1230 <main+0xe0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <main+0x88>
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1258 <main+0x108>
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1195 <main+0x45>
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
mov    $0x4d260,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0xf4241,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,%rbx
mov    $0xf4240,%edi
mov    %rax,%rsi
mov    %r14,%rdx
call   1030 <Sieve@plt>
mov    %eax,%ebp
lea    0xe5d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
test   %rax,%rax
je     123b <main+0xdb>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     123b <main+0xdb>
mov    %ebp,%r12d
lea    0x4(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    $0x0,%r13d
test   %ebp,%ebp
jle    120e <main+0xae>
xor    %r13d,%r13d
nopl   (%rax)
mov    (%r14,%r13,4),%edx
mov    %esi,%ecx
sub    %edx,%ecx
movslq %ecx,%rax
cmpl   $0x0,(%rbx,%rax,4)
je     1200 <main+0xa0>
add    $0x1,%r13
cmp    %r13,%r12
jne    11e0 <main+0x80>
jmp    1213 <main+0xb3>
nopl   0x0(%rax)
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    %ebp,%r13d
jne    121f <main+0xbf>
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
lea    0xdda(%rip),%rdi
mov    %r15,%rsi
call   1080 <scanf@plt>
test   %rax,%rax
je     123b <main+0xdb>
mov    0x4(%rsp),%esi
test   %esi,%esi
jne    11d0 <main+0x70>
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 = [14 x i8] c"%d = %d + %d\0A\00"
@.str.2 = [33 x i8] c"Goldbach's conjecture is wrong.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32* @malloc(i32 316000)
store i32* %8, i32** %6
%9 = call i32* @calloc(i32 1000001, i32 4)
store i32* %9, i32** %7
%10 = load i32*, i32** %7
%11 = load i32*, i32** %6
%12 = call i32 @Sieve(i32 1000000, i32* %10, i32* %11)
store i32 %12, i32* %5
br label %13
13: ; preds = %59, %0
%14 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br label %19
19: ; preds = %16, %13
%20 = phi i1 [ false, %13 ], [ %18, %16 ]
br i1 %20, label %21, label %60
21: ; preds = %19
store i32 0, i32* %2
br label %22
22: ; preds = %50, %21
%23 = load i32, i32* %2
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %53
26: ; preds = %22
%27 = load i32, i32* %3
%28 = load i32*, i32** %6
%29 = load i32, i32* %2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = sub nsw i32 %27, %32
store i32 %33, i32* %4
%34 = load i32*, i32** %7
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %49, label %40
40: ; preds = %26
%41 = load i32, i32* %3
%42 = load i32*, i32** %6
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
%46 = load i32, i32* %45
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %46, i32 %47)
br label %53
49: ; preds = %26
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %22
53: ; preds = %40, %22
%54 = load i32, i32* %2
%55 = load i32, i32* %5
%56 = icmp eq i32 %54, %55
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %59
59: ; preds = %57, %53
br label %13
60: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [14 x i8] c"%d = %d + %d\0A\00"
@str = [32 x i8] c"Goldbach's conjecture is wrong.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @malloc(i32 316000)
%4 = tail call i32* @calloc(i32 1000001, i32 4)
%5 = tail call i32 @Sieve(i32 1000000, i32* %4, i32* %3)
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = icmp ne i64 %6, 0
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
br i1 %10, label %11, label %42
11: ; preds = %0
%12 = icmp sgt i32 %5, 0
%13 = zext i32 %5 to i64
br label %14
14: ; preds = %11, %36
%15 = phi i32 [ %8, %11 ], [ %39, %36 ]
br i1 %12, label %16, label %31
16: ; preds = %14, %28
%17 = phi i64 [ %29, %28 ], [ 0, %14 ]
%18 = getelementptr inbounds i32, i32* %3, i64 %17
%19 = load i32, i32* %18
%20 = sub nsw i32 %15, %19
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %4, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %16
%26 = trunc i64 %17 to i32
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %19, i32 %20)
br label %31
28: ; preds = %16
%29 = add nuw nsw i64 %17, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %34, label %16
31: ; preds = %14, %25
%32 = phi i32 [ %26, %25 ], [ 0, %14 ]
%33 = icmp eq i32 %32, %5
br i1 %33, label %34, label %36
34: ; preds = %28, %31
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%38 = icmp ne i64 %37, 0
%39 = load i32, i32* %1
%40 = icmp ne i32 %39, 0
%41 = select i1 %38, i1 %40, i1 false
br i1 %41, label %14, label %42
42: ; preds = %36, %0
ret i32 0
}