#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 isPrime(int *array) {
  printf("\nNow I print the prime number inside the array!\n");
  int number = 0;
  for (int ii = 0; ii < 100; ii++) {
    number = array[ii];
    int flag = 0;
    for (int i = 2; i <= number / 2; i++) {
      if (number % i == 0) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      printf("\n%d is prime and  the position was [%d]\n", number, ii);
    }
  }
}


x86 assembly (clang, -O0):
<isPrime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x64,-0x18(%rbp)
jge    11dc <isPrime+0xcc>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jg     11ab <isPrime+0x9b>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x20(%rbp)
cmp    $0x0,%edx
jne    1198 <isPrime+0x88>
movl   $0x1,-0x1c(%rbp)
jmp    11ab <isPrime+0x9b>
jmp    119d <isPrime+0x8d>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <isPrime+0x4e>
cmpl   $0x0,-0x1c(%rbp)
jne    11c9 <isPrime+0xb9>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <isPrime+0xbe>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1138 <isPrime+0x28>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isPrime>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xefa(%rip),%rdi
call   1030 <puts@plt>
lea    0xec5(%rip),%r14
xor    %ebx,%ebx
jmp    1156 <isPrime+0x36>
nop
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
je     118d <isPrime+0x6d>
mov    (%r15,%rbx,4),%esi
cmp    $0x4,%esi
jl     1140 <isPrime+0x20>
mov    %esi,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%edi
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
cltd
idiv   %edi
test   %edx,%edx
je     114c <isPrime+0x2c>
lea    (%rcx,%rdi,1),%eax
add    $0x1,%eax
mov    %edi,%edx
add    $0x1,%edx
mov    %edx,%edi
cmp    $0x1,%eax
jne    1170 <isPrime+0x50>
jmp    1140 <isPrime+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\0ANow I print the prime number inside the array!\0A\00"
@.str.1 = [41 x i8] c"\0A%d is prime and the position was [%d]\0A\00"
define i32 @isPrime(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
store i32 0, i32* %5
br label %9
9: ; preds = %41, %1
%10 = load i32, i32* %5
%11 = icmp slt i32 %10, 100
br i1 %11, label %12, label %44
12: ; preds = %9
%13 = load i32*, i32** %3
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
store i32 %17, i32* %4
store i32 0, i32* %6
store i32 2, i32* %7
br label %18
18: ; preds = %30, %12
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = sdiv i32 %20, 2
%22 = icmp sle i32 %19, %21
br i1 %22, label %23, label %33
23: ; preds = %18
%24 = load i32, i32* %4
%25 = load i32, i32* %7
%26 = srem i32 %24, %25
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i32 1, i32* %6
br label %33
29: ; preds = %23
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %18
33: ; preds = %28, %18
%34 = load i32, i32* %6
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i32, i32* %4
%38 = load i32, i32* %5
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %37, i32 %38)
br label %40
40: ; preds = %36, %33
br label %41
41: ; preds = %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, 1
store i32 %43, i32* %5
br label %9
44: ; preds = %9
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c"\0A%d is prime and the position was [%d]\0A\00"
@str = [48 x i8] c"\0ANow I print the prime number inside the array!\00"
define i32 @isPrime(i32* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %4
3: ; preds = %21
ret i32 undef
4: ; preds = %1, %21
%5 = phi i64 [ 0, %1 ], [ %22, %21 ]
%6 = getelementptr inbounds i32, i32* %0, i64 %5
%7 = load i32, i32* %6
%8 = icmp slt i32 %7, 4
br i1 %8, label %18, label %9
9: ; preds = %4
%10 = lshr i32 %7, 1
br label %14
11: ; preds = %14
%12 = add nuw nsw i32 %15, 1
%13 = icmp eq i32 %15, %10
br i1 %13, label %18, label %14
14: ; preds = %9, %11
%15 = phi i32 [ %12, %11 ], [ 2, %9 ]
%16 = srem i32 %7, %15
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %11
18: ; preds = %11, %4
%19 = trunc i64 %5 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %19)
br label %21
21: ; preds = %14, %18
%22 = add nuw nsw i64 %5, 1
%23 = icmp eq i64 %22, 100
br i1 %23, label %3, label %4
}