#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 scalar_t__ const time_t;
struct tm {
  int /*<<< orphan*/ tm_sec;
  int /*<<< orphan*/ tm_min;
  int /*<<< orphan*/ tm_hour;
  int /*<<< orphan*/ tm_yday;
  int /*<<< orphan*/ tm_year;
};

/* Variables and functions */
int CHAR_BIT;
scalar_t__ ydhms_diff(long, long, int, int, int, int /*<<< orphan*/,
                      int /*<<< orphan*/, int /*<<< orphan*/,
                      int /*<<< orphan*/, int /*<<< orphan*/);
time_t guess_time_tm(long int year, long int yday, int hour, int min, int sec,
                     const time_t *t, const struct tm *tp) {
  if (tp) {
    time_t d = ydhms_diff(year, yday, hour, min, sec, tp->tm_year, tp->tm_yday,
                          tp->tm_hour, tp->tm_min, tp->tm_sec);
    time_t t1 = *t + d;
    if ((t1 < *t) ==
        ((!((time_t)0 < (time_t)-1))
             ? d < 0
             : ((time_t)(!(!((time_t)0 < (time_t)-1))
                             ? (time_t)-1
                             : ~(~(time_t)0
                                 << (sizeof(time_t) * CHAR_BIT - 1)))) /
                       2 <
                   d))
      return t1;
  }
  return (
      *t < ((-1 >> 1 == -1
                 ? (((time_t)(!(!((time_t)0 < (time_t)-1)) ? (time_t)0
                              : ((time_t) ~(time_t)0 < (time_t)-1)
                                  ? ~(time_t)0
                                  : ~(time_t)0
                                        << (sizeof(time_t) * CHAR_BIT - 1))) +
                    ((time_t)(!(!((time_t)0 < (time_t)-1))
                                  ? (time_t)-1
                                  : ~(~(time_t)0
                                      << (sizeof(time_t) * CHAR_BIT - 1))))) >>
                       (1)
                 : (((time_t)(!(!((time_t)0 < (time_t)-1)) ? (time_t)0
                              : ((time_t) ~(time_t)0 < (time_t)-1)
                                  ? ~(time_t)0
                                  : ~(time_t)0
                                        << (sizeof(time_t) * CHAR_BIT - 1))) +
                    ((time_t)(!(!((time_t)0 < (time_t)-1))
                                  ? (time_t)-1
                                  : ~(~(time_t)0
                                      << (sizeof(time_t) * CHAR_BIT - 1))))) /
                           (1 << (1)) -
                       ((((time_t)(!(!((time_t)0 < (time_t)-1)) ? (time_t)0
                                   : ((time_t) ~(time_t)0 < (time_t)-1)
                                       ? ~(time_t)0
                                       : ~(time_t)0
                                             << (sizeof(time_t) * CHAR_BIT -
                                                 1))) +
                         ((time_t)(!(!((time_t)0 < (time_t)-1))
                                       ? (time_t)-1
                                       : ~(~(time_t)0
                                           << (sizeof(time_t) * CHAR_BIT -
                                               1))))) %
                            (1 << (1)) <
                        0)) +
            1)
          ? (*t <= ((time_t)(!(!((time_t)0 < (time_t)-1)) ? (time_t)0
                             : ((time_t) ~(time_t)0 < (time_t)-1)
                                 ? ~(time_t)0
                                 : ~(time_t)0
                                       << (sizeof(time_t) * CHAR_BIT - 1))) +
                         1
                 ? *t + 1
                 : ((time_t)(!(!((time_t)0 < (time_t)-1)) ? (time_t)0
                             : ((time_t) ~(time_t)0 < (time_t)-1)
                                 ? ~(time_t)0
                                 : ~(time_t)0
                                       << (sizeof(time_t) * CHAR_BIT - 1))))
          : (((time_t)(!(!((time_t)0 < (time_t)-1))
                           ? (time_t)-1
                           : ~(~(time_t)0
                               << (sizeof(time_t) * CHAR_BIT - 1)))) -
                         1 <=
                     *t
                 ? *t - 1
                 : ((time_t)(!(!((time_t)0 < (time_t)-1))
                                 ? (time_t)-1
                                 : ~(~(time_t)0
                                     << (sizeof(time_t) * CHAR_BIT - 1))))));
}


x86 assembly (clang, -O0):
<guess_time_tm>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x88,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %edx,-0x24(%rbp)
mov    %ecx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,0x10(%rbp)
je     11dc <guess_time_tm+0xcc>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
mov    0x10(%rbp),%rax
mov    0x10(%rax),%r9d
mov    0x10(%rbp),%rax
mov    0xc(%rax),%ebx
mov    0x10(%rbp),%rax
mov    0x8(%rax),%r11d
mov    0x10(%rbp),%rax
mov    0x4(%rax),%r10d
mov    0x10(%rbp),%rax
mov    (%rax),%eax
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1030 <ydhms_diff@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
cmpq   $0x0,-0x40(%rbp)
setl   %cl
and    $0x1,%cl
movzbl %cl,%ecx
cmp    %ecx,%eax
jne    11d7 <guess_time_tm+0xc7>
mov    -0x48(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1328 <guess_time_tm+0x218>
jmp    11dc <guess_time_tm+0xcc>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2df6(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
mov    %rdx,-0x50(%rbp)
mov    0x2dd6(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
mov    -0x50(%rbp),%rcx
xor    $0xffffffffffffffff,%rdx
add    %rdx,%rcx
sar    $0x1,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jge    12af <guess_time_tm+0x19f>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2d97(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
mov    %rdx,%rcx
add    $0x1,%rcx
cmp    %rcx,%rax
jg     1282 <guess_time_tm+0x172>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
add    $0x1,%rax
mov    %rax,-0x58(%rbp)
jmp    12a2 <guess_time_tm+0x192>
mov    0x2d57(%rip),%rax
movslq (%rax),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1320 <guess_time_tm+0x210>
mov    0x2d2a(%rip),%rax
movslq (%rax),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
xor    $0xffffffffffffffff,%rax
sub    $0x1,%rax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%rax
jg     12f4 <guess_time_tm+0x1e4>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
sub    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1318 <guess_time_tm+0x208>
mov    0x2ce5(%rip),%rax
movslq (%rax),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<guess_time_tm>:
push   %r14
push   %rbx
push   %rax
mov    %r9,%r14
mov    0x20(%rsp),%rax
test   %rax,%rax
je     1146 <guess_time_tm+0x36>
mov    0x10(%rax),%r9d
mov    0xc(%rax),%r10d
mov    0x8(%rax),%r11d
mov    (%rax),%ebx
mov    0x4(%rax),%eax
push   %rbx
push   %rax
push   %r11
push   %r10
call   1030 <ydhms_diff@plt>
add    $0x20,%rsp
add    (%r14),%rax
jmp    118c <guess_time_tm+0x7c>
mov    (%r14),%rdx
mov    0x2e90(%rip),%rax
mov    (%rax),%cl
shl    $0x3,%cl
add    $0xff,%cl
mov    $0xffffffffffffffff,%rsi
shl    %cl,%rsi
test   %rdx,%rdx
js     117d <guess_time_tm+0x6d>
mov    $0xfffffffffffffffe,%rcx
sub    %rsi,%rcx
not    %rsi
lea    -0x1(%rdx),%rax
cmp    %rdx,%rcx
jmp    1188 <guess_time_tm+0x78>
lea    0x1(%rsi),%rcx
lea    0x1(%rdx),%rax
cmp    %rcx,%rdx
cmovg  %rsi,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32 }
@CHAR_BIT = global i32 0
define i64 @guess_time_tm(i64 %0, i64 %1, i32 %2, i32 %3, i32 %4, i64* %5, %struct.tm* %6) {
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64*
%15 = alloca %struct.tm*
%16 = alloca i64
%17 = alloca i64
store i64 %0, i64* %9
store i64 %1, i64* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i64* %5, i64** %14
store %struct.tm* %6, %struct.tm** %15
%18 = load %struct.tm*, %struct.tm** %15
%19 = icmp ne %struct.tm* %18, null
br i1 %19, label %20, label %58
20: ; preds = %7
%21 = load i64, i64* %9
%22 = load i64, i64* %10
%23 = load i32, i32* %11
%24 = load i32, i32* %12
%25 = load i32, i32* %13
%26 = load %struct.tm*, %struct.tm** %15
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 4
%28 = load i32, i32* %27
%29 = load %struct.tm*, %struct.tm** %15
%30 = getelementptr inbounds %struct.tm, %struct.tm* %29, i32 0, i32 3
%31 = load i32, i32* %30
%32 = load %struct.tm*, %struct.tm** %15
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 2
%34 = load i32, i32* %33
%35 = load %struct.tm*, %struct.tm** %15
%36 = getelementptr inbounds %struct.tm, %struct.tm* %35, i32 0, i32 1
%37 = load i32, i32* %36
%38 = load %struct.tm*, %struct.tm** %15
%39 = getelementptr inbounds %struct.tm, %struct.tm* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = call i64 @ydhms_diff(i64 %21, i64 %22, i32 %23, i32 %24, i32 %25, i32 %28, i32 %31, i32 %34, i32 %37, i32 %40)
store i64 %41, i64* %16
%42 = load i64*, i64** %14
%43 = load i64, i64* %42
%44 = load i64, i64* %16
%45 = add nsw i64 %43, %44
store i64 %45, i64* %17
%46 = load i64, i64* %17
%47 = load i64*, i64** %14
%48 = load i64, i64* %47
%49 = icmp slt i64 %46, %48
%50 = zext i1 %49 to i32
%51 = load i64, i64* %16
%52 = icmp slt i64 %51, 0
%53 = zext i1 %52 to i32
%54 = icmp eq i32 %50, %53
br i1 %54, label %55, label %57
55: ; preds = %20
%56 = load i64, i64* %17
store i64 %56, i64* %8
br label %124
57: ; preds = %20
br label %58
58: ; preds = %57, %7
%59 = load i64*, i64** %14
%60 = load i64, i64* %59
%61 = load i32, i32* @CHAR_BIT
%62 = sext i32 %61 to i64
%63 = mul i64 8, %62
%64 = sub i64 %63, 1
%65 = shl i64 -1, %64
%66 = load i32, i32* @CHAR_BIT
%67 = sext i32 %66 to i64
%68 = mul i64 8, %67
%69 = sub i64 %68, 1
%70 = shl i64 -1, %69
%71 = xor i64 %70, -1
%72 = add nsw i64 %65, %71
%73 = ashr i64 %72, 1
%74 = add nsw i64 %73, 1
%75 = icmp slt i64 %60, %74
br i1 %75, label %76, label %98
76: ; preds = %58
%77 = load i64*, i64** %14
%78 = load i64, i64* %77
%79 = load i32, i32* @CHAR_BIT
%80 = sext i32 %79 to i64
%81 = mul i64 8, %80
%82 = sub i64 %81, 1
%83 = shl i64 -1, %82
%84 = add nsw i64 %83, 1
%85 = icmp sle i64 %78, %84
br i1 %85, label %86, label %90
86: ; preds = %76
%87 = load i64*, i64** %14
%88 = load i64, i64* %87
%89 = add nsw i64 %88, 1
br label %96
90: ; preds = %76
%91 = load i32, i32* @CHAR_BIT
%92 = sext i32 %91 to i64
%93 = mul i64 8, %92
%94 = sub i64 %93, 1
%95 = shl i64 -1, %94
br label %96
96: ; preds = %90, %86
%97 = phi i64 [ %89, %86 ], [ %95, %90 ]
br label %122
98: ; preds = %58
%99 = load i32, i32* @CHAR_BIT
%100 = sext i32 %99 to i64
%101 = mul i64 8, %100
%102 = sub i64 %101, 1
%103 = shl i64 -1, %102
%104 = xor i64 %103, -1
%105 = sub nsw i64 %104, 1
%106 = load i64*, i64** %14
%107 = load i64, i64* %106
%108 = icmp sle i64 %105, %107
br i1 %108, label %109, label %113
109: ; preds = %98
%110 = load i64*, i64** %14
%111 = load i64, i64* %110
%112 = sub nsw i64 %111, 1
br label %120
113: ; preds = %98
%114 = load i32, i32* @CHAR_BIT
%115 = sext i32 %114 to i64
%116 = mul i64 8, %115
%117 = sub i64 %116, 1
%118 = shl i64 -1, %117
%119 = xor i64 %118, -1
br label %120
120: ; preds = %113, %109
%121 = phi i64 [ %112, %109 ], [ %119, %113 ]
br label %122
122: ; preds = %120, %96
%123 = phi i64 [ %97, %96 ], [ %121, %120 ]
store i64 %123, i64* %8
br label %124
124: ; preds = %122, %55
%125 = load i64, i64* %8
ret i64 %125
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32 }
@CHAR_BIT = global i32 0
define i64 @guess_time_tm(i64 %0, i64 %1, i32 %2, i32 %3, i32 %4, i64* nocapture %5, %struct.tm* %6) {
%8 = icmp eq %struct.tm* %6, null
br i1 %8, label %23, label %9
9: ; preds = %7
%10 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 4
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 3
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%19 = load i32, i32* %18
%20 = tail call i64 @ydhms_diff(i64 %0, i64 %1, i32 %2, i32 %3, i32 %4, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = load i64, i64* %5
%22 = add nsw i64 %21, %20
br label %42
23: ; preds = %7
%24 = load i64, i64* %5
%25 = load i32, i32* @CHAR_BIT
%26 = sext i32 %25 to i64
%27 = shl nsw i64 %26, 3
%28 = add nsw i64 %27, -1
%29 = shl nsw i64 -1, %28
%30 = icmp slt i64 %24, 0
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = add nsw i64 %29, 1
%33 = icmp sgt i64 %24, %32
%34 = add nsw i64 %24, 1
%35 = select i1 %33, i64 %29, i64 %34
br label %42
36: ; preds = %23
%37 = xor i64 %29, -1
%38 = sub nsw i64 -2, %29
%39 = icmp sgt i64 %38, %24
%40 = add nsw i64 %24, -1
%41 = select i1 %39, i64 %37, i64 %40
br label %42
42: ; preds = %9, %36, %31
%43 = phi i64 [ %22, %9 ], [ %35, %31 ], [ %41, %36 ]
ret i64 %43
}