#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_SET;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int getsize(FILE *fp) {
  int size;
  fseek(fp, SEEK_SET, 0);
  if (!fscanf(fp, "%d", &size)) {
    printf("Input file is not in the prescribed format\n");
    exit(0);
  }
  return size;
}


x86 assembly (clang, -O0):
<getsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e89(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <fseek@plt>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x0,%eax
jne    1190 <getsize+0x50>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getsize>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <fseek@plt>
lea    0xea1(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <fscanf@plt>
test   %eax,%eax
je     117a <getsize+0x3a>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%d\00"
@.str.1 = [44 x i8] c"Input file is not in the prescribed format\0A\00"
define i32 @getsize(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = load i32, i32* @SEEK_SET
%6 = call i32 @fseek(i32* %4, i32 %5, i32 0)
%7 = load i32*, i32** %2
%8 = call i32 @fscanf(i32* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%9 = icmp ne i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %1
%14 = load i32, i32* %3
ret i32 %14
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%d\00"
@str = [43 x i8] c"Input file is not in the prescribed format\00"
define i32 @getsize(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 %4, i32 0)
%6 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%10 = call i32 @exit(i32 0)
unreachable
11: ; preds = %1
%12 = load i32, i32* %2
ret i32 %12
}