#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 /*<<< orphan*/ system(char *);
int main() {
  int numero, mod1, i;
  printf("Digite um numero: ");
  scanf("%d", &numero);
  if (numero > 1) {
    for (i = 1; i <= numero; i++) {
      if (numero % i == 0) {
        mod1++;
      }
    }
    if (mod1 == 2) {
      printf("o numero eh primo\n");
      system("pause");
    } else {
      printf("o numero nao eh primo\n");
      system("pause");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11e8 <main+0xb8>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a4 <main+0x74>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1191 <main+0x61>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1196 <main+0x66>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116c <main+0x3c>
cmpl   $0x2,-0xc(%rbp)
jne    11cb <main+0x9b>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
lea    0xe68(%rip),%rdi
call   1030 <system@plt>
jmp    11e3 <main+0xb3>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4b(%rip),%rdi
call   1030 <system@plt>
jmp    11e8 <main+0xb8>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xeb8(%rip),%rdi
call   1050 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%r9d
cmp    $0x2,%r9d
jl     11db <main+0x9b>
mov    %r9d,%r8d
and    $0xfffffffe,%r8d
mov    $0x1,%edi
cs nopw 0x0(%rax,%rax,1)
nop
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+0x40>
test   $0x1,%r9b
je     11b5 <main+0x75>
mov    %r9d,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%esi
cmp    $0x2,%esi
lea    0xe73(%rip),%rax
lea    0xe56(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
lea    0xe40(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"o numero eh primo\0A\00"
@.str.3 = [6 x i8] c"pause\00"
@.str.4 = [23 x i8] c"o numero nao 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 @printf(i8* getelementptr inbounds ([19 x i8], [19 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)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %36
9: ; preds = %0
store i32 1, i32* %4
br label %10
10: ; preds = %23, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %2
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %4
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
br label %22
22: ; preds = %19, %14
br label %23
23: ; preds = %22
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %10
26: ; preds = %10
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %35
32: ; preds = %26
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %0
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str = [19 x i8] c"Digite um numero: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [6 x i8] c"pause\00"
@str = [22 x i8] c"o numero nao eh primo\00"
@str.5 = [18 x i8] c"o numero eh primo\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 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 %39
7: ; preds = %0
%8 = and i32 %5, 1
%9 = and i32 %5, -2
br label %10
10: ; preds = %10, %7
%11 = phi i32 [ 1, %7 ], [ %23, %10 ]
%12 = phi i32 [ undef, %7 ], [ %22, %10 ]
%13 = phi i32 [ 0, %7 ], [ %24, %10 ]
%14 = srem i32 %5, %11
%15 = icmp eq i32 %14, 0
%16 = zext i1 %15 to i32
%17 = add nsw i32 %12, %16
%18 = add nuw nsw i32 %11, 1
%19 = srem i32 %5, %18
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = add nsw i32 %17, %21
%23 = add nuw nsw i32 %11, 2
%24 = add nuw nsw i32 %13, 2
%25 = icmp eq i32 %24, %9
br i1 %25, label %26, label %10
26: ; preds = %10
%27 = icmp eq i32 %8, 0
br i1 %27, label %33, label %28
28: ; preds = %26
%29 = srem i32 %5, %23
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = add nsw i32 %22, %31
br label %33
33: ; preds = %26, %28
%34 = phi i32 [ %22, %26 ], [ %32, %28 ]
%35 = icmp eq i32 %34, 2
%36 = select i1 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0)
%37 = call i32 @puts(i8* dereferenceable(1) %36)
%38 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %39
39: ; preds = %33, %0
ret i32 0
}