#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);
int scanf(char *, int *);
int sqrt(int);
int main() {
  int i, j, k, root, n, count = 0;
  while (scanf("%d", &k) == 1) {
    for (i = 1; i <= k; i++) {
      scanf("%d", &n);
      if (n == 1 || n == 0)
        printf("%d nao eh primo\n", n);
      else {
        count = 0;
        root = sqrt(n);
        for (j = 2; j <= root; j++) {
          if (n % j == 0) {
            count = 1;
            break;
          }
        }
        if (count == 1)
          printf("%d nao eh primo\n", n);
        else
          printf("%d eh primo\n", n);
        count = 0;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    124a <main+0x11a>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1245 <main+0x115>
lea    0xe87(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
je     1196 <main+0x66>
cmpl   $0x0,-0x18(%rbp)
jne    11aa <main+0x7a>
mov    -0x18(%rbp),%esi
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
jmp    1232 <main+0x102>
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
call   1050 <sqrt@plt>
mov    %eax,-0x14(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11fe <main+0xce>
mov    -0x18(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11eb <main+0xbb>
movl   $0x1,-0x1c(%rbp)
jmp    11fe <main+0xce>
jmp    11f0 <main+0xc0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c3 <main+0x93>
cmpl   $0x1,-0x1c(%rbp)
jne    121c <main+0xec>
mov    -0x18(%rbp),%esi
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
jmp    122b <main+0xfb>
mov    -0x18(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    1237 <main+0x107>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1166 <main+0x36>
jmp    1146 <main+0x16>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1200 <main+0xd0>
lea    0xea6(%rip),%rbx
mov    %rsp,%r14
lea    0x4(%rsp),%r15
lea    0xe9a(%rip),%r12
lea    0xea4(%rip),%r13
jmp    1190 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
cmp    $0x1,%eax
jne    1200 <main+0xd0>
cmpl   $0x0,(%rsp)
jle    1180 <main+0x50>
mov    $0x1,%ebp
jmp    11b2 <main+0x82>
nopl   (%rax)
mov    %r12,%rdi
call   1030 <printf@plt>
lea    0x1(%rbp),%eax
cmp    (%rsp),%ebp
mov    %eax,%ebp
jge    1180 <main+0x50>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0x1,%esi
jbe    11a0 <main+0x70>
mov    %esi,%edi
call   1050 <sqrt@plt>
mov    0x4(%rsp),%esi
cmp    $0x2,%eax
jl     11fb <main+0xcb>
mov    %eax,%ecx
neg    %ecx
mov    $0x2,%edi
nop
mov    %esi,%eax
cltd
idiv   %edi
test   %edx,%edx
je     11a0 <main+0x70>
lea    (%rcx,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    11e0 <main+0xb0>
mov    %r13,%rdi
jmp    11a3 <main+0x73>
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 = [17 x i8] c"%d nao eh primo\0A\00"
@.str.2 = [13 x i8] c"%d eh primo\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
store i32 0, i32* %7
br label %8
8: ; preds = %57, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %58
11: ; preds = %8
store i32 1, i32* %2
br label %12
12: ; preds = %54, %11
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %57
16: ; preds = %12
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%18 = load i32, i32* %6
%19 = icmp eq i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = load i32, i32* %6
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20, %16
%24 = load i32, i32* %6
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %53
26: ; preds = %20
store i32 0, i32* %7
%27 = load i32, i32* %6
%28 = call i32 @sqrt(i32 %27)
store i32 %28, i32* %5
store i32 2, i32* %3
br label %29
29: ; preds = %40, %26
%30 = load i32, i32* %3
%31 = load i32, i32* %5
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i32, i32* %6
%35 = load i32, i32* %3
%36 = srem i32 %34, %35
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %33
store i32 1, i32* %7
br label %43
39: ; preds = %33
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %29
43: ; preds = %38, %29
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* %6
%48 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %47)
br label %52
49: ; preds = %43
%50 = load i32, i32* %6
%51 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %49, %46
store i32 0, i32* %7
br label %53
53: ; preds = %52, %23
br label %54
54: ; preds = %53
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %12
57: ; preds = %12
br label %8
58: ; preds = %8
%59 = load i32, i32* %1
ret i32 %59
}

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