#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*/ GenClose(void *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *GenOpen(void *, char const *, char *);
long LookupEntry(void *, char const *, char **, char *, int *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
FILE *GetEntries(void *theEnv, const char *file, char **menu, char *name,
                 int *code) {
  FILE *fp;
  long int offset;
  offset = LookupEntry(theEnv, file, menu, name, code);
  if (offset < 0)
    return (NULL);
  fp = GenOpen(theEnv, file, "r");
  if (fp == NULL) {
    *code = -10;
    return (NULL);
  }
  if (fseek(fp, offset, 0) < 0) {
    GenClose(theEnv, fp);
    *code = -10;
    return (NULL);
  }
  return (fp);
}


x86 assembly (clang, -O0):
<GetEntries>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1060 <LookupEntry@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jge    1191 <GetEntries+0x51>
movq   $0x0,-0x8(%rbp)
jmp    1210 <GetEntries+0xd0>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    0xe60(%rip),%rdx
call   1030 <GenOpen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11cb <GetEntries+0x8b>
mov    -0x30(%rbp),%rax
movl   $0xfffffff6,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1210 <GetEntries+0xd0>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
xor    %edx,%edx
call   1040 <fseek@plt>
cmp    $0x0,%rax
jge    1208 <GetEntries+0xc8>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <GenClose@plt>
mov    -0x30(%rbp),%rax
movl   $0xfffffff6,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1210 <GetEntries+0xd0>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetEntries>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
call   1060 <LookupEntry@plt>
test   %rax,%rax
js     119c <GetEntries+0x5c>
mov    %rax,%r12
lea    0xe9b(%rip),%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <GenOpen@plt>
test   %rax,%rax
je     1195 <GetEntries+0x55>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   1040 <fseek@plt>
test   %rax,%rax
jns    119e <GetEntries+0x5e>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <GenClose@plt>
movl   $0xfffffff6,(%r14)
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32* @GetEntries(i8* %0, i8* %1, i8** %2, i8* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8**
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8** %2, i8*** %9
store i8* %3, i8** %10
store i32* %4, i32** %11
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i8**, i8*** %9
%17 = load i8*, i8** %10
%18 = load i32*, i32** %11
%19 = call i64 @LookupEntry(i8* %14, i8* %15, i8** %16, i8* %17, i32* %18)
store i64 %19, i64* %13
%20 = load i64, i64* %13
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %5
store i32* null, i32** %6
br label %43
23: ; preds = %5
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32* @GenOpen(i8* %24, i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %26, i32** %12
%27 = load i32*, i32** %12
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = load i32*, i32** %11
store i32 -10, i32* %30
store i32* null, i32** %6
br label %43
31: ; preds = %23
%32 = load i32*, i32** %12
%33 = load i64, i64* %13
%34 = call i64 @fseek(i32* %32, i64 %33, i32 0)
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = load i8*, i8** %7
%38 = load i32*, i32** %12
%39 = call i32 @GenClose(i8* %37, i32* %38)
%40 = load i32*, i32** %11
store i32 -10, i32* %40
store i32* null, i32** %6
br label %43
41: ; preds = %31
%42 = load i32*, i32** %12
store i32* %42, i32** %6
br label %43
43: ; preds = %41, %36, %29, %22
%44 = load i32*, i32** %6
ret i32* %44
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32* @GetEntries(i8* %0, i8* %1, i8** %2, i8* %3, i32* %4) {
%6 = tail call i64 @LookupEntry(i8* %0, i8* %1, i8** %2, i8* %3, i32* %4)
%7 = icmp slt i64 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %5
%9 = tail call i32* @GenOpen(i8* %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i64 @fseek(i32* %9, i64 %6, i32 0)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = tail call i32 @GenClose(i8* %0, i32* %9)
br label %16
16: ; preds = %8, %14
store i32 -10, i32* %4
br label %17
17: ; preds = %16, %11, %5
%18 = phi i32* [ null, %5 ], [ %9, %11 ], [ null, %16 ]
ret i32* %18
}