#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_char(int);
int /*<<< orphan*/ output_q(long);
int /*<<< orphan*/ output_q_digits(long, int);
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);
    output_char('.');
    output_q_digits(tnsec, 9);
  } else {
    {
      {
        output_char('E');
        output_char('R');
      };
      {
        output_char('R');
        output_char((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   1070 <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    11e3 <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   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)
mov    -0x30(%rbp),%rdi
call   1030 <output_q@plt>
mov    $0x2e,%edi
call   1050 <output_char@plt>
mov    -0x38(%rbp),%rdi
mov    $0x9,%esi
call   1060 <output_q_digits@plt>
jmp    1218 <print_time_diff_and_update+0xc8>
mov    $0x45,%edi
call   1050 <output_char@plt>
mov    $0x52,%edi
call   1050 <output_char@plt>
mov    $0x52,%edi
call   1050 <output_char@plt>
mov    $0xa,%edi
call   1050 <output_char@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1220 <print_time_diff_and_update+0xd0>
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   1070 <gettime@plt>
mov    %rax,%rbx
mov    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,(%rsp)
test   %rbx,%rbx
je     11b3 <print_time_diff_and_update+0x63>
mov    $0x45,%edi
call   1050 <output_char@plt>
mov    $0x52,%edi
call   1050 <output_char@plt>
mov    $0x52,%edi
call   1050 <output_char@plt>
mov    $0xa,%edi
call   1050 <output_char@plt>
jmp    11f8 <print_time_diff_and_update+0xa8>
mov    (%r15),%rdx
mov    (%r14),%rcx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <time_subtract@plt>
mov    0x18(%rsp),%rax
mov    %rax,(%r15)
mov    0x10(%rsp),%rax
mov    %rax,(%r14)
mov    0x8(%rsp),%rdi
call   1030 <output_q@plt>
mov    $0x2e,%edi
call   1050 <output_char@plt>
mov    (%rsp),%rdi
mov    $0x9,%esi
call   1060 <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 @output_char(i32 46)
%29 = load i64, i64* %9
%30 = call i32 @output_q_digits(i64 %29, i32 9)
br label %37
31: ; preds = %2
%32 = call i32 @output_char(i32 69)
%33 = call i32 @output_char(i32 82)
%34 = call i32 @output_char(i32 82)
%35 = call i32 @output_char(i32 10)
%36 = load i64, i64* %10
store i64 %36, i64* %3
br label %38
37: ; preds = %16
store i64 0, i64* %3
br label %38
38: ; preds = %37, %31
%39 = load i64, i64* %3
ret i64 %39
}

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 @output_char(i32 46)
%24 = load i64, i64* %6
%25 = call i32 @output_q_digits(i64 %24, i32 9)
br label %31
26: ; preds = %2
%27 = call i32 @output_char(i32 69)
%28 = call i32 @output_char(i32 82)
%29 = call i32 @output_char(i32 82)
%30 = call i32 @output_char(i32 10)
br label %31
31: ; preds = %15, %26
ret i64 %11
}