#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 n;
  printf("Digite um numero para saber se eh primo: \n");
  scanf("%d", &n);
  int divisivel = 0;
  for (int i = n; i > 1; i--) {
    if (n % i == 0) {
      divisivel++;
      if (divisivel == 2) {
        printf("o numero %i não eh primo \n", n);
        return 0;
      }
    }
  }
  printf("o numero %i eh primo \n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jle    11bc <main+0x9c>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11a9 <main+0x89>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    11a4 <main+0x84>
mov    -0x8(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11cd <main+0xad>
jmp    11a9 <main+0x89>
jmp    11ae <main+0x8e>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    115a <main+0x3a>
mov    -0x8(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%r9d
lea    0xec5(%rip),%rdi
cmp    $0x2,%r9d
jl     1191 <main+0x61>
xor    %ecx,%ecx
lea    0xe9a(%rip),%r8
mov    %r9d,%esi
jmp    117a <main+0x4a>
xchg   %ax,%ax
lea    -0x1(%rsi),%eax
cmp    $0x2,%esi
mov    %eax,%esi
jle    1191 <main+0x61>
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
jne    1170 <main+0x40>
cmp    $0x1,%ecx
mov    $0x1,%ecx
jne    1170 <main+0x40>
mov    %r8,%rdi
mov    %r9d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Digite um numero para saber se eh primo: \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"o numero %i n\C3\A3o eh primo \0A\00"
@.str.3 = [23 x i8] c"o numero %i eh primo \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 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 0, i32* %3
%7 = load i32, i32* %2
store i32 %7, i32* %4
br label %8
8: ; preds = %26, %0
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %29
11: ; preds = %8
%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 %25
16: ; preds = %11
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, 2
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %22)
store i32 0, i32* %1
br label %32
24: ; preds = %16
br label %25
25: ; preds = %24, %11
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, -1
store i32 %28, i32* %4
br label %8
29: ; preds = %8
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29, %21
%33 = load i32, i32* %1
ret i32 %33
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"o numero %i n\C3\A3o eh primo \0A\00"
@.str.3 = [23 x i8] c"o numero %i eh primo \0A\00"
@str = [42 x i8] c"Digite um numero para saber se eh primo: \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 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 sgt i32 %5, 1
br i1 %6, label %7, label %18
7: ; preds = %0, %14
%8 = phi i32 [ %16, %14 ], [ %5, %0 ]
%9 = phi i32 [ %15, %14 ], [ 0, %0 ]
%10 = srem i32 %5, %8
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = icmp eq i32 %9, 1
br i1 %13, label %18, label %14
14: ; preds = %7, %12
%15 = phi i32 [ 1, %12 ], [ %9, %7 ]
%16 = add nsw i32 %8, -1
%17 = icmp sgt i32 %8, 2
br i1 %17, label %7, label %18
18: ; preds = %14, %12, %0
%19 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), %14 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %19, i32 %5)
ret i32 0
}