#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*/ output_q(long);
int /*<<< orphan*/ output_q_digits(long, int);
int /*<<< orphan*/ put4(char, char, char, int);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ time_subtract(long *, long *, long, long);
long print_time_diff_and_update(long *base_sec, long *base_nsec) {
  long sec;
  long nsec;
  long tsec;
  long tnsec;
  long rt;
  rt = gettime(&sec, &nsec);
  tsec = sec;
  tnsec = nsec;
  if (rt == 0) {
    time_subtract(&tsec, &tnsec, *base_sec, *base_nsec);
    *base_sec = sec;
    *base_nsec = nsec;
    output_q(tsec);
    putchar('.');
    output_q_digits(tnsec, 9);
  } else {
    put4('E', 'R', 'R', (10));
    return rt;
  }
  return 0;
}


x86 assembly (clang, -O0):
<print_time_diff_and_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <gettime@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11f3 <print_time_diff_and_update+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1060 <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)
mov    -0x30(%rbp),%rdi
call   1050 <output_q@plt>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    -0x38(%rbp),%rdi
mov    $0x9,%esi
call   1070 <output_q_digits@plt>
jmp    1216 <print_time_diff_and_update+0xb6>
mov    $0x45,%edi
mov    $0x52,%edx
mov    $0xa,%ecx
mov    %edx,%esi
call   1030 <put4@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    121e <print_time_diff_and_update+0xbe>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time_diff_and_update>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0x18(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1080 <gettime@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,(%rsp)
test   %rbx,%rbx
je     11b4 <print_time_diff_and_update+0x54>
mov    $0x45,%edi
mov    $0x52,%esi
mov    $0x52,%edx
mov    $0xa,%ecx
call   1030 <put4@plt>
jmp    11f9 <print_time_diff_and_update+0x99>
mov    (%r15),%rdx
mov    (%r14),%rcx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <time_subtract@plt>
mov    0x18(%rsp),%rax
mov    %rax,(%r15)
mov    0x10(%rsp),%rax
mov    %rax,(%r14)
mov    0x8(%rsp),%rdi
call   1050 <output_q@plt>
mov    $0x2e,%edi
call   1040 <putchar@plt>
mov    (%rsp),%rdi
mov    $0x9,%esi
call   1070 <output_q_digits@plt>
mov    %rbx,%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @print_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
%9 = alloca i64
%10 = alloca i64
store i64* %0, i64** %4
store i64* %1, i64** %5
%11 = call i64 @gettime(i64* %6, i64* %7)
store i64 %11, i64* %10
%12 = load i64, i64* %6
store i64 %12, i64* %8
%13 = load i64, i64* %7
store i64 %13, i64* %9
%14 = load i64, i64* %10
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %31
16: ; preds = %2
%17 = load i64*, i64** %4
%18 = load i64, i64* %17
%19 = load i64*, i64** %5
%20 = load i64, i64* %19
%21 = call i32 @time_subtract(i64* %8, i64* %9, i64 %18, i64 %20)
%22 = load i64, i64* %6
%23 = load i64*, i64** %4
store i64 %22, i64* %23
%24 = load i64, i64* %7
%25 = load i64*, i64** %5
store i64 %24, i64* %25
%26 = load i64, i64* %8
%27 = call i32 @output_q(i64 %26)
%28 = call i32 @putchar(i8 signext 46)
%29 = load i64, i64* %9
%30 = call i32 @output_q_digits(i64 %29, i32 9)
br label %34
31: ; preds = %2
%32 = call i32 @put4(i8 signext 69, i8 signext 82, i8 signext 82, i32 10)
%33 = load i64, i64* %10
store i64 %33, i64* %3
br label %35
34: ; preds = %16
store i64 0, i64* %3
br label %35
35: ; preds = %34, %31
%36 = load i64, i64* %3
ret i64 %36
}

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