#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
FILE *find(char *key) {
  FILE *fp;
  int x, h, nrec, i, j;
  long off, offr;
  int del;
  char ssn[10], name[21];
  float sal;
  int ovptr;
  for (i = x = 0; key[i] != 0; i++) {
    x = x + key[i];
  }
  h = x % 10;
  off = h * (44 + 2L);
  fp = fopen("../create/emp", "r+");
  fseek(fp, off, 0);
  for (i = h; i != -1; i = ovptr) {
    off = i * (10L + 3 * (3 + 10 + 21 + 10 + 2));
    fseek(fp, off, 0);
    fscanf(fp, "%d%d", &nrec, &ovptr);
    for (j = 0; j < nrec; j++) {
      offr = ftell(fp) + 2;
      fscanf(fp, "%d%s%s%f", &del, ssn, name, &sal);
      if ((del == 0) && (strcmp(ssn, key) == 0)) {
        fseek(fp, offr, 0);
        return fp;
      }
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<find>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b4 <find+0x54>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x28(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117d <find+0x1d>
mov    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
movslq -0x20(%rbp),%rax
imul   $0x2e,%rax,%rax
mov    %rax,-0x38(%rbp)
lea    0xe2b(%rip),%rdi
lea    0xe32(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0xffffffff,-0x28(%rbp)
je     12e3 <find+0x183>
movslq -0x28(%rbp),%rax
imul   $0x94,%rax,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rdi
lea    0xde4(%rip),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x78(%rbp),%rcx
mov    $0x0,%al
call   1040 <fscanf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12d3 <find+0x173>
mov    -0x18(%rbp),%rdi
call   1060 <ftell@plt>
add    $0x2,%eax
cltq
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x4e(%rbp),%rcx
lea    -0x70(%rbp),%r8
lea    0xda2(%rip),%rsi
lea    -0x44(%rbp),%rdx
lea    -0x74(%rbp),%r9
mov    $0x0,%al
call   1040 <fscanf@plt>
cmpl   $0x0,-0x44(%rbp)
jne    12c0 <find+0x160>
lea    -0x4e(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12c0 <find+0x160>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12f4 <find+0x194>
jmp    12c5 <find+0x165>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1243 <find+0xe3>
jmp    12d8 <find+0x178>
mov    -0x78(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11fa <find+0x9a>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    (%rdi),%al
test   %al,%al
mov    %rdi,0x18(%rsp)
je     11b0 <find+0x50>
lea    0x1(%rdi),%rdx
xor    %ecx,%ecx
nop
movsbl %al,%eax
add    %eax,%ecx
movzbl (%rdx),%eax
add    $0x1,%rdx
test   %al,%al
jne    1180 <find+0x20>
movslq %ecx,%rbp
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebp
jmp    11b2 <find+0x52>
xor    %ebp,%ebp
imul   $0x2e,%ebp,%eax
movslq %eax,%r14
lea    0xe41(%rip),%rdi
lea    0xe48(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <fseek@plt>
cmp    $0xffffffff,%ebp
je     12af <find+0x14f>
lea    0x26(%rsp),%r12
lea    0x30(%rsp),%r13
lea    0x20(%rsp),%r14
jmp    120d <find+0xad>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x10(%rsp),%ebp
cmp    $0xffffffff,%ebp
je     12af <find+0x14f>
movslq %ebp,%rax
imul   $0x94,%rax,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <fseek@plt>
mov    %rbx,%rdi
lea    0xde6(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1200 <find+0xa0>
xor    %r15d,%r15d
jmp    125b <find+0xfb>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    0xc(%rsp),%r15d
jge    1200 <find+0xa0>
mov    %rbx,%rdi
call   1060 <ftell@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
lea    0xda7(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %r14,%r9
xor    %eax,%eax
call   1040 <fscanf@plt>
cmpl   $0x0,0x14(%rsp)
jne    1250 <find+0xf0>
mov    %r12,%rdi
mov    0x18(%rsp),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1250 <find+0xf0>
add    $0x2,%ebp
movslq %ebp,%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1070 <fseek@plt>
jmp    12b9 <find+0x159>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"../create/emp\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [5 x i8] c"%d%d\00"
@.str.3 = [9 x i8] c"%d%s%s%f\00"
define i32* @find(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca [10 x i8]
%14 = alloca [21 x i8]
%15 = alloca float
%16 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
store i32 0, i32* %8
br label %17
17: ; preds = %34, %1
%18 = load i8*, i8** %3
%19 = load i32, i32* %8
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %37
25: ; preds = %17
%26 = load i32, i32* %5
%27 = load i8*, i8** %3
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = add nsw i32 %26, %32
store i32 %33, i32* %5
br label %34
34: ; preds = %25
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %17
37: ; preds = %17
%38 = load i32, i32* %5
%39 = srem i32 %38, 10
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = mul nsw i64 %41, 46
store i64 %42, i64* %10
%43 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %43, i32** %4
%44 = load i32*, i32** %4
%45 = load i64, i64* %10
%46 = call i32 @fseek(i32* %44, i64 %45, i32 0)
%47 = load i32, i32* %6
store i32 %47, i32* %8
br label %48
48: ; preds = %90, %37
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, -1
br i1 %50, label %51, label %92
51: ; preds = %48
%52 = load i32, i32* %8
%53 = sext i32 %52 to i64
%54 = mul nsw i64 %53, 148
store i64 %54, i64* %10
%55 = load i32*, i32** %4
%56 = load i64, i64* %10
%57 = call i32 @fseek(i32* %55, i64 %56, i32 0)
%58 = load i32*, i32** %4
%59 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %7, i32* %16)
store i32 0, i32* %9
br label %60
60: ; preds = %86, %51
%61 = load i32, i32* %9
%62 = load i32, i32* %7
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %89
64: ; preds = %60
%65 = load i32*, i32** %4
%66 = call i32 @ftell(i32* %65)
%67 = add nsw i32 %66, 2
%68 = sext i32 %67 to i64
store i64 %68, i64* %11
%69 = load i32*, i32** %4
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%71 = getelementptr inbounds [21 x i8], [21 x i8]* %14, i64 0, i64 0
%72 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %69, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %12, i8* %70, i8* %71, float* %15)
%73 = load i32, i32* %12
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %85
75: ; preds = %64
%76 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%77 = load i8*, i8** %3
%78 = call i64 @strcmp(i8* %76, i8* %77)
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %85
80: ; preds = %75
%81 = load i32*, i32** %4
%82 = load i64, i64* %11
%83 = call i32 @fseek(i32* %81, i64 %82, i32 0)
%84 = load i32*, i32** %4
store i32* %84, i32** %2
br label %95
85: ; preds = %75, %64
br label %86
86: ; preds = %85
%87 = load i32, i32* %9
%88 = add nsw i32 %87, 1
store i32 %88, i32* %9
br label %60
89: ; preds = %60
br label %90
90: ; preds = %89
%91 = load i32, i32* %16
store i32 %91, i32* %8
br label %48
92: ; preds = %48
%93 = load i32*, i32** %4
%94 = call i32 @fclose(i32* %93)
store i32* null, i32** %2
br label %95
95: ; preds = %92, %80
%96 = load i32*, i32** %2
ret i32* %96
}

LLVM IR (-O2):
@.str = [14 x i8] c"../create/emp\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [5 x i8] c"%d%d\00"
@.str.3 = [9 x i8] c"%d%s%s%f\00"
define noalias i32* @find(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca [21 x i8]
%6 = alloca float
%7 = alloca i32
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%12 = bitcast float* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 0
br i1 %15, label %28, label %16
16: ; preds = %1, %16
%17 = phi i64 [ %22, %16 ], [ 0, %1 ]
%18 = phi i8 [ %24, %16 ], [ %14, %1 ]
%19 = phi i32 [ %21, %16 ], [ 0, %1 ]
%20 = sext i8 %18 to i32
%21 = add nsw i32 %19, %20
%22 = add nuw nsw i64 %17, 1
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %16
26: ; preds = %16
%27 = srem i32 %21, 10
br label %28
28: ; preds = %26, %1
%29 = phi i32 [ 0, %1 ], [ %27, %26 ]
%30 = mul nsw i32 %29, 46
%31 = sext i32 %30 to i64
%32 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%33 = tail call i32 @fseek(i32* %32, i64 %31, i32 0)
%34 = icmp eq i32 %29, -1
br i1 %34, label %63, label %35
35: ; preds = %28, %60
%36 = phi i32 [ %61, %60 ], [ %29, %28 ]
%37 = sext i32 %36 to i64
%38 = mul nsw i64 %37, 148
%39 = call i32 @fseek(i32* %32, i64 %38, i32 0)
%40 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %7)
%41 = load i32, i32* %2
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %60
43: ; preds = %35, %56
%44 = phi i32 [ %57, %56 ], [ 0, %35 ]
%45 = call i32 @ftell(i32* %32)
%46 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3, i8* %10, i8* %11, float* %6)
%47 = load i32, i32* %3
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %43
%50 = call i64 @strcmp(i8* %10, i8* %0)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %49
%53 = add nsw i32 %45, 2
%54 = sext i32 %53 to i64
%55 = call i32 @fseek(i32* %32, i64 %54, i32 0)
br label %65
56: ; preds = %43, %49
%57 = add nuw nsw i32 %44, 1
%58 = load i32, i32* %2
%59 = icmp slt i32 %57, %58
br i1 %59, label %43, label %60
60: ; preds = %56, %35
%61 = load i32, i32* %7
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %35
63: ; preds = %60, %28
%64 = call i32 @fclose(i32* %32)
br label %65
65: ; preds = %63, %52
%66 = phi i32* [ %32, %52 ], [ null, %63 ]
ret i32* %66
}