#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__ is_prime(int);
int next(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (!n)
      break;
    if (is_prime(n))
      printf("%d\n", next(1 + (n << 1)));
    else
      printf("%d (%d is not prime)\n", next(1 + (n << 1)), n);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    116e <main+0x2e>
jmp    11c9 <main+0x89>
mov    -0x8(%rbp),%edi
call   1050 <is_prime@plt>
cmp    $0x0,%rax
je     11a3 <main+0x63>
mov    -0x8(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <next@plt>
mov    %eax,%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c4 <main+0x84>
mov    -0x8(%rbp),%edi
shl    $0x1,%edi
add    $0x1,%edi
call   1040 <next@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114f <main+0xf>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
je     11dd <main+0x9d>
lea    0xe9a(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0xc(%rsp),%r13
lea    0xe83(%rip),%r12
jmp    11b3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
je     11dd <main+0x9d>
call   1050 <is_prime@plt>
mov    %rax,%rbx
mov    0xc(%rsp),%eax
lea    (%rax,%rax,1),%edi
add    $0x1,%edi
call   1040 <next@plt>
test   %rbx,%rbx
je     1190 <main+0x50>
mov    %r12,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [22 x i8] c"%d (%d is not prime)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
br label %3
3: ; preds = %0, %25
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %3
br label %26
8: ; preds = %3
%9 = load i32, i32* %2
%10 = call i64 @is_prime(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i32, i32* %2
%14 = shl i32 %13, 1
%15 = add nsw i32 1, %14
%16 = call i32 @next(i32 %15)
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %25
18: ; preds = %8
%19 = load i32, i32* %2
%20 = shl i32 %19, 1
%21 = add nsw i32 1, %20
%22 = call i32 @next(i32 %21)
%23 = load i32, i32* %2
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %23)
br label %25
25: ; preds = %18, %12
br label %3
26: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [22 x i8] c"%d (%d is not prime)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp eq i32 %4, 0
br i1 %5, label %23, label %6
6: ; preds = %0, %19
%7 = phi i32 [ %21, %19 ], [ %4, %0 ]
%8 = call i64 @is_prime(i32 %7)
%9 = icmp eq i64 %8, 0
%10 = load i32, i32* %1
%11 = shl i32 %10, 1
%12 = or i32 %11, 1
%13 = call i32 @next(i32 %12)
br i1 %9, label %16, label %14
14: ; preds = %6
%15 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %19
16: ; preds = %6
%17 = load i32, i32* %1
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %17)
br label %19
19: ; preds = %14, %16
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %6
23: ; preds = %19, %0
ret i32 0
}