#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 numero, i, controle = 0;
  printf("Informe um numero: ");
  scanf("%d", &numero);
  if (numero > 1) {
    for (i = 1; i <= numero; i++) {
      if (numero % i == 0)
        controle++;
    }
    if (controle == 2) {
      printf("O numero %d e um numero primo!\n", numero);
    } else {
      printf("O numero %d nao e um numero primo!\n", numero);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    11d3 <main+0xb3>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     119d <main+0x7d>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    118a <main+0x6a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118f <main+0x6f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x45>
cmpl   $0x2,-0x10(%rbp)
jne    11bd <main+0x9d>
mov    -0x8(%rbp),%esi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <main+0xae>
mov    -0x8(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <main+0xb3>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%esi
cmp    $0x2,%esi
jl     11ae <main+0x8e>
mov    %esi,%r8d
and    $0xfffffffe,%r8d
mov    $0x1,%ecx
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ecx
cmp    $0x1,%edx
adc    $0x0,%ebx
lea    0x1(%rcx),%edi
mov    %esi,%eax
cltd
idiv   %edi
cmp    $0x1,%edx
adc    $0x0,%ebx
add    $0x2,%ecx
cmp    %r8d,%edi
jne    1160 <main+0x40>
test   $0x1,%sil
je     1192 <main+0x72>
mov    %esi,%eax
cltd
idiv   %ecx
cmp    $0x1,%edx
adc    $0x0,%ebx
cmp    $0x2,%ebx
lea    0xe7b(%rip),%rax
lea    0xe94(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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