#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 num, i, divisores, n, primos = 0;
  printf("Entre com um n\243mero");
  scanf("%d", &n);
  for (num = 1; num <= n; num++) {
    divisores = 0;
    for (i = 2; i <= num / 2; i++) {
      if (num % i == 0) {
        divisores++;
        break;
      }
    }
    if (divisores == 0 && num != 1)
      primos++;
  }
  printf("possui %d primos", primos);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     11f4 <main+0xd4>
movl   $0x0,-0x10(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     11c4 <main+0xa4>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11b1 <main+0x91>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c4 <main+0xa4>
jmp    11b6 <main+0x96>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1175 <main+0x55>
cmpl   $0x0,-0x10(%rbp)
jne    11e1 <main+0xc1>
cmpl   $0x1,-0x8(%rbp)
je     11e1 <main+0xc1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <main+0xc6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    115b <main+0x3b>
mov    -0x18(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%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    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%r8d
test   %r8d,%r8d
jle    11ba <main+0x9a>
mov    $0x1,%ecx
xor    %r14d,%r14d
jmp    117a <main+0x5a>
xchg   %ax,%ax
xor    %eax,%eax
cmp    $0x1,%ecx
setne  %dl
and    %al,%dl
movzbl %dl,%eax
add    %eax,%r14d
lea    0x1(%rcx),%eax
cmp    %r8d,%ecx
mov    %eax,%ecx
je     11ba <main+0x9a>
mov    %ecx,%edi
shr    %edi
cmp    $0x3,%edi
mov    $0x2,%esi
cmovae %edi,%esi
mov    $0x1,%al
cmp    $0x4,%ecx
jb     1162 <main+0x42>
test   $0x1,%cl
je     1160 <main+0x40>
mov    $0x2,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%ebx
cmp    %ebp,%esi
je     11b3 <main+0x93>
lea    0x1(%rbx),%ebp
mov    %ecx,%eax
xor    %edx,%edx
div    %ebp
test   %edx,%edx
jne    11a0 <main+0x80>
cmp    %edi,%ebx
setae  %al
jmp    1162 <main+0x42>
lea    0xe56(%rip),%rdi
mov    %r14d,%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 = [20 x i8] c"Entre com um n\A3mero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"possui %d primos\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
store i32 1, i32* %2
br label %9
9: ; preds = %41, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %5
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %44
13: ; preds = %9
store i32 0, i32* %4
store i32 2, i32* %3
br label %14
14: ; preds = %28, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 2
%18 = icmp sle i32 %15, %17
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = srem i32 %20, %21
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %31
27: ; preds = %19
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %14
31: ; preds = %24, %14
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i32, i32* %2
%36 = icmp ne i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
br label %40
40: ; preds = %37, %34, %31
br label %41
41: ; preds = %40
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %9
44: ; preds = %9
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Entre com um n\A3mero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"possui %d primos\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 slt i32 %5, 1
br i1 %6, label %33, label %7
7: ; preds = %0, %25
%8 = phi i32 [ %30, %25 ], [ 0, %0 ]
%9 = phi i32 [ %31, %25 ], [ 1, %0 ]
%10 = lshr i32 %9, 1
%11 = call i32 @llvm.umax.i32(i32 %10, i32 2)
%12 = icmp ult i32 %9, 4
br i1 %12, label %25, label %13
13: ; preds = %7
%14 = and i32 %9, 1
%15 = icmp eq i32 %14, 0
br i1 %15, label %25, label %16
16: ; preds = %13, %20
%17 = phi i32 [ %18, %20 ], [ 2, %13 ]
%18 = add nuw nsw i32 %17, 1
%19 = icmp eq i32 %17, %11
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = urem i32 %9, %18
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %16
23: ; preds = %16, %20
%24 = icmp uge i32 %17, %10
br label %25
25: ; preds = %23, %13, %7
%26 = phi i1 [ true, %7 ], [ false, %13 ], [ %24, %23 ]
%27 = icmp ne i32 %9, 1
%28 = and i1 %27, %26
%29 = zext i1 %28 to i32
%30 = add nuw nsw i32 %8, %29
%31 = add nuw i32 %9, 1
%32 = icmp eq i32 %9, %5
br i1 %32, label %33, label %7
33: ; preds = %25, %0
%34 = phi i32 [ 0, %0 ], [ %30, %25 ]
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret i32 0
}