#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int BKDRHash(char *);
int GetTotalNumber();
int /*<<< orphan*/ *Sfopen(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
bool check_primer_number(void) {
  FILE *fp_primer_number;
  fp_primer_number = Sfopen("primer_number.txt");
  int max = GetTotalNumber();
  char primer_number[max][5];
  for (int i = 0; i < max; i++) {
    fgets(primer_number[i], 6, fp_primer_number);
  }
  char *str = primer_number[0];
  unsigned int answer = BKDRHash(str);
  return answer == 1207472236;
}


x86 assembly (clang, -O0):
<check_primer_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <Sfopen@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
call   1040 <GetTotalNumber@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(%rax,%rax,4),%rdx
movabs $0xffffffff0,%rcx
and    %rcx,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11cd <check_primer_number+0x8d>
mov    -0x40(%rbp),%rdi
movslq -0x24(%rbp),%rax
imul   $0x5,%rax,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%rdx
mov    $0x6,%esi
call   1030 <fgets@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1196 <check_primer_number+0x56>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <BKDRHash@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x47f8906c,-0x34(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_primer_number>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeae(%rip),%rdi
call   1050 <Sfopen@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1040 <GetTotalNumber@plt>
mov    %eax,%r12d
lea    (%r12,%r12,4),%rcx
add    $0xf,%rcx
movabs $0xffffffff0,%rdx
and    %rcx,%rdx
mov    %rsp,%r14
sub    %rdx,%r14
mov    %r14,%rsp
test   %eax,%eax
jle    11aa <check_primer_number+0x6a>
mov    %r14,%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0x6,%esi
mov    %r15,%rdx
call   1030 <fgets@plt>
add    $0x5,%rbx
add    $0xffffffffffffffff,%r12
jne    1190 <check_primer_number+0x50>
mov    %r14,%rdi
call   1060 <BKDRHash@plt>
xor    %ecx,%ecx
cmp    $0x47f8906c,%eax
sete   %cl
mov    %ecx,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"primer_number.txt\00"
define i32 @check_primer_number() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = call i32* @Sfopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %1
%9 = call i32 (...) @GetTotalNumber()
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = alloca [5 x i8], i64 %11
store i64 %11, i64* %4
store i32 0, i32* %5
br label %14
14: ; preds = %25, %0
%15 = load i32, i32* %5
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %28
18: ; preds = %14
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 %20
%22 = getelementptr inbounds [5 x i8], [5 x i8]* %21, i64 0, i64 0
%23 = load i32*, i32** %1
%24 = call i32 @fgets(i8* %22, i32 6, i32* %23)
br label %25
25: ; preds = %18
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %14
28: ; preds = %14
%29 = getelementptr inbounds [5 x i8], [5 x i8]* %13, i64 0
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %29, i64 0, i64 0
store i8* %30, i8** %6
%31 = load i8*, i8** %6
%32 = call i32 @BKDRHash(i8* %31)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = icmp eq i32 %33, 1207472236
%35 = zext i1 %34 to i32
%36 = load i8*, i8** %3
ret i32 %35
}

LLVM IR (-O2):
@.str = [18 x i8] c"primer_number.txt\00"
define i32 @check_primer_number() {
%1 = tail call i32* @Sfopen(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @GetTotalNumber()
%3 = zext i32 %2 to i64
%4 = alloca [5 x i8], i64 %3
%5 = icmp sgt i32 %2, 0
br i1 %5, label %11, label %6
6: ; preds = %11, %0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = call i32 @BKDRHash(i8* %7)
%9 = icmp eq i32 %8, 1207472236
%10 = zext i1 %9 to i32
ret i32 %10
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 %12, i64 0
%14 = call i32 @fgets(i8* %13, i32 6, i32* %1)
%15 = add nuw nsw i64 %12, 1
%16 = icmp eq i64 %15, %3
br i1 %16, label %6, label %11
}