#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*/ 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 {
    {
      {
        output_char('E');
        output_char('R');
      };
      {
        output_char('R');
        output_char((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   1030 <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    11c7 <get_time_diff_and_update+0x97>
mov    $0x45,%edi
call   1040 <output_char@plt>
mov    $0x52,%edi
call   1040 <output_char@plt>
mov    $0x52,%edi
call   1040 <output_char@plt>
mov    $0xa,%edi
call   1040 <output_char@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11cf <get_time_diff_and_update+0x9f>
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     117e <get_time_diff_and_update+0x4e>
mov    $0x45,%edi
call   1040 <output_char@plt>
mov    $0x52,%edi
call   1040 <output_char@plt>
mov    $0x52,%edi
call   1040 <output_char@plt>
mov    $0xa,%edi
call   1040 <output_char@plt>
jmp    11a0 <get_time_diff_and_update+0x70>
mov    (%r15),%rdx
mov    (%r14),%rcx
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1030 <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 %28
22: ; preds = %2
%23 = call i32 @output_char(i32 69)
%24 = call i32 @output_char(i32 82)
%25 = call i32 @output_char(i32 82)
%26 = call i32 @output_char(i32 10)
%27 = load i64, i64* %8
store i64 %27, i64* %3
br label %29
28: ; preds = %12
store i64 0, i64* %3
br label %29
29: ; preds = %28, %22
%30 = load i64, i64* %3
ret i64 %30
}

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 %20
15: ; preds = %2
%16 = call i32 @output_char(i32 69)
%17 = call i32 @output_char(i32 82)
%18 = call i32 @output_char(i32 82)
%19 = call i32 @output_char(i32 10)
br label %20
20: ; preds = %9, %15
ret i64 %7
}