#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 */

/* Variables and functions */
long gettime(long *, long *);
int /*<<< orphan*/ put4(char, char, char, int);
int /*<<< orphan*/ time_subtract(long *, long *, long, long);
long get_time_diff_and_update(long *base_sec, long *base_nsec) {
  long sec;
  long nsec;
  long rt;
  rt = gettime(&sec, &nsec);
  if (rt == 0) {
    time_subtract(&sec, &nsec, *base_sec, *base_nsec);
    *base_sec = sec;
    *base_nsec = nsec;
  } else {
    put4('E', 'R', 'R', (10));
    return rt;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_time_diff_and_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <gettime@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1192 <get_time_diff_and_update+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <time_subtract@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11b5 <get_time_diff_and_update+0x85>
mov    $0x45,%edi
mov    $0x52,%edx
mov    $0xa,%ecx
mov    %edx,%esi
call   1030 <put4@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11bd <get_time_diff_and_update+0x8d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time_diff_and_update>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1050 <gettime@plt>
mov    %rax,%rbx
test   %rax,%rax
je     116f <get_time_diff_and_update+0x3f>
mov    $0x45,%edi
mov    $0x52,%esi
mov    $0x52,%edx
mov    $0xa,%ecx
call   1030 <put4@plt>
jmp    1191 <get_time_diff_and_update+0x61>
mov    (%r15),%rdx
mov    (%r14),%rcx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <time_subtract@plt>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
mov    (%rsp),%rax
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @get_time_diff_and_update(i64* %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i64*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64* %0, i64** %4
store i64* %1, i64** %5
%9 = call i64 @gettime(i64* %6, i64* %7)
store i64 %9, i64* %8
%10 = load i64, i64* %8
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %2
%13 = load i64*, i64** %4
%14 = load i64, i64* %13
%15 = load i64*, i64** %5
%16 = load i64, i64* %15
%17 = call i32 @time_subtract(i64* %6, i64* %7, i64 %14, i64 %16)
%18 = load i64, i64* %6
%19 = load i64*, i64** %4
store i64 %18, i64* %19
%20 = load i64, i64* %7
%21 = load i64*, i64** %5
store i64 %20, i64* %21
br label %25
22: ; preds = %2
%23 = call i32 @put4(i8 signext 69, i8 signext 82, i8 signext 82, i32 10)
%24 = load i64, i64* %8
store i64 %24, i64* %3
br label %26
25: ; preds = %12
store i64 0, i64* %3
br label %26
26: ; preds = %25, %22
%27 = load i64, i64* %3
ret i64 %27
}

LLVM IR (-O2):
define i64 @get_time_diff_and_update(i64* nocapture %0, i64* nocapture %1) {
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i64* %3 to i8*
%6 = bitcast i64* %4 to i8*
%7 = call i64 @gettime(i64* %3, i64* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i64, i64* %0
%11 = load i64, i64* %1
%12 = call i32 @time_subtract(i64* %3, i64* %4, i64 %10, i64 %11)
%13 = load i64, i64* %3
store i64 %13, i64* %0
%14 = load i64, i64* %4
store i64 %14, i64* %1
br label %17
15: ; preds = %2
%16 = call i32 @put4(i8 signext 69, i8 signext 82, i8 signext 82, i32 10)
br label %17
17: ; preds = %9, %15
ret i64 %7
}