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

/* Variables and functions */
int /*<<< orphan*/ file_seek(int /*<<< orphan*/ *, long const);
long const get_int32_t(unsigned char *);
int /*<<< orphan*/ read_bytes(int /*<<< orphan*/ *, int, unsigned char *);
time_t get_linker_timestamp(FILE *file) {
  const long int peOffset = 60;
  const long int linkerTimestampOffset = 8;
  unsigned char bytes[4];
  if (!file) {
    return -1;
  }
  file_seek(file, peOffset);
  read_bytes(file, 4, bytes);
  file_seek(file, get_int32_t(bytes) + linkerTimestampOffset);
  read_bytes(file, 4, bytes);
  return (time_t)get_int32_t(bytes);
}


x86 assembly (clang, -O0):
<get_linker_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x3c,-0x18(%rbp)
movq   $0x8,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1163 <get_linker_timestamp+0x33>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <get_linker_timestamp+0x92>
mov    -0x10(%rbp),%rdi
mov    $0x3c,%esi
call   1030 <file_seek@plt>
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rdx
mov    $0x4,%esi
call   1040 <read_bytes@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x24(%rbp),%rdi
call   1050 <get_int32_t@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
add    $0x8,%rsi
call   1030 <file_seek@plt>
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rdx
mov    $0x4,%esi
call   1040 <read_bytes@plt>
lea    -0x24(%rbp),%rdi
call   1050 <get_int32_t@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_linker_timestamp>:
test   %rdi,%rdi
je     118f <get_linker_timestamp+0x5f>
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x3c,%esi
call   1030 <file_seek@plt>
lea    0x4(%rsp),%r14
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
call   1040 <read_bytes@plt>
mov    %r14,%rdi
call   1050 <get_int32_t@plt>
lea    0x8(%rax),%rsi
mov    %rbx,%rdi
call   1030 <file_seek@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14,%rdx
call   1040 <read_bytes@plt>
mov    %r14,%rdi
call   1050 <get_int32_t@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
define i32 @get_linker_timestamp(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca [4 x i8]
store i32* %0, i32** %3
store i64 60, i64* %4
store i64 8, i64* %5
%7 = load i32*, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 -1, i32* %2
br label %27
10: ; preds = %1
%11 = load i32*, i32** %3
%12 = call i32 @file_seek(i32* %11, i64 60)
%13 = load i32*, i32** %3
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%15 = call i32 @read_bytes(i32* %13, i32 4, i8* %14)
%16 = load i32*, i32** %3
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%18 = call i64 @get_int32_t(i8* %17)
%19 = add nsw i64 %18, 8
%20 = call i32 @file_seek(i32* %16, i64 %19)
%21 = load i32*, i32** %3
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%23 = call i32 @read_bytes(i32* %21, i32 4, i8* %22)
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%25 = call i64 @get_int32_t(i8* %24)
%26 = trunc i64 %25 to i32
store i32 %26, i32* %2
br label %27
27: ; preds = %10, %9
%28 = load i32, i32* %2
ret i32 %28
}

LLVM IR (-O2):
define i32 @get_linker_timestamp(i32* %0) {
%2 = alloca [4 x i8]
%3 = getelementptr inbounds [4 x i8], [4 x i8]* %2, i64 0, i64 0
%4 = icmp eq i32* %0, null
br i1 %4, label %14, label %5
5: ; preds = %1
%6 = tail call i32 @file_seek(i32* %0, i64 60)
%7 = call i32 @read_bytes(i32* %0, i32 4, i8* %3)
%8 = call i64 @get_int32_t(i8* %3)
%9 = add nsw i64 %8, 8
%10 = call i32 @file_seek(i32* %0, i64 %9)
%11 = call i32 @read_bytes(i32* %0, i32 4, i8* %3)
%12 = call i64 @get_int32_t(i8* %3)
%13 = trunc i64 %12 to i32
br label %14
14: ; preds = %1, %5
%15 = phi i32 [ %13, %5 ], [ -1, %1 ]
ret i32 %15
}