#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 /*<<< orphan*/ fill_hs(char, char, double *, double *);
double calc_tm(char *ss, int n) {
  int i;
  double h, s, tm;
  h = s = 0.0;
  for (i = 0; i < n - 1; i++)
    fill_hs(ss[i], ss[i + 1], &h, &s);
  tm = h / (s + 47.16510465) - 294.6124334;
  return tm;
}


x86 assembly (clang, -O0):
<calc_tm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1183 <calc_tm+0x73>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,1),%dil
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
movsbl %dil,%edi
movsbl (%rax,%rsi,1),%esi
call   1030 <fill_hs@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <calc_tm+0x26>
movsd  -0x18(%rbp),%xmm0
movsd  0xe78(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_tm>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
cmp    $0x2,%esi
jl     1191 <calc_tm+0x81>
mov    %esi,%r14d
mov    %rdi,%r13
add    $0xffffffff,%r14d
xor    %ebx,%ebx
lea    0x8(%rsp),%r15
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%rbx,1),%edi
movsbl 0x1(%r13,%rbx,1),%esi
add    $0x1,%rbx
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <fill_hs@plt>
cmp    %rbx,%r14
jne    1150 <calc_tm+0x40>
movsd  (%rsp),%xmm1
addsd  0xe8b(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
divsd  %xmm1,%xmm0
addsd  0xe71(%rip),%xmm0
jmp    1199 <calc_tm+0x89>
movsd  0xe67(%rip),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @calc_tm(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i8* %0, i8** %3
store i32 %1, i32* %4
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %6
store i32 0, i32* %5
br label %9
9: ; preds = %27, %2
%10 = load i32, i32* %5
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %30
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = load i8*, i8** %3
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = load i8, i8* %24
%26 = call i32 @fill_hs(i8 signext %19, i8 signext %25, double* %6, double* %7)
br label %27
27: ; preds = %14
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %9
30: ; preds = %9
%31 = load double, double* %6
%32 = load double, double* %7
%33 = fadd double %32, 0x4047952226301572
%34 = fdiv double %31, %33
%35 = fsub double %34, 0x407269CC86F6FFA6
store double %35, double* %8
%36 = load double, double* %8
ret double %36
}

LLVM IR (-O2):
define double @calc_tm(i8* nocapture %0, i32 %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %3
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = add nsw i32 %1, -1
%10 = zext i32 %9 to i64
br label %11
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %15, %11 ]
%13 = getelementptr inbounds i8, i8* %0, i64 %12
%14 = load i8, i8* %13
%15 = add nuw nsw i64 %12, 1
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @fill_hs(i8 signext %14, i8 signext %17, double* %3, double* %4)
%19 = icmp eq i64 %15, %10
br i1 %19, label %20, label %11
20: ; preds = %11
%21 = load double, double* %3
%22 = load double, double* %4
%23 = fadd double %22, 0x4047952226301572
%24 = fdiv double %21, %23
%25 = fadd double %24, 0xC07269CC86F6FFA6
br label %26
26: ; preds = %20, %2
%27 = phi double [ %25, %20 ], [ 0xC07269CC86F6FFA6, %2 ]
ret double %27
}