#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 */
double atof(char *);
int strcspn(char *, char *);
double to_seconds(char *str) {
  int pointindex = strcspn(str, ".");
  double mins, degs;
  if (pointindex < 2)
    return 0;
  mins = atof(str + pointindex - 2);
  str[pointindex - 2] = 0;
  degs = atof(str);
  return degs * 3600.0 + mins * 60.0;
}


x86 assembly (clang, -O0):
<to_seconds>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1040 <strcspn@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jge    1156 <to_seconds+0x36>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b5 <to_seconds+0x95>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffe,%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe6d(%rip),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe58(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_seconds>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xee2(%rip),%rsi
call   1040 <strcspn@plt>
cmp    $0x2,%eax
jge    113e <to_seconds+0x1e>
xorpd  %xmm0,%xmm0
jmp    117d <to_seconds+0x5d>
mov    %eax,%ebx
mov    %eax,%eax
lea    (%r14,%rax,1),%rdi
add    $0xfffffffffffffffe,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
add    $0xfffffffe,%ebx
movb   $0x0,(%r14,%rbx,1)
mov    %r14,%rdi
call   1030 <atof@plt>
movsd  (%rsp),%xmm1
mulsd  0xe8f(%rip),%xmm1
mulsd  0xe8f(%rip),%xmm0
addsd  %xmm1,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define double @to_seconds(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32 @strcspn(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %4
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %12
11: ; preds = %1
store double 0.000000e+00, double* %2
br label %30
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -2
%18 = call double @atof(i8* %17)
store double %18, double* %5
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
store i8 0, i8* %23
%24 = load i8*, i8** %3
%25 = call double @atof(i8* %24)
store double %25, double* %6
%26 = load double, double* %6
%27 = load double, double* %5
%28 = fmul double %27, 6.000000e+01
%29 = call double @llvm.fmuladd.f64(double %26, double 3.600000e+03, double %28)
store double %29, double* %2
br label %30
30: ; preds = %12, %11
%31 = load double, double* %2
ret double %31
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define double @to_seconds(i8* nocapture %0) {
%2 = tail call i32 @strcspn(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp slt i32 %2, 2
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = zext i32 %2 to i64
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = getelementptr inbounds i8, i8* %6, i64 -2
%8 = tail call double @atof(i8* %7)
%9 = add nsw i32 %2, -2
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 0, i8* %11
%12 = tail call double @atof(i8* %0)
%13 = fmul double %8, 6.000000e+01
%14 = tail call double @llvm.fmuladd.f64(double %12, double 3.600000e+03, double %13)
br label %15
15: ; preds = %1, %4
%16 = phi double [ %14, %4 ], [ 0.000000e+00, %1 ]
ret double %16
}