#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*/ vtimestr;
typedef int /*<<< orphan*/ vdatestr;

/* Variables and functions */
int /*<<< orphan*/ cdiDecodeDate(int, int *, int *, int *);
int /*<<< orphan*/ cdiDecodeTime(int, int *, int *, int *);
int /*<<< orphan*/ cdoAbort(char *, int, char *, char *);
int /*<<< orphan*/ date2str(int, char *, int);
int /*<<< orphan*/ time2str(int, char *, int);
int hour_of_year(int vdate, int vtime) {
  int year, month, day, houroy;
  int hour, minute, second;
  cdiDecodeDate(vdate, &year, &month, &day);
  cdiDecodeTime(vtime, &hour, &minute, &second);
  if (month >= 1 && month <= 12 && day >= 1 && day <= 31 && hour >= 0 &&
      hour < 24)
    houroy = ((month - 1) * 31 + day - 1) * 25 + hour + 1;
  else
    houroy = 0;
  if (houroy < 0 || houroy >= 9301) {
    char vdatestr[32], vtimestr[32];
    date2str(vdate, vdatestr, sizeof(vdatestr));
    time2str(vtime, vtimestr, sizeof(vtimestr));
    cdoAbort("Hour of year %d out of range (%s %s)!", houroy, vdatestr,
             vtimestr);
  }
  return (houroy);
}


x86 assembly (clang, -O0):
<hour_of_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1050 <cdiDecodeDate@plt>
mov    -0x8(%rbp),%edi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1070 <cdiDecodeTime@plt>
cmpl   $0x1,-0x10(%rbp)
jl     11e2 <hour_of_year+0x92>
cmpl   $0xc,-0x10(%rbp)
jg     11e2 <hour_of_year+0x92>
cmpl   $0x1,-0x14(%rbp)
jl     11e2 <hour_of_year+0x92>
cmpl   $0x1f,-0x14(%rbp)
jg     11e2 <hour_of_year+0x92>
cmpl   $0x0,-0x1c(%rbp)
jl     11e2 <hour_of_year+0x92>
cmpl   $0x18,-0x1c(%rbp)
jge    11e2 <hour_of_year+0x92>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
imul   $0x1f,%eax,%eax
add    -0x14(%rbp),%eax
sub    $0x1,%eax
imul   $0x19,%eax,%eax
add    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e9 <hour_of_year+0x99>
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1200 <hour_of_year+0xb0>
cmpl   $0x2455,-0x18(%rbp)
jl     1239 <hour_of_year+0xe9>
mov    -0x4(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0x20,%edx
call   1030 <date2str@plt>
mov    -0x8(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x20,%edx
call   1060 <time2str@plt>
mov    -0x18(%rbp),%esi
lea    -0x50(%rbp),%rdx
lea    -0x70(%rbp),%rcx
lea    0xdcc(%rip),%rdi
call   1040 <cdoAbort@plt>
mov    -0x18(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hour_of_year>:
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebx
lea    0x1c(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   1030 <cdiDecodeDate@plt>
lea    0x8(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %ebx,%edi
call   1040 <cdiDecodeTime@plt>
mov    0x10(%rsp),%ecx
lea    -0x1(%rcx),%edx
xor    %eax,%eax
cmp    $0xb,%edx
ja     118f <hour_of_year+0x6f>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    118f <hour_of_year+0x6f>
cmp    $0x1f,%edx
jg     118f <hour_of_year+0x6f>
mov    0x8(%rsp),%esi
test   %esi,%esi
js     118f <hour_of_year+0x6f>
cmp    $0x17,%esi
jg     118f <hour_of_year+0x6f>
mov    %ecx,%eax
shl    $0x5,%eax
sub    %ecx,%eax
add    %edx,%eax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,4),%eax
add    %esi,%eax
add    $0xfffffce1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Hour of year %d out of range (%s %s)!\00"
define i32 @hour_of_year(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [32 x i8]
%13 = alloca [32 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%14 = load i32, i32* %3
%15 = call i32 @cdiDecodeDate(i32 %14, i32* %5, i32* %6, i32* %7)
%16 = load i32, i32* %4
%17 = call i32 @cdiDecodeTime(i32 %16, i32* %9, i32* %10, i32* %11)
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 1
br i1 %19, label %20, label %46
20: ; preds = %2
%21 = load i32, i32* %6
%22 = icmp sle i32 %21, 12
br i1 %22, label %23, label %46
23: ; preds = %20
%24 = load i32, i32* %7
%25 = icmp sge i32 %24, 1
br i1 %25, label %26, label %46
26: ; preds = %23
%27 = load i32, i32* %7
%28 = icmp sle i32 %27, 31
br i1 %28, label %29, label %46
29: ; preds = %26
%30 = load i32, i32* %9
%31 = icmp sge i32 %30, 0
br i1 %31, label %32, label %46
32: ; preds = %29
%33 = load i32, i32* %9
%34 = icmp slt i32 %33, 24
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i32, i32* %6
%37 = sub nsw i32 %36, 1
%38 = mul nsw i32 %37, 31
%39 = load i32, i32* %7
%40 = add nsw i32 %38, %39
%41 = sub nsw i32 %40, 1
%42 = mul nsw i32 %41, 25
%43 = load i32, i32* %9
%44 = add nsw i32 %42, %43
%45 = add nsw i32 %44, 1
store i32 %45, i32* %8
br label %47
46: ; preds = %32, %29, %26, %23, %20, %2
store i32 0, i32* %8
br label %47
47: ; preds = %46, %35
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = load i32, i32* %8
%52 = icmp sge i32 %51, 9301
br i1 %52, label %53, label %64
53: ; preds = %50, %47
%54 = load i32, i32* %3
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%56 = call i32 @date2str(i32 %54, i8* %55, i32 32)
%57 = load i32, i32* %4
%58 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%59 = call i32 @time2str(i32 %57, i8* %58, i32 32)
%60 = load i32, i32* %8
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %12, i64 0, i64 0
%62 = getelementptr inbounds [32 x i8], [32 x i8]* %13, i64 0, i64 0
%63 = call i32 @cdoAbort(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %60, i8* %61, i8* %62)
br label %64
64: ; preds = %53, %50
%65 = load i32, i32* %8
ret i32 %65
}

LLVM IR (-O2):
define i32 @hour_of_year(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = bitcast i32* %8 to i8*
%15 = call i32 @cdiDecodeDate(i32 %0, i32* %3, i32* %4, i32* %5)
%16 = call i32 @cdiDecodeTime(i32 %1, i32* %6, i32* %7, i32* %8)
%17 = load i32, i32* %4
%18 = add i32 %17, -1
%19 = icmp ult i32 %18, 12
%20 = load i32, i32* %5
%21 = icmp sgt i32 %20, 0
%22 = select i1 %19, i1 %21, i1 false
%23 = icmp slt i32 %20, 32
%24 = select i1 %22, i1 %23, i1 false
%25 = load i32, i32* %6
%26 = icmp sgt i32 %25, -1
%27 = select i1 %24, i1 %26, i1 false
%28 = icmp slt i32 %25, 24
%29 = select i1 %27, i1 %28, i1 false
br i1 %29, label %30, label %37
30: ; preds = %2
%31 = mul nuw nsw i32 %17, 31
%32 = add nsw i32 %31, -31
%33 = add nuw nsw i32 %32, %20
%34 = mul nuw nsw i32 %33, 25
%35 = add nuw nsw i32 %25, -24
%36 = add nsw i32 %35, %34
br label %37
37: ; preds = %30, %2
%38 = phi i32 [ %36, %30 ], [ 0, %2 ]
ret i32 %38
}