#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 */
long Extract_Degrees(char *, double *, double *);
long Extract_Minutes(char *, long, long, int, double *);
long strlen(char *);
long Convert_GEOREF_To_Geodetic(char *georef, double *latitude,
                                double *longitude) {
  long start;
  long minutes_length;
  long georef_length;
  double origin_long;
  double origin_lat;
  double long_minutes;
  double lat_minutes;
  long error_code = 0x0000;
  origin_long = (double)-180;
  origin_lat = (double)-90;
  georef_length = strlen(georef);
  if ((georef_length < 4) || (georef_length > 14) ||
      ((georef_length % 2) != 0)) {
    error_code |= 0x0004;
  }
  if (!error_code) {
    error_code |= Extract_Degrees(georef, latitude, longitude);
    start = 4;
    minutes_length = (georef_length - start) / 2;
    if (!error_code) {
      error_code |=
          Extract_Minutes(georef, start, minutes_length, 0x0040, &long_minutes);
      if (!error_code) {
        error_code |= Extract_Minutes(georef, (start + minutes_length),
                                      minutes_length, 0x0020, &lat_minutes);
        *latitude = *latitude + origin_lat + lat_minutes / (double)60;
        *longitude = *longitude + origin_long + long_minutes / (double)60;
        *latitude = *latitude * (3.14159265358979323e0 / 180.0);
        *longitude = *longitude * (3.14159265358979323e0 / 180.0);
      }
    }
  }
  return (error_code);
}


x86 assembly (clang, -O0):
<Convert_GEOREF_To_Geodetic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x58(%rbp)
movsd  0xeb4(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x4,-0x30(%rbp)
jl     11a1 <Convert_GEOREF_To_Geodetic+0x71>
cmpq   $0xe,-0x30(%rbp)
jg     11a1 <Convert_GEOREF_To_Geodetic+0x71>
mov    -0x30(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
je     11ad <Convert_GEOREF_To_Geodetic+0x7d>
mov    -0x58(%rbp),%rax
or     $0x4,%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12db <Convert_GEOREF_To_Geodetic+0x1ab>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <Extract_Degrees@plt>
or     -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
movq   $0x4,-0x20(%rbp)
mov    -0x30(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12d6 <Convert_GEOREF_To_Geodetic+0x1a6>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x40,%ecx
lea    -0x48(%rbp),%r8
call   1030 <Extract_Minutes@plt>
or     -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12d1 <Convert_GEOREF_To_Geodetic+0x1a1>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
add    -0x28(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x20,%ecx
lea    -0x50(%rbp),%r8
call   1030 <Extract_Minutes@plt>
or     -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  0xd87(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movsd  0xd63(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  0xd4b(%rip),%xmm0
mulsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12d6 <Convert_GEOREF_To_Geodetic+0x1a6>
jmp    12db <Convert_GEOREF_To_Geodetic+0x1ab>
mov    -0x58(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Convert_GEOREF_To_Geodetic>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
call   1040 <strlen@plt>
mov    %rax,%rbx
lea    -0x4(%rax),%rcx
mov    $0x4,%eax
cmp    $0xa,%rcx
ja     1233 <Convert_GEOREF_To_Geodetic+0x103>
mov    %ebx,%ecx
and    $0x1,%ecx
test   %rcx,%rcx
jne    1233 <Convert_GEOREF_To_Geodetic+0x103>
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <Extract_Degrees@plt>
test   %rax,%rax
jne    1233 <Convert_GEOREF_To_Geodetic+0x103>
add    $0xfc,%ebx
shr    %ebx
and    $0x7f,%ebx
lea    0x10(%rsp),%r8
mov    $0x4,%esi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x40,%ecx
call   1030 <Extract_Minutes@plt>
test   %rax,%rax
jne    1233 <Convert_GEOREF_To_Geodetic+0x103>
lea    0x4(%rbx),%rsi
lea    0x8(%rsp),%r8
mov    %r12,%rdi
mov    %rbx,%rdx
mov    $0x20,%ecx
call   1030 <Extract_Minutes@plt>
movsd  (%r15),%xmm0
addsd  0xe28(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe22(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
movsd  (%r14),%xmm0
addsd  0xe10(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
divsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
movsd  0xdfd(%rip),%xmm0
movsd  (%r15),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%r15)
mulsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @Convert_GEOREF_To_Geodetic(i8* %0, double* %1, double* %2) {
%4 = alloca i8*
%5 = alloca double*
%6 = alloca double*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i64
store i8* %0, i8** %4
store double* %1, double** %5
store double* %2, double** %6
store i64 0, i64* %14
store double -1.800000e+02, double* %10
store double -9.000000e+01, double* %11
%15 = load i8*, i8** %4
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %9
%17 = load i64, i64* %9
%18 = icmp slt i64 %17, 4
br i1 %18, label %26, label %19
19: ; preds = %3
%20 = load i64, i64* %9
%21 = icmp sgt i64 %20, 14
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = load i64, i64* %9
%24 = srem i64 %23, 2
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22, %19, %3
%27 = load i64, i64* %14
%28 = or i64 %27, 4
store i64 %28, i64* %14
br label %29
29: ; preds = %26, %22
%30 = load i64, i64* %14
%31 = icmp ne i64 %30, 0
br i1 %31, label %89, label %32
32: ; preds = %29
%33 = load i8*, i8** %4
%34 = load double*, double** %5
%35 = load double*, double** %6
%36 = call i64 @Extract_Degrees(i8* %33, double* %34, double* %35)
%37 = load i64, i64* %14
%38 = or i64 %37, %36
store i64 %38, i64* %14
store i64 4, i64* %7
%39 = load i64, i64* %9
%40 = load i64, i64* %7
%41 = sub nsw i64 %39, %40
%42 = sdiv i64 %41, 2
store i64 %42, i64* %8
%43 = load i64, i64* %14
%44 = icmp ne i64 %43, 0
br i1 %44, label %88, label %45
45: ; preds = %32
%46 = load i8*, i8** %4
%47 = load i64, i64* %7
%48 = load i64, i64* %8
%49 = call i64 @Extract_Minutes(i8* %46, i64 %47, i64 %48, i32 64, double* %12)
%50 = load i64, i64* %14
%51 = or i64 %50, %49
store i64 %51, i64* %14
%52 = load i64, i64* %14
%53 = icmp ne i64 %52, 0
br i1 %53, label %87, label %54
54: ; preds = %45
%55 = load i8*, i8** %4
%56 = load i64, i64* %7
%57 = load i64, i64* %8
%58 = add nsw i64 %56, %57
%59 = load i64, i64* %8
%60 = call i64 @Extract_Minutes(i8* %55, i64 %58, i64 %59, i32 32, double* %13)
%61 = load i64, i64* %14
%62 = or i64 %61, %60
store i64 %62, i64* %14
%63 = load double*, double** %5
%64 = load double, double* %63
%65 = load double, double* %11
%66 = fadd double %64, %65
%67 = load double, double* %13
%68 = fdiv double %67, 6.000000e+01
%69 = fadd double %66, %68
%70 = load double*, double** %5
store double %69, double* %70
%71 = load double*, double** %6
%72 = load double, double* %71
%73 = load double, double* %10
%74 = fadd double %72, %73
%75 = load double, double* %12
%76 = fdiv double %75, 6.000000e+01
%77 = fadd double %74, %76
%78 = load double*, double** %6
store double %77, double* %78
%79 = load double*, double** %5
%80 = load double, double* %79
%81 = fmul double %80, 0x3F91DF46A2529D39
%82 = load double*, double** %5
store double %81, double* %82
%83 = load double*, double** %6
%84 = load double, double* %83
%85 = fmul double %84, 0x3F91DF46A2529D39
%86 = load double*, double** %6
store double %85, double* %86
br label %87
87: ; preds = %54, %45
br label %88
88: ; preds = %87, %32
br label %89
89: ; preds = %88, %29
%90 = load i64, i64* %14
ret i64 %90
}

LLVM IR (-O2):
define i64 @Convert_GEOREF_To_Geodetic(i8* %0, double* %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = bitcast double* %4 to i8*
%7 = bitcast double* %5 to i8*
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%9 = add i64 %8, -4
%10 = icmp ult i64 %9, 11
%11 = and i64 %8, 1
%12 = icmp eq i64 %11, 0
%13 = and i1 %10, %12
br i1 %13, label %14, label %40
14: ; preds = %3
%15 = tail call i64 @Extract_Degrees(i8* %0, double* %1, double* %2)
%16 = add nuw nsw i64 %8, 252
%17 = lshr i64 %16, 1
%18 = and i64 %17, 127
%19 = icmp eq i64 %15, 0
br i1 %19, label %20, label %40
20: ; preds = %14
%21 = call i64 @Extract_Minutes(i8* %0, i64 4, i64 %18, i32 64, double* %4)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %40
23: ; preds = %20
%24 = add nuw nsw i64 %18, 4
%25 = call i64 @Extract_Minutes(i8* %0, i64 %24, i64 %18, i32 32, double* %5)
%26 = load double, double* %1
%27 = fadd double %26, -9.000000e+01
%28 = load double, double* %5
%29 = fdiv double %28, 6.000000e+01
%30 = fadd double %27, %29
store double %30, double* %1
%31 = load double, double* %2
%32 = fadd double %31, -1.800000e+02
%33 = load double, double* %4
%34 = fdiv double %33, 6.000000e+01
%35 = fadd double %32, %34
store double %35, double* %2
%36 = load double, double* %1
%37 = fmul double %36, 0x3F91DF46A2529D39
store double %37, double* %1
%38 = load double, double* %2
%39 = fmul double %38, 0x3F91DF46A2529D39
store double %39, double* %2
br label %40
40: ; preds = %14, %23, %20, %3
%41 = phi i64 [ 4, %3 ], [ %15, %14 ], [ %21, %20 ], [ %25, %23 ]
ret i64 %41
}