#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)
          ? ((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))) +
                (*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))))
          : ((time_t)(!(!((time_t)0 < (time_t)-1))
                          ? (time_t)-1
                          : ~(~(time_t)0 << (sizeof(time_t) * CHAR_BIT - 1)))) -
                (*t ==
                 ((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    130a <guess_time_tm+0x1fa>
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    129d <guess_time_tm+0x18d>
mov    0x2d9e(%rip),%rax
movslq (%rax),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
mov    -0x38(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,-0x60(%rbp)
mov    0x2d77(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
mov    -0x60(%rbp),%rcx
cmp    %rdx,%rcx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x58(%rbp)
jmp    1302 <guess_time_tm+0x1f2>
mov    0x2d3c(%rip),%rax
movslq (%rax),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rax
shl    %cl,%rax
xor    $0xffffffffffffffff,%rax
mov    -0x38(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,-0x68(%rbp)
mov    0x2d11(%rip),%rcx
movslq (%rcx),%rcx
shl    $0x3,%rcx
sub    $0x1,%rcx
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
mov    -0x68(%rbp),%rcx
xor    $0xffffffffffffffff,%rdx
cmp    %rdx,%rcx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
movslq %ecx,%rcx
sub    %rcx,%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%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    1185 <guess_time_tm+0x75>
mov    (%r14),%rsi
mov    0x2e90(%rip),%rax
mov    (%rax),%cl
shl    $0x3,%cl
add    $0xff,%cl
mov    $0xffffffffffffffff,%rdx
shl    %cl,%rdx
test   %rsi,%rsi
js     117a <guess_time_tm+0x6a>
not    %rdx
xor    %eax,%eax
cmp    %rdx,%rsi
sete   %al
sub    %rax,%rdx
mov    %rdx,%rax
jmp    1185 <guess_time_tm+0x75>
xor    %eax,%eax
cmp    %rdx,%rsi
sete   %al
add    %rdx,%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 %114
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 %93
76: ; preds = %58
%77 = load i32, i32* @CHAR_BIT
%78 = sext i32 %77 to i64
%79 = mul i64 8, %78
%80 = sub i64 %79, 1
%81 = shl i64 -1, %80
%82 = load i64*, i64** %14
%83 = load i64, i64* %82
%84 = load i32, i32* @CHAR_BIT
%85 = sext i32 %84 to i64
%86 = mul i64 8, %85
%87 = sub i64 %86, 1
%88 = shl i64 -1, %87
%89 = icmp eq i64 %83, %88
%90 = zext i1 %89 to i32
%91 = sext i32 %90 to i64
%92 = add nsw i64 %81, %91
br label %112
93: ; preds = %58
%94 = load i32, i32* @CHAR_BIT
%95 = sext i32 %94 to i64
%96 = mul i64 8, %95
%97 = sub i64 %96, 1
%98 = shl i64 -1, %97
%99 = xor i64 %98, -1
%100 = load i64*, i64** %14
%101 = load i64, i64* %100
%102 = load i32, i32* @CHAR_BIT
%103 = sext i32 %102 to i64
%104 = mul i64 8, %103
%105 = sub i64 %104, 1
%106 = shl i64 -1, %105
%107 = xor i64 %106, -1
%108 = icmp eq i64 %101, %107
%109 = zext i1 %108 to i32
%110 = sext i32 %109 to i64
%111 = sub nsw i64 %99, %110
br label %112
112: ; preds = %93, %76
%113 = phi i64 [ %92, %76 ], [ %111, %93 ]
store i64 %113, i64* %8
br label %114
114: ; preds = %112, %55
%115 = load i64, i64* %8
ret i64 %115
}

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 %40
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 = xor i64 %29, -1
%31 = icmp slt i64 %24, 0
br i1 %31, label %32, label %36
32: ; preds = %23
%33 = icmp eq i64 %24, %29
%34 = zext i1 %33 to i64
%35 = add nsw i64 %29, %34
br label %40
36: ; preds = %23
%37 = icmp eq i64 %24, %30
%38 = sext i1 %37 to i64
%39 = add i64 %38, %30
br label %40
40: ; preds = %9, %32, %36
%41 = phi i64 [ %22, %9 ], [ %35, %32 ], [ %39, %36 ]
ret i64 %41
}