#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 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);
int get_sec_diff();
scalar_t__ get_utc_timestamp_sec_diff(int, struct tm *);
int mktime(struct tm *);
int /*<<< orphan*/ stderr;
time_t get_utc_timestamp(const struct tm *utc_tm) {
  struct tm copy_tm = *utc_tm;
  time_t utc_ts = mktime(&copy_tm);
  if (utc_ts == -1) {
    fprintf(stderr, "pgtime:%s:%d: couldn't get calendar 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",
            704);
    exit(EXIT_FAILURE);
  }
  int secs_diff = get_utc_timestamp_sec_diff(utc_ts, &copy_tm);
  if (secs_diff) {
    const time_t one_sec = get_sec_diff();
    utc_ts -= one_sec * secs_diff;
    secs_diff = get_utc_timestamp_sec_diff(utc_ts, &copy_tm);
    if (secs_diff) {
      if (get_utc_timestamp_sec_diff(utc_ts + one_sec, &copy_tm) == 0) {
        utc_ts += one_sec;
      } else if (get_utc_timestamp_sec_diff(utc_ts - one_sec, &copy_tm) == 0) {
        utc_ts -= one_sec;
      } else {
        fprintf(stderr, "pgtime:%s:%d: couldn't get calendar 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",
                732);
        exit(EXIT_FAILURE);
      }
    }
  }
  return utc_ts;
}


x86 assembly (clang, -O0):
<get_utc_timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
call   1040 <mktime@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    11aa <get_utc_timestamp+0x5a>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
lea    0xe99(%rip),%rdx
mov    $0x2c0,%ecx
call   1030 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <get_utc_timestamp_sec_diff@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1283 <get_utc_timestamp+0x133>
mov    $0x0,%al
call   1060 <get_sec_diff@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
imul   -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <get_utc_timestamp_sec_diff@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     127e <get_utc_timestamp+0x12e>
mov    -0x14(%rbp),%edi
add    -0x1c(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <get_utc_timestamp_sec_diff@plt>
cmp    $0x0,%rax
jne    121c <get_utc_timestamp+0xcc>
mov    -0x1c(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1279 <get_utc_timestamp+0x129>
mov    -0x14(%rbp),%edi
sub    -0x1c(%rbp),%edi
lea    -0x10(%rbp),%rsi
call   1050 <get_utc_timestamp_sec_diff@plt>
cmp    $0x0,%rax
jne    1245 <get_utc_timestamp+0xf5>
mov    -0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    1274 <get_utc_timestamp+0x124>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
lea    0xdcf(%rip),%rdx
mov    $0x2dc,%ecx
call   1030 <fprintf@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1279 <get_utc_timestamp+0x129>
jmp    127e <get_utc_timestamp+0x12e>
jmp    1283 <get_utc_timestamp+0x133>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_utc_timestamp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%eax
mov    %eax,(%rsp)
mov    %rsp,%rdi
call   1040 <mktime@plt>
cmp    $0xffffffff,%eax
je     11f8 <get_utc_timestamp+0xa8>
mov    %eax,%ebx
mov    %rsp,%rsi
mov    %eax,%edi
call   1050 <get_utc_timestamp_sec_diff@plt>
mov    %rax,%rbp
mov    %ebx,%r15d
test   %ebp,%ebp
je     11ea <get_utc_timestamp+0x9a>
xor    %eax,%eax
call   1060 <get_sec_diff@plt>
mov    %eax,%r14d
imul   %eax,%ebp
sub    %ebp,%ebx
mov    %rsp,%rsi
mov    %ebx,%edi
call   1050 <get_utc_timestamp_sec_diff@plt>
test   %eax,%eax
je     11e7 <get_utc_timestamp+0x97>
lea    (%rbx,%r14,1),%r15d
mov    %rsp,%rsi
mov    %r15d,%edi
call   1050 <get_utc_timestamp_sec_diff@plt>
test   %rax,%rax
je     11ea <get_utc_timestamp+0x9a>
sub    %r14d,%ebx
mov    %rsp,%rsi
mov    %ebx,%edi
call   1050 <get_utc_timestamp_sec_diff@plt>
mov    %ebx,%r15d
test   %rax,%rax
je     11ea <get_utc_timestamp+0x9a>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe27(%rip),%rsi
lea    0xe4b(%rip),%rdx
mov    $0x2dc,%ecx
jmp    1214 <get_utc_timestamp+0xc4>
mov    %ebx,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
lea    0xe1c(%rip),%rdx
mov    $0x2c0,%ecx
call   1030 <fprintf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [43 x i8] c"pgtime:%s:%d: couldn't get calendar 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 @get_utc_timestamp(%struct.tm* %0) {
%2 = alloca %struct.tm*
%3 = alloca %struct.tm
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.tm* %0, %struct.tm** %2
%7 = load %struct.tm*, %struct.tm** %2
%8 = bitcast %struct.tm* %3 to i8*
%9 = bitcast %struct.tm* %7 to i8*
%10 = call i32 @mktime(%struct.tm* %3)
store i32 %10, i32* %4
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 704)
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = load i32, i32* %4
%20 = call i64 @get_utc_timestamp_sec_diff(i32 %19, %struct.tm* %3)
%21 = trunc i64 %20 to i32
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %64
24: ; preds = %18
%25 = call i32 (...) @get_sec_diff()
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %4
%30 = sub nsw i32 %29, %28
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = call i64 @get_utc_timestamp_sec_diff(i32 %31, %struct.tm* %3)
%33 = trunc i64 %32 to i32
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %63
36: ; preds = %24
%37 = load i32, i32* %4
%38 = load i32, i32* %6
%39 = add nsw i32 %37, %38
%40 = call i64 @get_utc_timestamp_sec_diff(i32 %39, %struct.tm* %3)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %36
%43 = load i32, i32* %6
%44 = load i32, i32* %4
%45 = add nsw i32 %44, %43
store i32 %45, i32* %4
br label %62
46: ; preds = %36
%47 = load i32, i32* %4
%48 = load i32, i32* %6
%49 = sub nsw i32 %47, %48
%50 = call i64 @get_utc_timestamp_sec_diff(i32 %49, %struct.tm* %3)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %46
%53 = load i32, i32* %6
%54 = load i32, i32* %4
%55 = sub nsw i32 %54, %53
store i32 %55, i32* %4
br label %61
56: ; preds = %46
%57 = load i32, i32* @stderr
%58 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 732)
%59 = load i32, i32* @EXIT_FAILURE
%60 = call i32 @exit(i32 %59)
unreachable
61: ; preds = %52
br label %62
62: ; preds = %61, %42
br label %63
63: ; preds = %62, %24
br label %64
64: ; preds = %63, %18
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [43 x i8] c"pgtime:%s:%d: couldn't get calendar 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 @get_utc_timestamp(%struct.tm* nocapture %0) {
%2 = alloca %struct.tm
%3 = bitcast %struct.tm* %2 to i8*
%4 = getelementptr %struct.tm, %struct.tm* %0, i64 0, i32 0
%5 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%6 = load i32, i32* %4
store i32 %6, i32* %5
%7 = call i32 @mktime(%struct.tm* %2)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 704)
%12 = load i32, i32* @EXIT_FAILURE
%13 = tail call i32 @exit(i32 %12)
unreachable
14: ; preds = %1
%15 = call i64 @get_utc_timestamp_sec_diff(i32 %7, %struct.tm* %2)
%16 = trunc i64 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %38, label %18
18: ; preds = %14
%19 = call i32 (...) @get_sec_diff()
%20 = mul nsw i32 %19, %16
%21 = sub nsw i32 %7, %20
%22 = call i64 @get_utc_timestamp_sec_diff(i32 %21, %struct.tm* %2)
%23 = trunc i64 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %38, label %25
25: ; preds = %18
%26 = add nsw i32 %21, %19
%27 = call i64 @get_utc_timestamp_sec_diff(i32 %26, %struct.tm* %2)
%28 = icmp eq i64 %27, 0
br i1 %28, label %38, label %29
29: ; preds = %25
%30 = sub nsw i32 %21, %19
%31 = call i64 @get_utc_timestamp_sec_diff(i32 %30, %struct.tm* %2)
%32 = icmp eq i64 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str.1, i64 0, i64 0), i32 732)
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %18, %25, %29, %14
%39 = phi i32 [ %7, %14 ], [ %21, %18 ], [ %26, %25 ], [ %30, %29 ]
ret i32 %39
}