#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 */
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int sscanf(char *, char *, double *, double *, double *);
char *strchr(char *, char);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int f_scansexa(const char *str0, double *dp) {
  double a = 0, b = 0, c = 0;
  char str[128];
  char *neg;
  int r;
  strncpy(str, str0, sizeof(str) - 1);
  str[sizeof(str) - 1] = '\0';
  neg = strchr(str, '-');
  if (neg)
    *neg = ' ';
  r = sscanf(str, "%lf%*[^0-9]%lf%*[^0-9]%lf", &a, &b, &c);
  if (r < 1)
    return (-1);
  *dp = a + b / 60 + c / 3600;
  if (neg)
    *dp *= -1;
  return (0);
}


x86 assembly (clang, -O0):
<f_scansexa>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x7f,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x31(%rbp)
lea    -0xb0(%rbp),%rdi
mov    $0x2d,%esi
call   1040 <strchr@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
je     11a4 <f_scansexa+0x74>
mov    -0xb8(%rbp),%rax
movb   $0x20,(%rax)
lea    -0xb0(%rbp),%rdi
lea    0xe66(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1050 <sscanf@plt>
mov    %eax,-0xbc(%rbp)
cmpl   $0x1,-0xbc(%rbp)
jge    11e2 <f_scansexa+0xb2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1242 <f_scansexa+0x112>
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe14(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xdf7(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
cmpq   $0x0,-0xb8(%rbp)
je     123b <f_scansexa+0x10b>
mov    -0x18(%rbp),%rax
movsd  0xddd(%rip),%xmm0
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_scansexa>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
mov    %rsi,%r14
mov    %rdi,%rsi
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x7f,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x9f(%rsp)
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1040 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     118d <f_scansexa+0x5d>
movb   $0x20,(%rbx)
lea    0xe8c(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <sscanf@plt>
test   %eax,%eax
jle    11ed <f_scansexa+0xbd>
movsd  0x10(%rsp),%xmm1
divsd  0xe41(%rip),%xmm1
addsd  0x18(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
divsd  0xe35(%rip),%xmm0
addsd  %xmm1,%xmm0
test   %rbx,%rbx
je     11e4 <f_scansexa+0xb4>
xorpd  0xe2c(%rip),%xmm0
movsd  %xmm0,(%r14)
xor    %eax,%eax
jmp    11f2 <f_scansexa+0xc2>
mov    $0xffffffff,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"%lf%*[^0-9]%lf%*[^0-9]%lf\00"
define i32 @f_scansexa(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca [128 x i8]
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store double 0.000000e+00, double* %8
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%13 = load i8*, i8** %4
%14 = call i32 @strncpy(i8* %12, i8* %13, i32 127)
%15 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 127
store i8 0, i8* %15
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%17 = call i8* @strchr(i8* %16, i8 signext 45)
store i8* %17, i8** %10
%18 = load i8*, i8** %10
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = load i8*, i8** %10
store i8 32, i8* %21
br label %22
22: ; preds = %20, %2
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double* %6, double* %7, double* %8)
store i32 %24, i32* %11
%25 = load i32, i32* %11
%26 = icmp slt i32 %25, 1
br i1 %26, label %27, label %28
27: ; preds = %22
store i32 -1, i32* %3
br label %44
28: ; preds = %22
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fdiv double %30, 6.000000e+01
%32 = fadd double %29, %31
%33 = load double, double* %8
%34 = fdiv double %33, 3.600000e+03
%35 = fadd double %32, %34
%36 = load double*, double** %5
store double %35, double* %36
%37 = load i8*, i8** %10
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %28
%40 = load double*, double** %5
%41 = load double, double* %40
%42 = fmul double %41, -1.000000e+00
store double %42, double* %40
br label %43
43: ; preds = %39, %28
store i32 0, i32* %3
br label %44
44: ; preds = %43, %27
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [26 x i8] c"%lf%*[^0-9]%lf%*[^0-9]%lf\00"
define i32 @f_scansexa(i8* %0, double* nocapture writeonly %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca [128 x i8]
%7 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%8 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%9 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%11 = call i32 @strncpy(i8* %10, i8* %0, i32 127)
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 127
store i8 0, i8* %12
%13 = call i8* @strchr(i8* %10, i8 signext 45)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %2
store i8 32, i8* %13
br label %16
16: ; preds = %15, %2
%17 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), double* %3, double* %4, double* %5)
%18 = icmp slt i32 %17, 1
br i1 %18, label %29, label %19
19: ; preds = %16
%20 = load double, double* %3
%21 = load double, double* %4
%22 = fdiv double %21, 6.000000e+01
%23 = fadd double %20, %22
%24 = load double, double* %5
%25 = fdiv double %24, 3.600000e+03
%26 = fadd double %23, %25
%27 = fneg double %26
%28 = select i1 %14, double %26, double %27
store double %28, double* %1
br label %29
29: ; preds = %16, %19
%30 = phi i32 [ 0, %19 ], [ -1, %16 ]
ret i32 %30
}