#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 swe_calc_ut(double, int /*<<< orphan*/, int, double *,
                int /*<<< orphan*/ *);
double swe_degnorm(int);
double swe_deltat_ex(double, int, int /*<<< orphan*/ *);
int swe_houses_armc_ex2(double, double, double, int, double *, double *,
                        int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                        int /*<<< orphan*/ *);
int swe_sidtime0(double, double, double);
double swi_epsiln(double, int /*<<< orphan*/);
int /*<<< orphan*/ swi_nutation(double, int /*<<< orphan*/, double *);
char toupper(int);
int swe_houses(double tjd_ut, double geolat, double geolon, int hsys,
               double *cusp, double *ascmc) {
  int i, retc = 0;
  double armc, eps, nutlo[2];
  double tjde = tjd_ut + swe_deltat_ex(tjd_ut, -1, NULL);
  eps = swi_epsiln(tjde, 0) * (180.0 / 3.14159265358979323846);
  swi_nutation(tjde, 0, nutlo);
  for (i = 0; i < 2; i++)
    nutlo[i] *= (180.0 / 3.14159265358979323846);
  armc =
      swe_degnorm(swe_sidtime0(tjd_ut, eps + nutlo[1], nutlo[0]) * 15 + geolon);
  if (toupper(hsys) == 'I') {
    int flags = 256 | (2 * 1024);
    double xp[6];
    int result = swe_calc_ut(tjd_ut, 0, flags, xp, NULL);
    if (result < 0) {
      result = swe_houses_armc_ex2(armc, geolat, eps + nutlo[1], 'O', cusp,
                                   ascmc, NULL, NULL, NULL);
      return (-1);
    }
    ascmc[9] = xp[1];
  }
  retc = swe_houses_armc_ex2(armc, geolat, eps + nutlo[1], hsys, cusp, ascmc,
                             NULL, NULL, NULL);
  return retc;
}


x86 assembly (clang, -O0):
<swe_houses>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %rsi,-0x30(%rbp)
mov    %rdx,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
mov    $0xffffffff,%edi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <swe_deltat_ex@plt>
movaps %xmm0,%xmm1
movsd  -0xb0(%rbp),%xmm0
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
xor    %edi,%edi
call   1050 <swi_epsiln@plt>
movsd  0xe0c(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x68(%rbp),%xmm0
lea    -0x60(%rbp),%rsi
xor    %edi,%edi
call   1070 <swi_nutation@plt>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x2,-0x3c(%rbp)
jge    1244 <swe_houses+0xc4>
movslq -0x3c(%rbp),%rax
movsd  0xdd6(%rip),%xmm0
mulsd  -0x60(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1214 <swe_houses+0x94>
movsd  -0x10(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
addsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
call   1080 <swe_sidtime0@plt>
imul   $0xf,%eax,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <swe_degnorm@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <toupper@plt>
movsbl %al,%eax
cmp    $0x49,%eax
jne    1313 <swe_houses+0x193>
movl   $0x900,-0x6c(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x6c(%rbp),%esi
lea    -0xa0(%rbp),%rdx
xor    %edi,%edi
xor    %eax,%eax
mov    %eax,%ecx
call   1090 <swe_calc_ut@plt>
mov    %eax,-0xa4(%rbp)
cmpl   $0x0,-0xa4(%rbp)
jge    1302 <swe_houses+0x182>
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
addsd  -0x58(%rbp),%xmm2
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    $0x4f,%edi
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <swe_houses_armc_ex2@plt>
mov    %eax,-0xa4(%rbp)
movl   $0xffffffff,-0x4(%rbp)
jmp    134b <swe_houses+0x1cb>
movsd  -0x98(%rbp),%xmm0
ff
mov    -0x38(%rbp),%rax
movsd  %xmm0,0x48(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
addsd  -0x58(%rbp),%xmm2
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
call   1030 <swe_houses_armc_ex2@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swe_houses>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%ebp
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mov    $0xffffffff,%edi
xor    %esi,%esi
call   10a0 <swe_deltat_ex@plt>
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x38(%rsp)
xor    %edi,%edi
call   1050 <swi_epsiln@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x20(%rsp),%rsi
movsd  0x38(%rsp),%xmm0
xor    %edi,%edi
call   1070 <swi_nutation@plt>
movapd 0x20(%rsp),%xmm2
mulpd  0xe1a(%rip),%xmm2
movapd %xmm2,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xe16(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
call   1080 <swe_sidtime0@plt>
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
cvttsd2si %xmm0,%edi
call   1060 <swe_degnorm@plt>
movsd  %xmm0,(%rsp)
mov    %ebp,%edi
call   1040 <toupper@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
cmp    $0x49,%al
jne    128c <swe_houses+0x10c>
lea    0x40(%rsp),%rdx
movsd  0x18(%rsp),%xmm0
xor    %edi,%edi
mov    $0x900,%esi
xor    %ecx,%ecx
call   1090 <swe_calc_ut@plt>
test   %eax,%eax
js     12a9 <swe_houses+0x129>
movsd  0x48(%rsp),%xmm0
movsd  %xmm0,0x48(%rbx)
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm0
addsd  0x28(%rsp),%xmm2
mov    %ebp,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <swe_houses_armc_ex2@plt>
jmp    12dd <swe_houses+0x15d>
movsd  0x8(%rsp),%xmm2
addsd  0x28(%rsp),%xmm2
movsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x4f,%edi
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <swe_houses_armc_ex2@plt>
mov    $0xffffffff,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @swe_houses(double %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca double*
%13 = alloca double*
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca [2 x double]
%19 = alloca double
%20 = alloca i32
%21 = alloca [6 x double]
%22 = alloca i32
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store i32 %3, i32* %11
store double* %4, double** %12
store double* %5, double** %13
store i32 0, i32* %15
%23 = load double, double* %8
%24 = load double, double* %8
%25 = call double @swe_deltat_ex(double %24, i32 -1, i32* null)
%26 = fadd double %23, %25
store double %26, double* %19
%27 = load double, double* %19
%28 = call double @swi_epsiln(double %27, i32 0)
%29 = fmul double %28, 0x404CA5DC1A63C1F8
store double %29, double* %17
%30 = load double, double* %19
%31 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 0
%32 = call i32 @swi_nutation(double %30, i32 0, double* %31)
store i32 0, i32* %14
br label %33
33: ; preds = %42, %6
%34 = load i32, i32* %14
%35 = icmp slt i32 %34, 2
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %14
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 %38
%40 = load double, double* %39
%41 = fmul double %40, 0x404CA5DC1A63C1F8
store double %41, double* %39
br label %42
42: ; preds = %36
%43 = load i32, i32* %14
%44 = add nsw i32 %43, 1
store i32 %44, i32* %14
br label %33
45: ; preds = %33
%46 = load double, double* %8
%47 = load double, double* %17
%48 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 1
%49 = load double, double* %48
%50 = fadd double %47, %49
%51 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 0
%52 = load double, double* %51
%53 = call i32 @swe_sidtime0(double %46, double %50, double %52)
%54 = mul nsw i32 %53, 15
%55 = sitofp i32 %54 to double
%56 = load double, double* %10
%57 = fadd double %55, %56
%58 = fptosi double %57 to i32
%59 = call double @swe_degnorm(i32 %58)
store double %59, double* %16
%60 = load i32, i32* %11
%61 = call signext i8 @toupper(i32 %60)
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 73
br i1 %63, label %64, label %86
64: ; preds = %45
store i32 2304, i32* %20
%65 = load double, double* %8
%66 = load i32, i32* %20
%67 = getelementptr inbounds [6 x double], [6 x double]* %21, i64 0, i64 0
%68 = call i32 @swe_calc_ut(double %65, i32 0, i32 %66, double* %67, i32* null)
store i32 %68, i32* %22
%69 = load i32, i32* %22
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %81
71: ; preds = %64
%72 = load double, double* %16
%73 = load double, double* %9
%74 = load double, double* %17
%75 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 1
%76 = load double, double* %75
%77 = fadd double %74, %76
%78 = load double*, double** %12
%79 = load double*, double** %13
%80 = call i32 @swe_houses_armc_ex2(double %72, double %73, double %77, i32 79, double* %78, double* %79, i32* null, i32* null, i32* null)
store i32 %80, i32* %22
store i32 -1, i32* %7
br label %98
81: ; preds = %64
%82 = getelementptr inbounds [6 x double], [6 x double]* %21, i64 0, i64 1
%83 = load double, double* %82
%84 = load double*, double** %13
%85 = getelementptr inbounds double, double* %84, i64 9
store double %83, double* %85
br label %86
86: ; preds = %81, %45
%87 = load double, double* %16
%88 = load double, double* %9
%89 = load double, double* %17
%90 = getelementptr inbounds [2 x double], [2 x double]* %18, i64 0, i64 1
%91 = load double, double* %90
%92 = fadd double %89, %91
%93 = load i32, i32* %11
%94 = load double*, double** %12
%95 = load double*, double** %13
%96 = call i32 @swe_houses_armc_ex2(double %87, double %88, double %92, i32 %93, double* %94, double* %95, i32* null, i32* null, i32* null)
store i32 %96, i32* %15
%97 = load i32, i32* %15
store i32 %97, i32* %7
br label %98
98: ; preds = %86, %71
%99 = load i32, i32* %7
ret i32 %99
}

LLVM IR (-O2):
define i32 @swe_houses(double %0, double %1, double %2, i32 %3, double* %4, double* %5) {
%7 = alloca <2 x double>
%8 = alloca [6 x double]
%9 = bitcast <2 x double>* %7 to i8*
%10 = tail call double @swe_deltat_ex(double %0, i32 -1, i32* null)
%11 = fadd double %10, %0
%12 = tail call double @swi_epsiln(double %11, i32 0)
%13 = getelementptr inbounds <2 x double>, <2 x double>* %7, i64 0, i64 0
%14 = call i32 @swi_nutation(double %11, i32 0, double* %13)
%15 = getelementptr inbounds <2 x double>, <2 x double>* %7, i64 0, i64 1
%16 = load <2 x double>, <2 x double>* %7
%17 = fmul <2 x double> %16, <double 0x404CA5DC1A63C1F8, double 0x404CA5DC1A63C1F8>
store <2 x double> %17, <2 x double>* %7
%18 = fmul double %12, 0x404CA5DC1A63C1F8
%19 = extractelement <2 x double> %17, i64 1
%20 = fadd double %18, %19
%21 = extractelement <2 x double> %17, i64 0
%22 = call i32 @swe_sidtime0(double %0, double %20, double %21)
%23 = mul nsw i32 %22, 15
%24 = sitofp i32 %23 to double
%25 = fadd double %24, %2
%26 = fptosi double %25 to i32
%27 = call double @swe_degnorm(i32 %26)
%28 = call signext i8 @toupper(i32 %3)
%29 = icmp eq i8 %28, 73
br i1 %29, label %30, label %43
30: ; preds = %6
%31 = bitcast [6 x double]* %8 to i8*
%32 = getelementptr inbounds [6 x double], [6 x double]* %8, i64 0, i64 0
%33 = call i32 @swe_calc_ut(double %0, i32 0, i32 2304, double* %32, i32* null)
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load double, double* %15
%37 = fadd double %18, %36
%38 = call i32 @swe_houses_armc_ex2(double %27, double %1, double %37, i32 79, double* %4, double* %5, i32* null, i32* null, i32* null)
br label %47
39: ; preds = %30
%40 = getelementptr inbounds [6 x double], [6 x double]* %8, i64 0, i64 1
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %5, i64 9
store double %41, double* %42
br label %43
43: ; preds = %39, %6
%44 = load double, double* %15
%45 = fadd double %18, %44
%46 = call i32 @swe_houses_armc_ex2(double %27, double %1, double %45, i32 %3, double* %4, double* %5, i32* null, i32* null, i32* null)
br label %47
47: ; preds = %35, %43
%48 = phi i32 [ %46, %43 ], [ -1, %35 ]
ret i32 %48
}