#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);
void primeNum(int n) {
  int i, isprime = 1;
  for (i = 2; i < n; i++) {
    if (0 == n % i) {
      isprime = 0;
      break;
    }
  }
  if (1 == isprime)
    printf("%d is a prime number\n", n);
  else
    printf("%d is not a prime number\n", n);
}


x86 assembly (clang, -O0):
<primeNum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x2,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1165 <primeNum+0x55>
mov    -0x4(%rbp),%eax
cltd
idivl  -0x8(%rbp)
xor    %eax,%eax
cmp    %edx,%eax
jne    1152 <primeNum+0x42>
movl   $0x0,-0xc(%rbp)
jmp    1165 <primeNum+0x55>
jmp    1157 <primeNum+0x47>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1129 <primeNum+0x19>
mov    $0x1,%eax
cmp    -0xc(%rbp),%eax
jne    1187 <primeNum+0x77>
mov    -0x4(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
jmp    1196 <primeNum+0x86>
mov    -0x4(%rbp),%esi
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primeNum>:
mov    %edi,%esi
lea    0xee7(%rip),%rdi
cmp    $0x3,%esi
jl     1140 <primeNum+0x30>
mov    $0x2,%ecx
lea    0xeec(%rip),%r8
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %ecx
test   %edx,%edx
je     1145 <primeNum+0x35>
add    $0x1,%ecx
cmp    %ecx,%esi
jne    1130 <primeNum+0x20>
jmp    1030 <printf@plt>
mov    %r8,%rdi
jmp    1030 <printf@plt>

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

LLVM IR (-O2):
@.str = [22 x i8] c"%d is a prime number\0A\00"
@.str.1 = [26 x i8] c"%d is not a prime number\0A\00"
define void @primeNum(i32 %0) {
%2 = icmp sgt i32 %0, 2
br i1 %2, label %5, label %10
3: ; preds = %5
%4 = icmp eq i32 %9, %0
br i1 %4, label %10, label %5
5: ; preds = %1, %3
%6 = phi i32 [ %9, %3 ], [ 2, %1 ]
%7 = srem i32 %0, %6
%8 = icmp eq i32 %7, 0
%9 = add nuw nsw i32 %6, 1
br i1 %8, label %10, label %3
10: ; preds = %5, %3, %1
%11 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %5 ]
%12 = tail call i32 @printf(i8* %11, i32 %0)
ret void
}