#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, ...);
int equation(int number) {
  int counter = 2;
  int result;
  while (counter < number) {
    result = number % counter;
    if (result == 0) {
      printf("%d isn't prime, divided by %d \n", number, counter);
      break;
    } else {
      counter++;
      printf("%d is prime\n", number);
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<equation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    117a <equation+0x6a>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    115b <equation+0x4b>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    117a <equation+0x6a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1122 <equation+0x12>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<equation>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jl     1168 <equation+0x58>
mov    %edi,%r14d
mov    $0x2,%ebx
lea    0xef5(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r14d,%eax
cltd
idiv   %ebx
test   %edx,%edx
je     1153 <equation+0x43>
mov    %edx,%ebp
add    $0x1,%ebx
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    %ebx,%r14d
jne    1130 <equation+0x20>
jmp    1168 <equation+0x58>
lea    0xea6(%rip),%rdi
xor    %ebp,%ebp
mov    %r14d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"%d isn't prime, divided by %d \0A\00"
@.str.1 = [13 x i8] c"%d is prime\0A\00"
define i32 @equation(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 2, i32* %3
br label %5
5: ; preds = %24, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %25
9: ; preds = %5
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = srem i32 %10, %11
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %9
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %17)
br label %25
19: ; preds = %9
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %2
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %19
br label %5
25: ; preds = %15, %5
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
@.str = [32 x i8] c"%d isn't prime, divided by %d \0A\00"
@.str.1 = [13 x i8] c"%d is prime\0A\00"
define i32 @equation(i32 %0) {
%2 = icmp sgt i32 %0, 2
br i1 %2, label %3, label %13
3: ; preds = %1, %9
%4 = phi i32 [ %10, %9 ], [ 2, %1 ]
%5 = srem i32 %0, %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %4)
br label %13
9: ; preds = %3
%10 = add nuw nsw i32 %4, 1
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%12 = icmp eq i32 %10, %0
br i1 %12, label %13, label %3
13: ; preds = %9, %1, %7
%14 = phi i32 [ 0, %7 ], [ undef, %1 ], [ %5, %9 ]
ret i32 %14
}