#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 i, j = 2, divisores = 0;
  printf("Digite um numero");
  scanf("%d", &i);
  while (j <= i / 2) {
    if (i % j == 0) {
      printf("%d n\306o eh primo", i);
      divisores = 1;
      break;
    } else {
      j++;
    }
  }
  if (divisores == 0) {
    printf("%d \202 primo", i);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jg     11b4 <main+0x94>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
cmp    $0x0,%edx
jne    11a6 <main+0x86>
mov    -0x8(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    11b4 <main+0x94>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <main+0x3b>
cmpl   $0x0,-0x10(%rbp)
jne    11cf <main+0xaf>
mov    -0x8(%rbp),%esi
lea    0xe5c(%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   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%r9d
lea    0xed8(%rip),%rdi
cmp    $0x4,%r9d
jl     1191 <main+0x71>
mov    %r9d,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%esi
lea    0xeaf(%rip),%r8
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r9d,%eax
cltd
idiv   %esi
test   %edx,%edx
je     118e <main+0x6e>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1170 <main+0x50>
jmp    1191 <main+0x71>
mov    %r8,%rdi
mov    %r9d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Digite um numero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d n\C6o eh primo\00"
@.str.3 = [11 x i8] c"%d \82 primo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %3
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 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)
br label %7
7: ; preds = %23, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = sdiv i32 %9, 2
%11 = icmp sle i32 %8, %10
br i1 %11, label %12, label %24
12: ; preds = %7
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = srem i32 %13, %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32 %18)
store i32 1, i32* %4
br label %24
20: ; preds = %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %23
23: ; preds = %20
br label %7
24: ; preds = %17, %7
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %24
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [17 x i8] c"Digite um numero\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"%d n\C6o eh primo\00"
@.str.3 = [11 x i8] c"%d \82 primo\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 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, 4
br i1 %6, label %16, label %7
7: ; preds = %0
%8 = lshr i32 %5, 1
br label %12
9: ; preds = %12
%10 = add nuw nsw i32 %13, 1
%11 = icmp eq i32 %13, %8
br i1 %11, label %16, label %12
12: ; preds = %7, %9
%13 = phi i32 [ %10, %9 ], [ 2, %7 ]
%14 = srem i32 %5, %13
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9, %12, %0
%17 = phi i8* [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %0 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %12 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), %9 ]
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17, i32 %5)
ret i32 0
}