#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*/ SEEK_END;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int lenFile(char *nom) {
  FILE *fp;
  int file_size = 0;
  if ((fp = fopen(nom, "rb")) == NULL) {
    printf("META.DAT");
    exit(1);
  }
  if (fseek(fp, (long)(0), SEEK_END) != 0) {
    fclose(fp);
    return (file_size);
  }
  file_size = (ftell(fp));
  fclose(fp);
  return (file_size);
}


x86 assembly (clang, -O0):
<lenFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a7 <lenFile+0x47>
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     11db <lenFile+0x7b>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f6 <lenFile+0x96>
mov    -0x18(%rbp),%rdi
call   1050 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lenFile>:
push   %r14
push   %rbx
push   %rax
lea    0xe95(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11b1 <lenFile+0x51>
mov    %rax,%rbx
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <fseek@plt>
test   %rax,%rax
jne    119e <lenFile+0x3e>
mov    %rbx,%rdi
call   1050 <ftell@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [9 x i8] c"META.DAT\00"
@SEEK_END = global i32 0
define i32 @lenFile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = load i32*, i32** %4
%14 = load i32, i32* @SEEK_END
%15 = call i64 @fseek(i32* %13, i64 0, i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i32*, i32** %4
%19 = call i32 @fclose(i32* %18)
%20 = load i32, i32* %5
store i32 %20, i32* %2
br label %27
21: ; preds = %12
%22 = load i32*, i32** %4
%23 = call i32 @ftell(i32* %22)
store i32 %23, i32* %5
%24 = load i32*, i32** %4
%25 = call i32 @fclose(i32* %24)
%26 = load i32, i32* %5
store i32 %26, i32* %2
br label %27
27: ; preds = %21, %17
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [9 x i8] c"META.DAT\00"
@SEEK_END = global i32 0
define i32 @lenFile(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = load i32, i32* @SEEK_END
%9 = tail call i64 @fseek(i32* %2, i64 0, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @ftell(i32* %2)
br label %13
13: ; preds = %7, %11
%14 = phi i32 [ %12, %11 ], [ 0, %7 ]
%15 = tail call i32 @fclose(i32* %2)
ret i32 %14
}