#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 EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getc(int /*<<< orphan*/ *);
int get_filesize(char *fvalue) {
  int size, rc1;
  FILE *fp1 = fopen(fvalue, "rb");
  if (fp1 == NULL) {
    0;
    return 0;
  }
  for (size = 0; (rc1 = getc(fp1)) != EOF; size++) {
  }
  fclose(fp1);
  0;
  return size;
}


x86 assembly (clang, -O0):
<get_filesize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1167 <get_filesize+0x37>
movl   $0x0,-0x4(%rbp)
jmp    11ab <get_filesize+0x7b>
movl   $0x0,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    0x2e67(%rip),%rcx
cmp    (%rcx),%eax
je     119c <get_filesize+0x6c>
jmp    118e <get_filesize+0x5e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <get_filesize+0x3e>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filesize>:
push   %r15
push   %r14
push   %rbx
lea    0xec4(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     117a <get_filesize+0x4a>
mov    %rax,%r14
mov    $0xffffffff,%ebx
mov    0x2e93(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
call   1050 <getc@plt>
add    $0x1,%ebx
cmp    (%r15),%eax
jne    1160 <get_filesize+0x30>
mov    %r14,%rdi
call   1030 <fclose@plt>
jmp    117c <get_filesize+0x4c>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@EOF = global i32 0
define i32 @get_filesize(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 %12, label %4
4: ; preds = %1, %4
%5 = phi i32 [ %9, %4 ], [ 0, %1 ]
%6 = tail call i32 @getc(i32* %2)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
%9 = add nuw nsw i32 %5, 1
br i1 %8, label %10, label %4
10: ; preds = %4
%11 = tail call i32 @fclose(i32* %2)
br label %12
12: ; preds = %1, %10
%13 = phi i32 [ %5, %10 ], [ 0, %1 ]
ret i32 %13
}