#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 *);
main() {
  int num, cont;
  cont = 0;
  printf("Num..: ");
  scanf("%d", &num);
  int i;
  for (i = 1; i <= num; ++i)
    if (num % i == 0)
      cont++;
  if (cont <= 2)
    printf("\n Primo!\n");
  else
    printf("Nao e primo!\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1191 <main+0x71>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    117e <main+0x5e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1183 <main+0x63>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <main+0x39>
cmpl   $0x2,-0xc(%rbp)
jg     11ac <main+0x8c>
lea    0xe69(%rip),%rdi
call   1030 <printf@plt>
jmp    11b8 <main+0x98>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r9d
test   %r9d,%r9d
jle    1167 <main+0x37>
cmp    $0x1,%r9d
jne    1170 <main+0x40>
xor    %esi,%esi
mov    $0x1,%edi
jmp    11a3 <main+0x73>
lea    0xeaa(%rip),%rdi
jmp    11ca <main+0x9a>
mov    %r9d,%r8d
and    $0xfffffffe,%r8d
xor    %esi,%esi
mov    $0x1,%edi
xchg   %ax,%ax
mov    %r9d,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%esi
lea    0x1(%rdi),%ecx
mov    %r9d,%eax
cltd
idiv   %ecx
cmp    $0x1,%edx
adc    $0x0,%esi
add    $0x2,%edi
cmp    %r8d,%ecx
jne    1180 <main+0x50>
test   $0x1,%r9b
je     11b5 <main+0x85>
mov    %r9d,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%esi
cmp    $0x3,%esi
lea    0xe59(%rip),%rax
lea    0xe45(%rip),%rdi
cmovb  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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