#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*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
double dms2d(char *, int, float);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, int *, float *);
int read_latlon(FILE *in, double *lat, double *lon) {
  char d[5];
  int m;
  float s;
  if (fscanf(in, "%s %d %f\n", d, &m, &s) == EOF)
    return -1;
  *lat = dms2d(d, m, s);
  if (fscanf(in, "%s %d %f", d, &m, &s) == EOF)
    return -1;
  *lon = dms2d(d, m, s);
  return 0;
}


x86 assembly (clang, -O0):
<read_latlon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x25(%rbp),%rdx
lea    0xebd(%rip),%rsi
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1030 <fscanf@plt>
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%rax
jne    116c <read_latlon+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <read_latlon+0xbd>
lea    -0x25(%rbp),%rdi
mov    -0x2c(%rbp),%esi
movss  -0x30(%rbp),%xmm0
call   1040 <dms2d@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x25(%rbp),%rdx
lea    0xe76(%rip),%rsi
lea    -0x2c(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1030 <fscanf@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11bd <read_latlon+0x9d>
movl   $0xffffffff,-0x4(%rbp)
jmp    11dd <read_latlon+0xbd>
lea    -0x25(%rbp),%rdi
mov    -0x2c(%rbp),%esi
movss  -0x30(%rbp),%xmm0
call   1040 <dms2d@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_latlon>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xec2(%rip),%rsi
lea    0x13(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1030 <fscanf@plt>
mov    0x2e8f(%rip),%r13
mov    $0xffffffff,%ebp
cmp    0x0(%r13),%rax
je     11bd <read_latlon+0x9d>
mov    0xc(%rsp),%esi
movss  0x8(%rsp),%xmm0
lea    0x13(%rsp),%r12
mov    %r12,%rdi
call   1040 <dms2d@plt>
movsd  %xmm0,(%r15)
lea    0xe83(%rip),%rsi
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
mov    %r12,%rdx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%rax
je     11bd <read_latlon+0x9d>
mov    0xc(%rsp),%esi
movss  0x8(%rsp),%xmm0
lea    0x13(%rsp),%rdi
call   1040 <dms2d@plt>
movsd  %xmm0,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"%s %d %f\0A\00"
@EOF = global i64 0
@.str.1 = [9 x i8] c"%s %d %f\00"
define i32 @read_latlon(i32* %0, double* %1, double* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca double*
%7 = alloca double*
%8 = alloca [5 x i8]
%9 = alloca i32
%10 = alloca float
store i32* %0, i32** %5
store double* %1, double** %6
store double* %2, double** %7
%11 = load i32*, i32** %5
%12 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%13 = call i64 @fscanf(i32* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %12, i32* %9, float* %10)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -1, i32* %4
br label %35
17: ; preds = %3
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%19 = load i32, i32* %9
%20 = load float, float* %10
%21 = call double @dms2d(i8* %18, i32 %19, float %20)
%22 = load double*, double** %6
store double %21, double* %22
%23 = load i32*, i32** %5
%24 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%25 = call i64 @fscanf(i32* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %24, i32* %9, float* %10)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %29
28: ; preds = %17
store i32 -1, i32* %4
br label %35
29: ; preds = %17
%30 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%31 = load i32, i32* %9
%32 = load float, float* %10
%33 = call double @dms2d(i8* %30, i32 %31, float %32)
%34 = load double*, double** %7
store double %33, double* %34
store i32 0, i32* %4
br label %35
35: ; preds = %29, %28, %16
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
@.str = [10 x i8] c"%s %d %f\0A\00"
@EOF = global i64 0
@.str.1 = [9 x i8] c"%s %d %f\00"
define i32 @read_latlon(i32* nocapture %0, double* nocapture writeonly %1, double* nocapture writeonly %2) {
%4 = alloca [5 x i8]
%5 = alloca i32
%6 = alloca float
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = bitcast i32* %5 to i8*
%9 = bitcast float* %6 to i8*
%10 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %7, i32* %5, float* %6)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %24, label %13
13: ; preds = %3
%14 = load i32, i32* %5
%15 = load float, float* %6
%16 = call double @dms2d(i8* %7, i32 %14, float %15)
store double %16, double* %1
%17 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %7, i32* %5, float* %6)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %24, label %20
20: ; preds = %13
%21 = load i32, i32* %5
%22 = load float, float* %6
%23 = call double @dms2d(i8* %7, i32 %21, float %22)
store double %23, double* %2
br label %24
24: ; preds = %13, %3, %20
%25 = phi i32 [ 0, %20 ], [ -1, %3 ], [ -1, %13 ]
ret i32 %25
}