#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*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
char verifica_primo(int, int);
int ler_primo(int max) {
  int numero;
  char cond;
  do {
    cond = 'P';
    scanf("%d", &numero);
    getchar();
    if (verifica_primo(numero, 2) == 'N')
      printf("\nO numero fornecido nao e primo!");
    if (numero < 2 || numero > max) {
      printf("\nO numero fornecido nao pertence ao intervalo estabelecido!");
      cond = 'N';
    }
    if ((verifica_primo(numero, 2) != 'P') || cond == 'N')
      printf("\nDigite novamente!\n");
  } while ((verifica_primo(numero, 2) != 'P') || cond == 'N');
  return numero;
}


x86 assembly (clang, -O0):
<ler_primo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x50,-0x9(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <verifica_primo@plt>
movsbl %al,%eax
cmp    $0x4e,%eax
jne    118b <ler_primo+0x4b>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x2,-0x8(%rbp)
jl     11a1 <ler_primo+0x61>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jle    11b1 <ler_primo+0x71>
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
movb   $0x4e,-0x9(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <verifica_primo@plt>
movsbl %al,%eax
cmp    $0x50,%eax
jne    11d7 <ler_primo+0x97>
movsbl -0x9(%rbp),%eax
cmp    $0x4e,%eax
jne    11e3 <ler_primo+0xa3>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11e8 <ler_primo+0xa8>
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1040 <verifica_primo@plt>
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x50,%ecx
mov    %al,-0xa(%rbp)
jne    1213 <ler_primo+0xd3>
movsbl -0x9(%rbp),%eax
cmp    $0x4e,%eax
sete   %al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
test   $0x1,%al
jne    114b <ler_primo+0xb>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ler_primo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xe9c(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xeb4(%rip),%r13
lea    0xee9(%rip),%rbp
jmp    11b6 <ler_primo+0x66>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1050 <verifica_primo@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1050 <verifica_primo@plt>
cmp    $0x50,%al
setne  %al
or     %al,%r12b
je     121d <ler_primo+0xcd>
mov    %r14,%rdi
mov    %r15,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1050 <verifica_primo@plt>
cmp    $0x4e,%al
jne    11e6 <ler_primo+0x96>
lea    0xe22(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
cmp    $0x2,%edi
setl   %al
cmp    %ebx,%edi
setg   %r12b
or     %al,%r12b
cmp    $0x1,%r12b
je     1180 <ler_primo+0x30>
mov    $0x2,%esi
call   1050 <verifica_primo@plt>
cmp    $0x50,%al
sete   %al
mov    %r12d,%ecx
not    %cl
test   %al,%cl
je     1196 <ler_primo+0x46>
jmp    119e <ler_primo+0x4e>
mov    0x4(%rsp),%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 = [33 x i8] c"\0AO numero fornecido nao e primo!\00"
@.str.2 = [60 x i8] c"\0AO numero fornecido nao pertence ao intervalo estabelecido!\00"
@.str.3 = [20 x i8] c"\0ADigite novamente!\0A\00"
define i32 @ler_primo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
store i32 %0, i32* %2
br label %5
5: ; preds = %44, %1
store i8 80, i8* %4
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%7 = call i32 (...) @getchar()
%8 = load i32, i32* %3
%9 = call signext i8 @verifica_primo(i32 %8, i32 2)
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 78
br i1 %11, label %12, label %14
12: ; preds = %5
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %15, 2
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = icmp sgt i32 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17, %14
%22 = call i32 @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
store i8 78, i8* %4
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* %3
%25 = call signext i8 @verifica_primo(i32 %24, i32 2)
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 80
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 78
br i1 %31, label %32, label %34
32: ; preds = %28, %23
%33 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
br label %35
35: ; preds = %34
%36 = load i32, i32* %3
%37 = call signext i8 @verifica_primo(i32 %36, i32 2)
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 80
br i1 %39, label %44, label %40
40: ; preds = %35
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 78
br label %44
44: ; preds = %40, %35
%45 = phi i1 [ true, %35 ], [ %43, %40 ]
br i1 %45, label %5, label %46
46: ; preds = %44
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [33 x i8] c"\0AO numero fornecido nao e primo!\00"
@.str.2 = [60 x i8] c"\0AO numero fornecido nao pertence ao intervalo estabelecido!\00"
@str = [19 x i8] c"\0ADigite novamente!\00"
define i32 @ler_primo(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %27, %1
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = call i32 (...) @getchar()
%7 = load i32, i32* %2
%8 = call signext i8 @verifica_primo(i32 %7, i32 2)
%9 = icmp eq i8 %8, 78
br i1 %9, label %10, label %12
10: ; preds = %4
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %4
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 2
%15 = icmp sgt i32 %13, %0
%16 = or i1 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* %2
%20 = call signext i8 @verifica_primo(i32 %19, i32 2)
br label %25
21: ; preds = %12
%22 = call signext i8 @verifica_primo(i32 %13, i32 2)
%23 = icmp ne i8 %22, 80
%24 = or i1 %16, %23
br i1 %24, label %25, label %27
25: ; preds = %17, %21
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = load i32, i32* %2
%29 = call signext i8 @verifica_primo(i32 %28, i32 2)
%30 = icmp ne i8 %29, 80
%31 = or i1 %16, %30
br i1 %31, label %4, label %32
32: ; preds = %27
%33 = load i32, i32* %2
ret i32 %33
}