#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*/ uint8_t;
typedef int /*<<< orphan*/ uint64_t;
struct timeval {
  scalar_t__ tv_sec;
  int /*<<< orphan*/ tv_usec;
};

/* Variables and functions */
scalar_t__ sdnv_decode(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int ar_sr_extract_time_of(uint8_t *ar, struct timeval *tv) {
  int off = 3;
  off += sdnv_decode((uint8_t *)ar + off, (uint64_t *)&tv->tv_sec);
  sdnv_decode((uint8_t *)ar + off, (uint64_t *)&tv->tv_usec);
  tv->tv_sec += 946684800;
  return 0;
}


x86 assembly (clang, -O0):
<ar_sr_extract_time_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <sdnv_decode@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
add    $0x8,%rsi
call   1030 <sdnv_decode@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x386d4380,%rcx
mov    %rcx,(%rax)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ar_sr_extract_time_of>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0xc,%rdi
call   1030 <sdnv_decode@plt>
shl    $0x20,%rax
movabs $0x300000000,%rdi
add    %rax,%rdi
sar    $0x1e,%rdi
add    %r14,%rdi
lea    0x8(%rbx),%rsi
call   1030 <sdnv_decode@plt>
addq   $0x386d4380,(%rbx)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
define i32 @ar_sr_extract_time_of(i32* %0, %struct.timeval* %1) {
%3 = alloca i32*
%4 = alloca %struct.timeval*
%5 = alloca i32
store i32* %0, i32** %3
store %struct.timeval* %1, %struct.timeval** %4
store i32 3, i32* %5
%6 = load i32*, i32** %3
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %6, i64 %8
%10 = load %struct.timeval*, %struct.timeval** %4
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %10, i32 0, i32 0
%12 = bitcast i64* %11 to i32*
%13 = call i64 @sdnv_decode(i32* %9, i32* %12)
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %5
%18 = load i32*, i32** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load %struct.timeval*, %struct.timeval** %4
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %22, i32 0, i32 1
%24 = call i64 @sdnv_decode(i32* %21, i32* %23)
%25 = load %struct.timeval*, %struct.timeval** %4
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = add nsw i64 %27, 946684800
store i64 %28, i64* %26
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
define i32 @ar_sr_extract_time_of(i32* %0, %struct.timeval* %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 3
%4 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%5 = bitcast %struct.timeval* %1 to i32*
%6 = tail call i64 @sdnv_decode(i32* %3, i32* %5)
%7 = shl i64 %6, 32
%8 = add i64 %7, 12884901888
%9 = ashr exact i64 %8, 32
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%12 = tail call i64 @sdnv_decode(i32* %10, i32* %11)
%13 = load i64, i64* %4
%14 = add nsw i64 %13, 946684800
store i64 %14, i64* %4
ret i32 0
}