#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 encode_day(int, int, int, int);
int encode_julday(int, int, int, int);
void encode_caldaysec(int calendar, int year, int month, int day, int hour,
                      int minute, int second, int *julday, int *secofday) {
  int dpy;
  dpy = calendar_dpy(calendar);
  if (dpy == 360 || dpy == 365 || dpy == 366)
    *julday = encode_day(dpy, year, month, day);
  else
    *julday = encode_julday(calendar, year, month, day);
  *secofday = hour * 3600 + minute * 60 + second;
}


x86 assembly (clang, -O0):
<encode_caldaysec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <calendar_dpy@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x168,-0x1c(%rbp)
je     1189 <encode_caldaysec+0x59>
cmpl   $0x16d,-0x1c(%rbp)
je     1189 <encode_caldaysec+0x59>
cmpl   $0x16e,-0x1c(%rbp)
jne    11a7 <encode_caldaysec+0x77>
mov    -0x1c(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1040 <encode_day@plt>
mov    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c0 <encode_caldaysec+0x90>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <encode_julday@plt>
mov    %eax,%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
imul   $0xe10,-0x14(%rbp),%ecx
imul   $0x3c,-0x18(%rbp),%eax
add    %eax,%ecx
add    0x10(%rbp),%ecx
mov    0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_caldaysec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r14d
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebx
mov    %edi,%ebp
call   1050 <calendar_dpy@plt>
lea    -0x168(%rax),%ecx
cmp    $0x6,%ecx
ja     1176 <encode_caldaysec+0x46>
mov    $0x61,%edx
bt     %ecx,%edx
jae    1176 <encode_caldaysec+0x46>
mov    %eax,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1040 <encode_day@plt>
jmp    1185 <encode_caldaysec+0x55>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
call   1030 <encode_julday@plt>
mov    0x48(%rsp),%rcx
mov    %eax,(%rcx)
imul   $0xe10,%r15d,%eax
imul   $0x3c,%r14d,%ecx
add    %eax,%ecx
add    0x40(%rsp),%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 @encode_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* %12
%34 = load i32, i32* %13
%35 = call i32 @encode_day(i32 %31, i32 %32, i32 %33, i32 %34)
%36 = load i32*, i32** %17
store i32 %35, i32* %36
br label %44
37: ; preds = %27
%38 = load i32, i32* %10
%39 = load i32, i32* %11
%40 = load i32, i32* %12
%41 = load i32, i32* %13
%42 = call i32 @encode_julday(i32 %38, i32 %39, i32 %40, i32 %41)
%43 = load i32*, i32** %17
store i32 %42, i32* %43
br label %44
44: ; preds = %37, %30
%45 = load i32, i32* %14
%46 = mul nsw i32 %45, 3600
%47 = load i32, i32* %15
%48 = mul nsw i32 %47, 60
%49 = add nsw i32 %46, %48
%50 = load i32, i32* %16
%51 = add nsw i32 %49, %50
%52 = load i32*, i32** %18
store i32 %51, i32* %52
ret void
}

LLVM IR (-O2):
define void @encode_caldaysec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %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 @encode_day(i32 %10, i32 %1, i32 %2, i32 %3)
br label %15
13: ; preds = %9
%14 = tail call i32 @encode_julday(i32 %0, i32 %1, i32 %2, i32 %3)
br label %15
15: ; preds = %13, %11
%16 = phi i32 [ %14, %13 ], [ %12, %11 ]
store i32 %16, i32* %7
%17 = mul nsw i32 %4, 3600
%18 = mul nsw i32 %5, 60
%19 = add nsw i32 %18, %17
%20 = add nsw i32 %19, %6
store i32 %20, i32* %8
ret void
}