#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 uint16_t;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_min;
  int tm_mon;
  int tm_mday;
  int tm_year;
  int tm_hour;
  int tm_gmtoff;
};

/* Variables and functions */
int abs(int);
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int get_rds_ct_group(uint16_t *blocks) {
  static int latest_minutes = -1;
  time_t now;
  struct tm *utc;
  now = time(NULL);
  utc = gmtime(&now);
  if (utc->tm_min != latest_minutes) {
    latest_minutes = utc->tm_min;
    int l = utc->tm_mon <= 1 ? 1 : 0;
    int mjd = 14956 + utc->tm_mday + (int)((utc->tm_year - l) * 365.25) +
              (int)((utc->tm_mon + 2 + l * 12) * 30.6001);
    blocks[1] = 0x4400 | (mjd >> 15);
    blocks[2] = (mjd << 1) | (utc->tm_hour >> 4);
    blocks[3] = (utc->tm_hour & 0xF) << 12 | utc->tm_min << 6;
    utc = localtime(&now);
    int offset = utc->tm_gmtoff / (30 * 60);
    blocks[3] |= abs(offset);
    if (offset < 0)
      blocks[3] |= 0x20;
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<get_rds_ct_group>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <gmtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    0x2ecf(%rip),%eax
je     1290 <get_rds_ct_group+0x150>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
mov    %eax,0x2ebd(%rip)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x1,%edx
cmovle %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%eax
add    $0x3a6c,%eax
mov    -0x20(%rbp),%rcx
mov    0xc(%rcx),%ecx
sub    -0x24(%rbp),%ecx
cvtsi2sd %ecx,%xmm0
movsd  0xe4c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
mov    -0x20(%rbp),%rcx
mov    0x4(%rcx),%ecx
add    $0x2,%ecx
imul   $0xc,-0x24(%rbp),%edx
add    %edx,%ecx
cvtsi2sd %ecx,%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
sar    $0xf,%ecx
or     $0x4400,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x28(%rbp),%ecx
shl    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%eax
sar    $0x4,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%ecx
and    $0xf,%ecx
shl    $0xc,%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
shl    $0x6,%eax
or     %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x14(%rax),%eax
mov    $0x708,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
or     0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
cmpl   $0x0,-0x2c(%rbp)
jge    1284 <get_rds_ct_group+0x144>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
or     $0x20,%ecx
mov    %ecx,0xc(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1297 <get_rds_ct_group+0x157>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rds_ct_group>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1050 <gmtime@plt>
mov    (%rax),%ecx
cmp    0x2ee2(%rip),%ecx
je     122a <get_rds_ct_group+0xfa>
mov    %ecx,0x2ed6(%rip)
mov    0x4(%rax),%ecx
mov    0xc(%rax),%edx
lea    0xc(%rcx),%esi
xor    %edi,%edi
cmp    $0x2,%ecx
cmovge %ecx,%esi
setl   %dil
sub    %edi,%edx
cvtsi2sd %edx,%xmm0
mulsd  0xe7b(%rip),%xmm0
cvttsd2si %xmm0,%ecx
add    0x8(%rax),%ecx
add    $0x2,%esi
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
mulsd  0xe6a(%rip),%xmm0
cvttsd2si %xmm0,%edx
lea    (%rcx,%rdx,1),%esi
add    %edx,%ecx
add    $0x3a6c,%ecx
sar    $0xf,%ecx
or     $0x4400,%ecx
mov    %ecx,0x4(%r14)
lea    (%rsi,%rsi,1),%ecx
add    $0x74d8,%ecx
mov    0x10(%rax),%edx
sar    $0x4,%edx
or     %ecx,%edx
mov    %edx,0x8(%r14)
mov    (%rax),%ecx
mov    0x10(%rax),%eax
shl    $0xc,%eax
movzwl %ax,%eax
shl    $0x6,%ecx
or     %eax,%ecx
mov    %ecx,0xc(%r14)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
movslq 0x14(%rax),%rax
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xa,%ecx
add    %edx,%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
or     0xc(%r14),%edx
mov    %edx,%ecx
or     $0x20,%ecx
cmp    $0xfffffffffffff8f9,%rax
cmovge %edx,%ecx
mov    %ecx,0xc(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@get_rds_ct_group.latest_minutes = internal global i32 -1
define i32 @get_rds_ct_group(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca %struct.tm*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
%9 = call i32 @time(i32* null)
store i32 %9, i32* %4
%10 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %10, %struct.tm** %5
%11 = load %struct.tm*, %struct.tm** %5
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @get_rds_ct_group.latest_minutes
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %95
16: ; preds = %1
%17 = load %struct.tm*, %struct.tm** %5
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 0
%19 = load i32, i32* %18
store i32 %19, i32* @get_rds_ct_group.latest_minutes
%20 = load %struct.tm*, %struct.tm** %5
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = icmp sle i32 %22, 1
%24 = zext i1 %23 to i64
%25 = select i1 %23, i32 1, i32 0
store i32 %25, i32* %6
%26 = load %struct.tm*, %struct.tm** %5
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 2
%28 = load i32, i32* %27
%29 = add nsw i32 14956, %28
%30 = load %struct.tm*, %struct.tm** %5
%31 = getelementptr inbounds %struct.tm, %struct.tm* %30, i32 0, i32 3
%32 = load i32, i32* %31
%33 = load i32, i32* %6
%34 = sub nsw i32 %32, %33
%35 = sitofp i32 %34 to double
%36 = fmul double %35, 3.652500e+02
%37 = fptosi double %36 to i32
%38 = add nsw i32 %29, %37
%39 = load %struct.tm*, %struct.tm** %5
%40 = getelementptr inbounds %struct.tm, %struct.tm* %39, i32 0, i32 1
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 2
%43 = load i32, i32* %6
%44 = mul nsw i32 %43, 12
%45 = add nsw i32 %42, %44
%46 = sitofp i32 %45 to double
%47 = fmul double %46, 3.060010e+01
%48 = fptosi double %47 to i32
%49 = add nsw i32 %38, %48
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = ashr i32 %50, 15
%52 = or i32 17408, %51
%53 = load i32*, i32** %3
%54 = getelementptr inbounds i32, i32* %53, i64 1
store i32 %52, i32* %54
%55 = load i32, i32* %7
%56 = shl i32 %55, 1
%57 = load %struct.tm*, %struct.tm** %5
%58 = getelementptr inbounds %struct.tm, %struct.tm* %57, i32 0, i32 4
%59 = load i32, i32* %58
%60 = ashr i32 %59, 4
%61 = or i32 %56, %60
%62 = load i32*, i32** %3
%63 = getelementptr inbounds i32, i32* %62, i64 2
store i32 %61, i32* %63
%64 = load %struct.tm*, %struct.tm** %5
%65 = getelementptr inbounds %struct.tm, %struct.tm* %64, i32 0, i32 4
%66 = load i32, i32* %65
%67 = and i32 %66, 15
%68 = shl i32 %67, 12
%69 = load %struct.tm*, %struct.tm** %5
%70 = getelementptr inbounds %struct.tm, %struct.tm* %69, i32 0, i32 0
%71 = load i32, i32* %70
%72 = shl i32 %71, 6
%73 = or i32 %68, %72
%74 = load i32*, i32** %3
%75 = getelementptr inbounds i32, i32* %74, i64 3
store i32 %73, i32* %75
%76 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %76, %struct.tm** %5
%77 = load %struct.tm*, %struct.tm** %5
%78 = getelementptr inbounds %struct.tm, %struct.tm* %77, i32 0, i32 5
%79 = load i32, i32* %78
%80 = sdiv i32 %79, 1800
store i32 %80, i32* %8
%81 = load i32, i32* %8
%82 = call i32 @abs(i32 %81)
%83 = load i32*, i32** %3
%84 = getelementptr inbounds i32, i32* %83, i64 3
%85 = load i32, i32* %84
%86 = or i32 %85, %82
store i32 %86, i32* %84
%87 = load i32, i32* %8
%88 = icmp slt i32 %87, 0
br i1 %88, label %89, label %94
89: ; preds = %16
%90 = load i32*, i32** %3
%91 = getelementptr inbounds i32, i32* %90, i64 3
%92 = load i32, i32* %91
%93 = or i32 %92, 32
store i32 %93, i32* %91
br label %94
94: ; preds = %89, %16
store i32 1, i32* %2
br label %96
95: ; preds = %1
store i32 0, i32* %2
br label %96
96: ; preds = %95, %94
%97 = load i32, i32* %2
ret i32 %97
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@get_rds_ct_group.latest_minutes = internal unnamed_addr global i32 -1
define i32 @get_rds_ct_group(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = call %struct.tm* @gmtime(i32* %2)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%7 = load i32, i32* %6
%8 = load i32, i32* @get_rds_ct_group.latest_minutes
%9 = icmp eq i32 %7, %8
br i1 %9, label %58, label %10
10: ; preds = %1
store i32 %7, i32* @get_rds_ct_group.latest_minutes
%11 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%12 = load i32, i32* %11
%13 = icmp slt i32 %12, 2
%14 = sext i1 %13 to i32
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 14956
%18 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%19 = load i32, i32* %18
%20 = add i32 %19, %14
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 3.652500e+02
%23 = fptosi double %22 to i32
%24 = add nsw i32 %17, %23
%25 = add nsw i32 %12, 2
%26 = select i1 %13, i32 12, i32 0
%27 = add nsw i32 %25, %26
%28 = sitofp i32 %27 to double
%29 = fmul double %28, 3.060010e+01
%30 = fptosi double %29 to i32
%31 = add nsw i32 %24, %30
%32 = ashr i32 %31, 15
%33 = or i32 %32, 17408
%34 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %33, i32* %34
%35 = shl i32 %31, 1
%36 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%37 = load i32, i32* %36
%38 = ashr i32 %37, 4
%39 = or i32 %35, %38
%40 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %39, i32* %40
%41 = load i32, i32* %36
%42 = shl i32 %41, 12
%43 = and i32 %42, 61440
%44 = load i32, i32* %6
%45 = shl i32 %44, 6
%46 = or i32 %43, %45
%47 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %46, i32* %47
%48 = call %struct.tm* @localtime(i32* %2)
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i64 0, i32 5
%50 = load i32, i32* %49
%51 = sdiv i32 %50, 1800
%52 = call i32 @llvm.abs.i32(i32 %51, i1 true)
%53 = load i32, i32* %47
%54 = or i32 %52, %53
%55 = icmp slt i32 %50, -1799
%56 = or i32 %54, 32
%57 = select i1 %55, i32 %56, i32 %54
store i32 %57, i32* %47
br label %58
58: ; preds = %1, %10
%59 = phi i32 [ 1, %10 ], [ 0, %1 ]
ret i32 %59
}