#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x = 0;
  int y = 2;
  int cont = 0;
  int d = 0;
  scanf("%d", &x);
  while (x != 0) {
    if (x == 2) {
      printf("1\n");
    } else {
      while (y < x) {
        d = 1;
        if (x % y == 0) {
          d = 0;
          break;
        }
        y++;
      }
      printf("%d\n", d);
      y = 2;
    }
    scanf("%d", &x);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11f1 <main+0xd1>
cmpl   $0x2,-0x8(%rbp)
jne    1182 <main+0x62>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11dc <main+0xbc>
jmp    1187 <main+0x67>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c4 <main+0xa4>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11b6 <main+0x96>
movl   $0x0,-0x14(%rbp)
jmp    11c4 <main+0xa4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1187 <main+0x67>
mov    -0x14(%rbp),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0xc(%rbp)
lea    0xe1d(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    115b <main+0x3b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xeb5(%rip),%r14
lea    0xc(%rsp),%rbx
lea    0xeb0(%rip),%r15
lea    0xea5(%rip),%r12
xor    %ebp,%ebp
jmp    1178 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ecx
cmp    $0x2,%ecx
je     1170 <main+0x40>
test   %ecx,%ecx
je     11c7 <main+0x97>
cmp    $0x3,%ecx
jl     11b9 <main+0x89>
mov    $0x2,%esi
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     11b7 <main+0x87>
add    $0x1,%esi
cmp    %esi,%ecx
jne    11a0 <main+0x70>
mov    $0x1,%ebp
jmp    11b9 <main+0x89>
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1178 <main+0x48>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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