#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 */

/* Variables and functions */
int calendar_dpy(int);
int /*<<< orphan*/ decode_day(int, int, int *, int *, int *);
int /*<<< orphan*/ decode_julday(int, int, int *, int *, int *);
void decode_caldaysec(int calendar, int julday, int secofday, int *year,
                      int *month, int *day, int *hour, int *minute,
                      int *second) {
  int dpy;
  dpy = calendar_dpy(calendar);
  if (dpy == 360 || dpy == 365 || dpy == 366)
    decode_day(dpy, julday, year, month, day);
  else
    decode_julday(calendar, julday, year, month, day);
  *hour = secofday / 3600;
  *minute = secofday / 60 - *hour * 60;
  *second = secofday - *hour * 3600 - *minute * 60;
}


x86 assembly (clang, -O0):
<decode_caldaysec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <calendar_dpy@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x168,-0x2c(%rbp)
je     118b <decode_caldaysec+0x5b>
cmpl   $0x16d,-0x2c(%rbp)
je     118b <decode_caldaysec+0x5b>
cmpl   $0x16e,-0x2c(%rbp)
jne    11a7 <decode_caldaysec+0x77>
mov    -0x2c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <decode_day@plt>
jmp    11be <decode_caldaysec+0x8e>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1030 <decode_julday@plt>
mov    -0xc(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    0x10(%rbp),%rax
imul   $0x3c,(%rax),%eax
sub    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
mov    0x10(%rbp),%rax
imul   $0xe10,(%rax),%eax
sub    %eax,%ecx
mov    0x18(%rbp),%rax
imul   $0x3c,(%rax),%eax
sub    %eax,%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_caldaysec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,%r13
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <calendar_dpy@plt>
lea    -0x168(%rax),%ecx
cmp    $0x6,%ecx
ja     1179 <decode_caldaysec+0x49>
mov    $0x61,%edx
bt     %ecx,%edx
jae    1179 <decode_caldaysec+0x49>
mov    %eax,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1040 <decode_day@plt>
jmp    118b <decode_caldaysec+0x5b>
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r13,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1030 <decode_julday@plt>
movslq %r14d,%rax
imul   $0xffffffff91a2b3c5,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0xb,%ecx
add    %edx,%ecx
mov    0x40(%rsp),%rdi
mov    %ecx,(%rdi)
imul   $0xffffffff88888889,%rax,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0xffffffc4,%ecx,%ecx
add    %edx,%ecx
mov    0x48(%rsp),%rdx
mov    %ecx,(%rdx)
imul   $0xfffff1f0,(%rdi),%edx
imul   $0xffffffc4,%ecx,%ecx
add    %eax,%ecx
add    %edx,%ecx
mov    0x50(%rsp),%rax
mov    %ecx,(%rax)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @decode_caldaysec(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%20 = load i32, i32* %10
%21 = call i32 @calendar_dpy(i32 %20)
store i32 %21, i32* %19
%22 = load i32, i32* %19
%23 = icmp eq i32 %22, 360
br i1 %23, label %30, label %24
24: ; preds = %9
%25 = load i32, i32* %19
%26 = icmp eq i32 %25, 365
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %19
%29 = icmp eq i32 %28, 366
br i1 %29, label %30, label %37
30: ; preds = %27, %24, %9
%31 = load i32, i32* %19
%32 = load i32, i32* %11
%33 = load i32*, i32** %13
%34 = load i32*, i32** %14
%35 = load i32*, i32** %15
%36 = call i32 @decode_day(i32 %31, i32 %32, i32* %33, i32* %34, i32* %35)
br label %44
37: ; preds = %27
%38 = load i32, i32* %10
%39 = load i32, i32* %11
%40 = load i32*, i32** %13
%41 = load i32*, i32** %14
%42 = load i32*, i32** %15
%43 = call i32 @decode_julday(i32 %38, i32 %39, i32* %40, i32* %41, i32* %42)
br label %44
44: ; preds = %37, %30
%45 = load i32, i32* %12
%46 = sdiv i32 %45, 3600
%47 = load i32*, i32** %16
store i32 %46, i32* %47
%48 = load i32, i32* %12
%49 = sdiv i32 %48, 60
%50 = load i32*, i32** %16
%51 = load i32, i32* %50
%52 = mul nsw i32 %51, 60
%53 = sub nsw i32 %49, %52
%54 = load i32*, i32** %17
store i32 %53, i32* %54
%55 = load i32, i32* %12
%56 = load i32*, i32** %16
%57 = load i32, i32* %56
%58 = mul nsw i32 %57, 3600
%59 = sub nsw i32 %55, %58
%60 = load i32*, i32** %17
%61 = load i32, i32* %60
%62 = mul nsw i32 %61, 60
%63 = sub nsw i32 %59, %62
%64 = load i32*, i32** %18
store i32 %63, i32* %64
ret void
}

LLVM IR (-O2):
define void @decode_caldaysec(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5, i32* nocapture %6, i32* nocapture writeonly %7, i32* nocapture writeonly %8) {
%10 = tail call i32 @calendar_dpy(i32 %0)
switch i32 %10, label %13 [
i32 366, label %11
i32 365, label %11
i32 360, label %11
]
11: ; preds = %9, %9, %9
%12 = tail call i32 @decode_day(i32 %10, i32 %1, i32* %3, i32* %4, i32* %5)
br label %15
13: ; preds = %9
%14 = tail call i32 @decode_julday(i32 %0, i32 %1, i32* %3, i32* %4, i32* %5)
br label %15
15: ; preds = %13, %11
%16 = sdiv i32 %2, 3600
store i32 %16, i32* %6
%17 = sdiv i32 %2, 60
%18 = mul nsw i32 %16, -60
%19 = add nsw i32 %18, %17
store i32 %19, i32* %7
%20 = load i32, i32* %6
%21 = mul i32 %20, -3600
%22 = mul i32 %19, -60
%23 = add i32 %22, %2
%24 = add i32 %23, %21
store i32 %24, i32* %8
ret void
}