#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*/ age;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(void *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int age;
  FILE *fp;
  fp = fopen("prof.bin", "rb");
  if (fp == NULL) {
    printf("Can't open file!\n");
    return -1;
  }
  fseek(fp, 32, SEEK_SET);
  fread((void *)&age, sizeof(age), 1, fp);
  printf("age: %d\n", age);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119b <main+0x4b>
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <main+0x9a>
mov    -0x10(%rbp),%rdi
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1060 <fseek@plt>
lea    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x8(%rbp),%esi
lea    0xe4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11c9 <main+0x69>
mov    %rax,%rbx
mov    0x2e5b(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <fseek@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    0x4(%rsp),%esi
lea    0xe56(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    11da <main+0x7a>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"prof.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [18 x i8] c"Can't open file!\0A\00"
@SEEK_SET = global i32 0
@.str.3 = [9 x i8] c"age: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %3
%5 = load i32*, i32** %3
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %20
9: ; preds = %0
%10 = load i32*, i32** %3
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @fseek(i32* %10, i32 32, i32 %11)
%13 = bitcast i32* %2 to i8*
%14 = load i32*, i32** %3
%15 = call i32 @fread(i8* %13, i32 4, i32 1, i32* %14)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32*, i32** %3
%19 = call i32 @fclose(i32* %18)
store i32 0, i32* %1
br label %20
20: ; preds = %9, %7
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [9 x i8] c"prof.bin\00"
@.str.1 = [3 x i8] c"rb\00"
@SEEK_SET = global i32 0
@.str.3 = [9 x i8] c"age: %d\0A\00"
@str = [17 x i8] c"Can't open file!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %14
7: ; preds = %0
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %3, i32 32, i32 %8)
%10 = call i32 @fread(i8* %2, i32 4, i32 1, i32* %3)
%11 = load i32, i32* %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = tail call i32 @fclose(i32* %3)
br label %14
14: ; preds = %7, %5
%15 = phi i32 [ -1, %5 ], [ 0, %7 ]
ret i32 %15
}