#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 /*<<< orphan*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
struct tm *gmtime(int /*<<< orphan*/ const *);
int /*<<< orphan*/ stderr;
scalar_t__ tm_compare(struct tm const *, struct tm *);
int tm_intraday_secs_diff(struct tm const *, struct tm *);
bool check_utc_timestamp(const time_t check_time, int *secs_diff,
                         const struct tm *check_tm) {
  struct tm *ptm = gmtime(&check_time);
  if (ptm == 0) {
    fprintf(stderr, "pgtime:%s:%d: couldn't get UTC time.\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/paulgriffiths/pgtime/refs/heads/master/"
            "pgtime.c",
            71);
    exit(EXIT_FAILURE);
  }
  struct tm compare_tm = *ptm;
  bool agrees = tm_compare(check_tm, &compare_tm) ? false : true;
  if (agrees) {
    *secs_diff = 0;
  } else {
    *secs_diff = tm_intraday_secs_diff(check_tm, &compare_tm);
  }
  return agrees;
}


x86 assembly (clang, -O0):
<check_utc_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x4(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11aa <check_utc_timestamp+0x5a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
lea    0xe94(%rip),%rdx
mov    $0x47,%ecx
call   1040 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <tm_compare@plt>
mov    %rax,%rdx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11ed <check_utc_timestamp+0x9d>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    1202 <check_utc_timestamp+0xb2>
mov    -0x18(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1050 <tm_intraday_secs_diff@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_utc_timestamp>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1060 <gmtime@plt>
test   %rax,%rax
je     11b5 <check_utc_timestamp+0x65>
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1030 <tm_compare@plt>
mov    %rax,%rbx
test   %rax,%rax
je     119c <check_utc_timestamp+0x4c>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1050 <tm_intraday_secs_diff@plt>
jmp    119e <check_utc_timestamp+0x4e>
xor    %eax,%eax
xor    %ecx,%ecx
test   %rbx,%rbx
sete   %cl
mov    %eax,(%r14)
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
lea    0xe5a(%rip),%rdx
mov    $0x47,%ecx
call   1040 <fprintf@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [38 x i8] c"pgtime:%s:%d: couldn't get UTC time.\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/paulgriffiths/pgtime/refs/heads/master/pgtime.c\00"
@EXIT_FAILURE = global i32 0
define i32 @check_utc_timestamp(i32 %0, i32* %1, %struct.tm* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.tm*
%7 = alloca %struct.tm*
%8 = alloca %struct.tm
%9 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store %struct.tm* %2, %struct.tm** %6
%10 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %10, %struct.tm** %7
%11 = load %struct.tm*, %struct.tm** %7
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 71)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %3
%19 = load %struct.tm*, %struct.tm** %7
%20 = bitcast %struct.tm* %8 to i8*
%21 = bitcast %struct.tm* %19 to i8*
%22 = load %struct.tm*, %struct.tm** %6
%23 = call i64 @tm_compare(%struct.tm* %22, %struct.tm* %8)
%24 = icmp ne i64 %23, 0
%25 = zext i1 %24 to i64
%26 = select i1 %24, i32 0, i32 1
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %18
%30 = load i32*, i32** %5
store i32 0, i32* %30
br label %35
31: ; preds = %18
%32 = load %struct.tm*, %struct.tm** %6
%33 = call i32 @tm_intraday_secs_diff(%struct.tm* %32, %struct.tm* %8)
%34 = load i32*, i32** %5
store i32 %33, i32* %34
br label %35
35: ; preds = %31, %29
%36 = load i32, i32* %9
ret i32 %36
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [38 x i8] c"pgtime:%s:%d: couldn't get UTC time.\0A\00"
@.str.1 = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/paulgriffiths/pgtime/refs/heads/master/pgtime.c\00"
@EXIT_FAILURE = global i32 0
define i32 @check_utc_timestamp(i32 %0, i32* nocapture writeonly %1, %struct.tm* %2) {
%4 = alloca i32
%5 = alloca %struct.tm
store i32 %0, i32* %4
%6 = call %struct.tm* @gmtime(i32* %4)
%7 = icmp eq %struct.tm* %6, null
br i1 %7, label %8, label %13
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 71)
%11 = load i32, i32* @EXIT_FAILURE
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %3
%14 = bitcast %struct.tm* %5 to i8*
%15 = getelementptr %struct.tm, %struct.tm* %6, i64 0, i32 0
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%17 = load i32, i32* %15
store i32 %17, i32* %16
%18 = call i64 @tm_compare(%struct.tm* %2, %struct.tm* %5)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %13
%21 = call i32 @tm_intraday_secs_diff(%struct.tm* %2, %struct.tm* %5)
br label %22
22: ; preds = %13, %20
%23 = phi i32 [ %21, %20 ], [ 0, %13 ]
store i32 %23, i32* %1
%24 = zext i1 %19 to i32
ret i32 %24
}