#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 */
scalar_t__ isPrime(int, int *);
int /*<<< orphan*/ puts(char *);
void dividers(int n) {
  int a = 3, b = 3, c = 0, i;
  if (isPrime(n, &a)) {
    puts("Primo");
  }
  b = a + 1;
  while (b < n / 2 && c == 0) {
    isPrime(n, &b);
    c = b % a;
  }
  if (c != 0) {
    puts("Quase Primo");
  } else {
    puts("Nem primo nem quase primo");
  }
}


x86 assembly (clang, -O0):
<dividers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
movl   $0x3,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x8(%rbp),%rsi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1162 <dividers+0x42>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
mov    $0x2,%esi
cltd
idiv   %esi
mov    %eax,%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x15(%rbp)
jge    1192 <dividers+0x72>
cmpl   $0x0,-0x10(%rbp)
sete   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11a2 <dividers+0x82>
jmp    11bd <dividers+0x9d>
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1040 <isPrime@plt>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x10(%rbp)
jmp    116b <dividers+0x4b>
cmpl   $0x0,-0x10(%rbp)
je     11d8 <dividers+0xb8>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
jmp    11e4 <dividers+0xc4>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dividers>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x3,0x8(%rsp)
lea    0x8(%rsp),%rsi
call   1040 <isPrime@plt>
test   %rax,%rax
je     114d <dividers+0x2d>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
mov    %ebx,%ebp
shr    $0x1f,%ebp
add    %ebx,%ebp
sar    %ebp
cmp    %ebp,%eax
jge    119a <dividers+0x7a>
lea    0xc(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %r14,%rsi
call   1040 <isPrime@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
cltd
idivl  0x8(%rsp)
cmp    %ebp,%ecx
jge    118d <dividers+0x6d>
test   %edx,%edx
je     1170 <dividers+0x50>
test   %edx,%edx
je     119a <dividers+0x7a>
lea    0xe68(%rip),%rdi
jmp    11a1 <dividers+0x81>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Primo\00"
@.str.1 = [12 x i8] c"Quase Primo\00"
@.str.2 = [26 x i8] c"Nem primo nem quase primo\00"
define void @dividers(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 3, i32* %3
store i32 3, i32* %4
store i32 0, i32* %5
%7 = load i32, i32* %2
%8 = call i64 @isPrime(i32 %7, i32* %3)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %1
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %4
br label %15
15: ; preds = %25, %12
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 2
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br label %23
23: ; preds = %20, %15
%24 = phi i1 [ false, %15 ], [ %22, %20 ]
br i1 %24, label %25, label %31
25: ; preds = %23
%26 = load i32, i32* %2
%27 = call i64 @isPrime(i32 %26, i32* %4)
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = srem i32 %28, %29
store i32 %30, i32* %5
br label %15
31: ; preds = %23
%32 = load i32, i32* %5
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %38
36: ; preds = %31
%37 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %34
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"Primo\00"
@.str.1 = [12 x i8] c"Quase Primo\00"
@.str.2 = [26 x i8] c"Nem primo nem quase primo\00"
define void @dividers(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
store i32 3, i32* %2
%5 = bitcast i32* %3 to i8*
%6 = call i64 @isPrime(i32 %0, i32* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = load i32, i32* %2
%12 = add nsw i32 %11, 1
store i32 %12, i32* %3
%13 = sdiv i32 %0, 2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %10, %15
%16 = call i64 @isPrime(i32 %0, i32* %3)
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = srem i32 %17, %18
%20 = icmp slt i32 %17, %13
%21 = icmp eq i32 %19, 0
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %15, label %23
23: ; preds = %15
br i1 %21, label %24, label %25
24: ; preds = %10, %23
br label %25
25: ; preds = %23, %24
%26 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %24 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %23 ]
%27 = call i32 @puts(i8* dereferenceable(1) %26)
ret void
}