#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 uint64_t;
typedef int uint32_t;
struct timespec {
  scalar_t__ tv_sec;
  int tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void timespec_to_proto(const struct timespec *a, uint32_t *tv_sec_hi,
                       uint32_t *tv_sec_lo, uint32_t *tv_nsec) {
  assert(a->tv_sec >= 0);
  assert(a->tv_nsec >= 0 && a->tv_nsec < 1000000000);
  uint64_t sec64 = a->tv_sec;
  *tv_sec_hi = sec64 >> 32;
  *tv_sec_lo = sec64 & 0xffffffff;
  *tv_nsec = a->tv_nsec;
}


x86 assembly (clang, -O0):
<timespec_to_proto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmpl   $0x0,0x8(%rcx)
mov    %al,-0x25(%rbp)
jl     1161 <timespec_to_proto+0x51>
mov    -0x8(%rbp),%rax
cmpl   $0x3b9aca00,0x8(%rax)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
and    $0xffffffff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timespec_to_proto>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
mov    (%rdi),%rdi
shr    $0x3f,%rdi
xor    $0x1,%edi
call   1030 <assert@plt>
xor    %edi,%edi
cmpl   $0x3b9aca00,0x8(%rbx)
setb   %dil
call   1030 <assert@plt>
mov    (%rbx),%eax
mov    %eax,(%r15)
mov    0x8(%rbx),%eax
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
define void @timespec_to_proto(%struct.timespec* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca %struct.timespec*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store %struct.timespec* %0, %struct.timespec** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load %struct.timespec*, %struct.timespec** %5
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%12 = load i64, i64* %11
%13 = icmp sge i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load %struct.timespec*, %struct.timespec** %5
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%18 = load i32, i32* %17
%19 = icmp sge i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %4
%21 = load %struct.timespec*, %struct.timespec** %5
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = icmp slt i32 %23, 1000000000
br label %25
25: ; preds = %20, %4
%26 = phi i1 [ false, %4 ], [ %24, %20 ]
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
%29 = load %struct.timespec*, %struct.timespec** %5
%30 = getelementptr inbounds %struct.timespec, %struct.timespec* %29, i32 0, i32 0
%31 = load i64, i64* %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = ashr i32 %33, 32
%35 = load i32*, i32** %6
store i32 %34, i32* %35
%36 = load i32, i32* %9
%37 = and i32 %36, -1
%38 = load i32*, i32** %7
store i32 %37, i32* %38
%39 = load %struct.timespec*, %struct.timespec** %5
%40 = getelementptr inbounds %struct.timespec, %struct.timespec* %39, i32 0, i32 1
%41 = load i32, i32* %40
%42 = load i32*, i32** %8
store i32 %41, i32* %42
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
define void @timespec_to_proto(%struct.timespec* nocapture %0, i32* nocapture readnone %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 0
%6 = load i64, i64* %5
%7 = lshr i64 %6, 63
%8 = trunc i64 %7 to i32
%9 = xor i32 %8, 1
%10 = tail call i32 @assert(i32 %9)
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %0, i64 0, i32 1
%12 = load i32, i32* %11
%13 = icmp ult i32 %12, 1000000000
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = load i64, i64* %5
%17 = trunc i64 %16 to i32
store i32 %17, i32* %2
%18 = load i32, i32* %11
store i32 %18, i32* %3
ret void
}