#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 check(float average) {
  printf("\nI will check if the average is a prime number: ");
  int number = (int)average;
  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\n", number);
  } else {
    if (flag == 1) {
      printf("\nThe number %d isn't prime!", number);
    }
  }
  return number;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
lea    0xedc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvttss2si -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%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     118e <check+0x7e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    117b <check+0x6b>
movl   $0x1,-0xc(%rbp)
jmp    118e <check+0x7e>
jmp    1180 <check+0x70>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1141 <check+0x31>
cmpl   $0x0,-0xc(%rbp)
jne    11ae <check+0x9e>
mov    -0x8(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <check+0xbe>
cmpl   $0x1,-0xc(%rbp)
jne    11c9 <check+0xb9>
mov    -0x8(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ce <check+0xbe>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
lea    0xede(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cvttss2si 0xc(%rsp),%ebx
lea    0xefb(%rip),%rdi
cmp    $0x4,%ebx
jl     1170 <check+0x60>
mov    %ebx,%ecx
shr    %ecx
neg    %ecx
mov    $0x2,%esi
lea    0xef2(%rip),%r8
nopl   (%rax)
mov    %ebx,%eax
cltd
idiv   %esi
test   %edx,%edx
je     116d <check+0x5d>
lea    (%rcx,%rsi,1),%eax
add    $0x1,%eax
mov    %esi,%edx
add    $0x1,%edx
mov    %edx,%esi
cmp    $0x1,%eax
jne    1150 <check+0x40>
jmp    1170 <check+0x60>
mov    %r8,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"\0AI will check if the average is a prime number: \00"
@.str.1 = [14 x i8] c"\0A%d is prime\0A\00"
@.str.2 = [28 x i8] c"\0AThe number %d isn't prime!\00"
define i32 @check(float %0) {
%2 = alloca float
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store float %0, float* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%7 = load float, float* %2
%8 = fptosi float %7 to i32
store i32 %8, i32* %3
store i32 0, i32* %4
store i32 2, i32* %5
br label %9
9: ; preds = %21, %1
%10 = load i32, i32* %5
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 2
%13 = icmp sle i32 %10, %12
br i1 %13, label %14, label %24
14: ; preds = %9
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = srem i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %4
br label %24
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %9
24: ; preds = %19, %9
%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* %3
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %28)
br label %37
30: ; preds = %24
%31 = load i32, i32* %4
%32 = icmp eq i32 %31, 1
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32, i32* %3
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %30
br label %37
37: ; preds = %36, %27
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [49 x i8] c"\0AI will check if the average is a prime number: \00"
@.str.1 = [14 x i8] c"\0A%d is prime\0A\00"
@.str.2 = [28 x i8] c"\0AThe number %d isn't prime!\00"
define i32 @check(float %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%3 = fptosi float %0 to i32
%4 = icmp slt i32 %3, 4
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = lshr i32 %3, 1
br label %10
7: ; preds = %10
%8 = add nuw nsw i32 %11, 1
%9 = icmp eq i32 %11, %6
br i1 %9, label %14, label %10
10: ; preds = %5, %7
%11 = phi i32 [ %8, %7 ], [ 2, %5 ]
%12 = srem i32 %3, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %10, %7, %1
%15 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %1 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), %10 ]
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %15, i32 %3)
ret i32 %3
}