#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, divisor, eprimo, ini, fim;
  int numprimos = 0;
  printf("Entre com o numero inicial: ");
  scanf("%d", &ini);
  printf("Entre com o numero final: ");
  scanf("%d", &fim);
  for (num = ini; num <= fim; num++) {
    eprimo = 1;
    divisor = 2;
    while ((divisor <= (num - 1)) && eprimo) {
      if ((num % divisor) == 0)
        eprimo = 0;
      divisor++;
    }
    if (eprimo) {
      printf("Numero %d e primo\n", num);
      numprimos++;
    }
  }
  if (numprimos > 0)
    printf("Total de primos = %d", numprimos);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf12(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     121e <main+0xfe>
movl   $0x1,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x1d(%rbp)
jg     11b2 <main+0x92>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11c2 <main+0xa2>
jmp    11e7 <main+0xc7>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11d9 <main+0xb9>
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <main+0x72>
cmpl   $0x0,-0x10(%rbp)
je     120b <main+0xeb>
mov    -0x8(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1210 <main+0xf0>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1178 <main+0x58>
cmpl   $0x0,-0x1c(%rbp)
jle    1239 <main+0x119>
mov    -0x1c(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf20(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ebx
mov    0x8(%rsp),%ecx
cmp    %ecx,%ebx
jg     11dd <main+0xbd>
lea    0xec0(%rip),%r14
xor    %ebp,%ebp
jmp    119c <main+0x7c>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%ecx
lea    0x1(%rbx),%eax
cmp    %ecx,%ebx
mov    %eax,%ebx
jge    11c9 <main+0xa9>
cmp    $0x3,%ebx
jl     1180 <main+0x60>
mov    $0x3,%esi
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rsi),%edi
mov    %ebx,%eax
cltd
idiv   %edi
cmp    %ebx,%esi
jge    11c3 <main+0xa3>
add    $0x1,%esi
test   %edx,%edx
jne    11b0 <main+0x90>
test   %edx,%edx
jne    1180 <main+0x60>
jmp    1193 <main+0x73>
test   %ebp,%ebp
jle    11dd <main+0xbd>
lea    0xe77(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Entre com o numero inicial: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [27 x i8] c"Entre com o numero final: \00"
@.str.3 = [19 x i8] c"Numero %d e primo\0A\00"
@.str.4 = [21 x i8] c"Total de primos = %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %7
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %5
store i32 %12, i32* %2
br label %13
13: ; preds = %46, %0
%14 = load i32, i32* %2
%15 = load i32, i32* %6
%16 = icmp sle i32 %14, %15
br i1 %16, label %17, label %49
17: ; preds = %13
store i32 1, i32* %4
store i32 2, i32* %3
br label %18
18: ; preds = %34, %17
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = sub nsw i32 %20, 1
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 0
br label %26
26: ; preds = %23, %18
%27 = phi i1 [ false, %18 ], [ %25, %23 ]
br i1 %27, label %28, label %37
28: ; preds = %26
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = srem i32 %29, %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 0, i32* %4
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %18
37: ; preds = %26
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i32, i32* %2
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
br label %45
45: ; preds = %40, %37
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add nsw i32 %47, 1
store i32 %48, i32* %2
br label %13
49: ; preds = %13
%50 = load i32, i32* %7
%51 = icmp sgt i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %49
%53 = load i32, i32* %7
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %52, %49
%56 = load i32, i32* %1
ret i32 %56
}

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