#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 */
struct timespec {
  unsigned long long tv_nsec;
  scalar_t__ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ get_pcie_time(struct timespec *);
int /*<<< orphan*/ get_time(struct timespec *);
void get_offset(long long int *offset) {
  unsigned long long tmr_cnt;
  unsigned long long cur_cnt;
  struct timespec tmr_time;
  struct timespec cur_time;
  get_time(&cur_time);
  get_pcie_time(&tmr_time);
  cur_cnt = (unsigned long long)cur_time.tv_sec * 1000000000 + cur_time.tv_nsec;
  tmr_cnt = (unsigned long long)tmr_time.tv_sec * 1000000000 + tmr_time.tv_nsec;
  tmr_cnt -= 35;
  if (tmr_cnt > cur_cnt) {
    *offset = (-(tmr_cnt - cur_cnt));
  } else {
    *offset = (cur_cnt - tmr_cnt);
  }
}


x86 assembly (clang, -O0):
<get_offset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x38(%rbp),%rdi
call   1030 <get_time@plt>
lea    -0x28(%rbp),%rdi
call   1040 <get_pcie_time@plt>
imul   $0x3b9aca00,-0x30(%rbp),%rax
3b
add    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
imul   $0x3b9aca00,-0x20(%rbp),%rax
3b
add    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x23,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    1191 <get_offset+0x71>
mov    -0x10(%rbp),%rax
sub    -0x18(%rbp),%rax
xor    %ecx,%ecx
sub    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
jmp    11a0 <get_offset+0x80>
mov    -0x18(%rbp),%rcx
sub    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_offset>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <get_time@plt>
lea    0x10(%rsp),%rdi
call   1040 <get_pcie_time@plt>
mov    (%rsp),%rax
mov    0x8(%rsp),%rcx
sub    0x18(%rsp),%rcx
imul   $0x3b9aca00,%rcx,%rcx
sub    0x10(%rsp),%rax
add    %rcx,%rax
add    $0x23,%rax
mov    %rax,(%rbx)
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
define void @get_offset(i64* %0) {
%2 = alloca i64*
%3 = alloca i64
%4 = alloca i64
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
store i64* %0, i64** %2
%7 = call i32 @get_time(%struct.timespec* %6)
%8 = call i32 @get_pcie_time(%struct.timespec* %5)
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 1
%10 = load i64, i64* %9
%11 = mul i64 %10, 1000000000
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i32 0, i32 0
%13 = load i64, i64* %12
%14 = add i64 %11, %13
store i64 %14, i64* %4
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 1
%16 = load i64, i64* %15
%17 = mul i64 %16, 1000000000
%18 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i32 0, i32 0
%19 = load i64, i64* %18
%20 = add i64 %17, %19
store i64 %20, i64* %3
%21 = load i64, i64* %3
%22 = sub i64 %21, 35
store i64 %22, i64* %3
%23 = load i64, i64* %3
%24 = load i64, i64* %4
%25 = icmp ugt i64 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %1
%27 = load i64, i64* %3
%28 = load i64, i64* %4
%29 = sub i64 %27, %28
%30 = sub i64 0, %29
%31 = load i64*, i64** %2
store i64 %30, i64* %31
br label %37
32: ; preds = %1
%33 = load i64, i64* %4
%34 = load i64, i64* %3
%35 = sub i64 %33, %34
%36 = load i64*, i64** %2
store i64 %35, i64* %36
br label %37
37: ; preds = %32, %26
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
define void @get_offset(i64* nocapture writeonly %0) {
%2 = alloca %struct.timespec
%3 = alloca %struct.timespec
%4 = bitcast %struct.timespec* %2 to i8*
%5 = bitcast %struct.timespec* %3 to i8*
%6 = call i32 @get_time(%struct.timespec* %3)
%7 = call i32 @get_pcie_time(%struct.timespec* %2)
%8 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
%9 = load i64, i64* %8
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
%13 = load i64, i64* %12
%14 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
%15 = load i64, i64* %14
%16 = sub i64 %9, %13
%17 = mul i64 %16, 1000000000
%18 = add i64 %11, 35
%19 = sub i64 %18, %15
%20 = add i64 %19, %17
store i64 %20, i64* %0
ret void
}