#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 counter(int, int *, int);
int is_perfect_f(int);
int /*<<< orphan*/ is_perfect_p(int);
int is_prime_f(int);
int /*<<< orphan*/ is_prime_p(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  do {
    printf("Enter n (n > 5): ");
    scanf("%d", &n);
  } while (n <= 5);
  int prime = is_prime_f(n);
  is_prime_p(n);
  int perfect = is_perfect_f(n);
  is_perfect_p(n);
  int V[n], i;
  for (i = 0; i < n; ++i) {
    printf("V[%d] = ", i);
    scanf("%d", &V[i]);
  }
  int val;
  printf("Enter a value: ");
  scanf("%d", &val);
  printf("%d has accured %d times in V\n", val, counter(val, V, n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x5,-0x8(%rbp)
jle    117f <main+0xf>
mov    -0x8(%rbp),%edi
call   1080 <is_prime_f@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1090 <is_prime_p@plt>
mov    -0x8(%rbp),%edi
call   1040 <is_perfect_f@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <is_perfect_p@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1241 <main+0xd1>
mov    -0x24(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xde4(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11fb <main+0x8b>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdbc(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x8(%rbp),%edx
call   1060 <counter@plt>
mov    -0x34(%rbp),%esi
mov    %eax,%edx
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe78(%rip),%r14
lea    0xe83(%rip),%r15
lea    -0x2c(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%edi
cmp    $0x6,%edi
jl     11a0 <main+0x30>
call   1080 <is_prime_f@plt>
mov    -0x2c(%rbp),%edi
call   1090 <is_prime_p@plt>
mov    -0x2c(%rbp),%edi
call   1040 <is_perfect_f@plt>
mov    -0x2c(%rbp),%edi
call   1050 <is_perfect_p@plt>
mov    %rsp,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    1238 <main+0xc8>
lea    0xe12(%rip),%r15
lea    0xe08(%rip),%r12
mov    %r14,%r13
xor    %ebx,%ebx
nop
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     1210 <main+0xa0>
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdc5(%rip),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x30(%rbp),%ebx
mov    -0x2c(%rbp),%edx
mov    %ebx,%edi
mov    %r14,%rsi
call   1060 <counter@plt>
lea    0xdc1(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x38(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Enter n (n > 5): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"V[%d] = \00"
@.str.3 = [16 x i8] c"Enter a value: \00"
@.str.4 = [30 x i8] c"%d has accured %d times in V\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
br label %9
9: ; preds = %12, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %9
%13 = load i32, i32* %2
%14 = icmp sle i32 %13, 5
br i1 %14, label %9, label %15
15: ; preds = %12
%16 = load i32, i32* %2
%17 = call i32 @is_prime_f(i32 %16)
store i32 %17, i32* %3
%18 = load i32, i32* %2
%19 = call i32 @is_prime_p(i32 %18)
%20 = load i32, i32* %2
%21 = call i32 @is_perfect_f(i32 %20)
store i32 %21, i32* %4
%22 = load i32, i32* %2
%23 = call i32 @is_perfect_p(i32 %22)
%24 = load i32, i32* %2
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %5
%27 = alloca i32, i64 %25
store i64 %25, i64* %6
store i32 0, i32* %7
br label %28
28: ; preds = %39, %15
%29 = load i32, i32* %7
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %42
32: ; preds = %28
%33 = load i32, i32* %7
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %27, i64 %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %32
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %28
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%45 = load i32, i32* %8
%46 = load i32, i32* %8
%47 = load i32, i32* %2
%48 = call i32 @counter(i32 %46, i32* %27, i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 %48)
store i32 0, i32* %1
%50 = load i8*, i8** %5
%51 = load i32, i32* %1
ret i32 %51
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter n (n > 5): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"V[%d] = \00"
@.str.3 = [16 x i8] c"Enter a value: \00"
@.str.4 = [30 x i8] c"%d has accured %d times in V\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %4, %0
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 6
br i1 %8, label %4, label %9
9: ; preds = %4
%10 = call i32 @is_prime_f(i32 %7)
%11 = load i32, i32* %1
%12 = call i32 @is_prime_p(i32 %11)
%13 = load i32, i32* %1
%14 = call i32 @is_perfect_f(i32 %13)
%15 = load i32, i32* %1
%16 = call i32 @is_perfect_p(i32 %15)
%17 = load i32, i32* %1
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
%20 = alloca i32, i64 %18
%21 = load i32, i32* %1
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %33
23: ; preds = %9, %23
%24 = phi i64 [ %29, %23 ], [ 0, %9 ]
%25 = trunc i64 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds i32, i32* %20, i64 %24
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %27)
%29 = add nuw nsw i64 %24, 1
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %23, label %33
33: ; preds = %23, %9
%34 = bitcast i32* %2 to i8*
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%36 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%37 = load i32, i32* %2
%38 = load i32, i32* %1
%39 = call i32 @counter(i32 %37, i32* %20, i32 %38)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %39)
ret i32 0
}