#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 scalar_t__ u_int8_t;
typedef scalar_t__ const u_int32_t;
typedef int /*<<< orphan*/ u_char;
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ GETLONG(scalar_t__ const, int /*<<< orphan*/ const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ precsize_ntoa(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strdup(int /*<<< orphan*/);
const char *loc_ntoa(const u_char *binary, char *ascii) {
  static const char error[] = "?";
  static char tmpbuf[sizeof "1000 60 60.000 N 1000 60 60.000 W -12345678.00m "
                            "90000000.00m 90000000.00m 90000000.00m"];
  const u_char *cp = binary;
  int latdeg, latmin, latsec, latsecfrac;
  int longdeg, longmin, longsec, longsecfrac;
  char northsouth, eastwest;
  int altmeters, altfrac, altsign;
  const u_int32_t referencealt = 100000 * 100;
  int32_t latval, longval, altval;
  u_int32_t templ;
  u_int8_t sizeval, hpval, vpval, versionval;
  char *sizestr, *hpstr, *vpstr;
  versionval = *cp++;
  if (ascii == NULL)
    ascii = tmpbuf;
  if (versionval) {
    (void)sprintf(ascii, "; error: unknown LOC RR version");
    return (ascii);
  }
  sizeval = *cp++;
  hpval = *cp++;
  vpval = *cp++;
  GETLONG(templ, cp);
  latval = (templ - ((unsigned)1 << 31));
  GETLONG(templ, cp);
  longval = (templ - ((unsigned)1 << 31));
  GETLONG(templ, cp);
  if (templ < referencealt) {
    altval = referencealt - templ;
    altsign = -1;
  } else {
    altval = templ - referencealt;
    altsign = 1;
  }
  if (latval < 0) {
    northsouth = 'S';
    latval = -latval;
  } else
    northsouth = 'N';
  latsecfrac = latval % 1000;
  latval = latval / 1000;
  latsec = latval % 60;
  latval = latval / 60;
  latmin = latval % 60;
  latval = latval / 60;
  latdeg = latval;
  if (longval < 0) {
    eastwest = 'W';
    longval = -longval;
  } else
    eastwest = 'E';
  longsecfrac = longval % 1000;
  longval = longval / 1000;
  longsec = longval % 60;
  longval = longval / 60;
  longmin = longval % 60;
  longval = longval / 60;
  longdeg = longval;
  altfrac = altval % 100;
  altmeters = (altval / 100) * altsign;
  if ((sizestr = strdup(precsize_ntoa(sizeval))) == NULL)
    sizestr = (char *)error;
  if ((hpstr = strdup(precsize_ntoa(hpval))) == NULL)
    hpstr = (char *)error;
  if ((vpstr = strdup(precsize_ntoa(vpval))) == NULL)
    vpstr = (char *)error;
  sprintf(
      ascii, "%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",
      latdeg, latmin, latsec, latsecfrac, northsouth, longdeg, longmin, longsec,
      longsecfrac, eastwest, altmeters, altfrac, sizestr, hpstr, vpstr);
  if (sizestr != (char *)error)
    free(sizestr);
  if (hpstr != (char *)error)
    free(hpstr);
  if (vpstr != (char *)error)
    free(vpstr);
  return (ascii);
}


x86 assembly (clang, -O0):
<loc_ntoa>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rdi,-0x38(%rbp)
mov    %rsi,-0x40(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x989680,-0x80(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
movslq (%rax),%rax
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11ab <loc_ntoa+0x5b>
lea    0x2eb9(%rip),%rax
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0xb8(%rbp)
je     11d8 <loc_ntoa+0x88>
mov    -0x40(%rbp),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    15df <loc_ntoa+0x48f>
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
movslq (%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
movslq (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x48(%rbp)
movslq (%rax),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <GETLONG@plt>
mov    -0x98(%rbp),%rax
movabs $0x80000000,%rcx
sub    %rcx,%rax
mov    %eax,-0x84(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <GETLONG@plt>
mov    -0x98(%rbp),%rax
movabs $0x80000000,%rcx
sub    %rcx,%rax
mov    %eax,-0x88(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1040 <GETLONG@plt>
cmpq   $0x989680,-0x98(%rbp)
jge    12b6 <loc_ntoa+0x166>
mov    $0x989680,%eax
sub    -0x98(%rbp),%rax
mov    %eax,-0x8c(%rbp)
movl   $0xffffffff,-0x78(%rbp)
jmp    12d0 <loc_ntoa+0x180>
mov    -0x98(%rbp),%rax
sub    $0x989680,%rax
mov    %eax,-0x8c(%rbp)
movl   $0x1,-0x78(%rbp)
cmpl   $0x0,-0x84(%rbp)
jge    12f4 <loc_ntoa+0x1a4>
movb   $0x53,-0x69(%rbp)
xor    %eax,%eax
sub    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
jmp    12f8 <loc_ntoa+0x1a8>
movb   $0x4e,-0x69(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x58(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x54(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x50(%rbp)
mov    -0x84(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x88(%rbp)
jge    1394 <loc_ntoa+0x244>
movb   $0x57,-0x6a(%rbp)
xor    %eax,%eax
sub    -0x88(%rbp),%eax
mov    %eax,-0x88(%rbp)
jmp    1398 <loc_ntoa+0x248>
movb   $0x45,-0x6a(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,-0x68(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x64(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x60(%rbp)
mov    -0x88(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,-0x88(%rbp)
mov    -0x88(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x8c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x74(%rbp)
mov    -0x8c(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
imul   -0x78(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0xa0(%rbp),%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,-0xc0(%rbp)
cmp    $0x0,%rax
jne    1468 <loc_ntoa+0x318>
lea    0xb9f(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xa8(%rbp),%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,-0xc8(%rbp)
cmp    $0x0,%rax
jne    149a <loc_ntoa+0x34a>
lea    0xb6d(%rip),%rax
mov    %rax,-0xc8(%rbp)
mov    -0xb0(%rbp),%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,-0xd0(%rbp)
cmp    $0x0,%rax
jne    14cc <loc_ntoa+0x37c>
lea    0xb3b(%rip),%rax
mov    %rax,-0xd0(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
mov    -0x58(%rbp),%r9d
movsbl -0x69(%rbp),%eax
mov    -0x5c(%rbp),%esi
mov    %esi,-0xe0(%rbp)
mov    -0x60(%rbp),%esi
mov    %esi,-0xdc(%rbp)
mov    -0x64(%rbp),%r13d
mov    -0x68(%rbp),%r12d
movsbl -0x6a(%rbp),%r15d
mov    -0x70(%rbp),%r14d
mov    -0x74(%rbp),%ebx
mov    -0xc0(%rbp),%r11
mov    -0xc8(%rbp),%r10
mov    -0xd0(%rbp),%rsi
mov    %rsi,-0xd8(%rbp)
lea    0xaf7(%rip),%rsi
mov    %eax,(%rsp)
mov    -0xe0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0xdc(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0xd8(%rbp),%rax
mov    %r13d,0x18(%rsp)
mov    %r12d,0x20(%rsp)
mov    %r15d,0x28(%rsp)
mov    %r14d,0x30(%rsp)
mov    %ebx,0x38(%rsp)
mov    %r11,0x40(%rsp)
mov    %r10,0x48(%rsp)
mov    %rax,0x50(%rsp)
mov    $0x0,%al
call   1050 <sprintf@plt>
lea    0xa82(%rip),%rax
cmp    %rax,-0xc0(%rbp)
je     1597 <loc_ntoa+0x447>
mov    -0xc0(%rbp),%rdi
call   1030 <free@plt>
lea    0xa62(%rip),%rax
cmp    %rax,-0xc8(%rbp)
je     15b7 <loc_ntoa+0x467>
mov    -0xc8(%rbp),%rdi
call   1030 <free@plt>
lea    0xa42(%rip),%rax
cmp    %rax,-0xd0(%rbp)
je     15d7 <loc_ntoa+0x487>
mov    -0xd0(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<loc_ntoa>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rsi,%rsi
lea    0x2efd(%rip),%r13
cmovne %rsi,%r13
cmpl   $0x0,(%rdi)
je     1189 <loc_ntoa+0x39>
movups 0xe9f(%rip),%xmm0
movups %xmm0,0x10(%r13)
movups 0xe83(%rip),%xmm0
movups %xmm0,0x0(%r13)
jmp    1266 <loc_ntoa+0x116>
mov    %rdi,%rbx
movslq 0x4(%rdi),%r14
movslq 0x8(%rdi),%r15
movslq 0xc(%rdi),%r12
add    $0x10,%rbx
mov    %rbx,%rsi
call   1040 <GETLONG@plt>
mov    %rbx,%rsi
call   1040 <GETLONG@plt>
mov    %rbx,%rsi
call   1040 <GETLONG@plt>
mov    %r14,%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,%r14
test   %rax,%rax
lea    0xe30(%rip),%rbx
cmove  %rbx,%r14
mov    %r15,%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,%r15
test   %rax,%rax
cmove  %rbx,%r15
mov    %r12,%rdi
call   1070 <precsize_ntoa@plt>
mov    %eax,%edi
call   1060 <strdup@plt>
mov    %rax,%r12
test   %rax,%rax
cmove  %rbx,%r12
sub    $0x8,%rsp
lea    0xe11(%rip),%rsi
mov    %r13,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
push   %r12
push   %r15
push   %r14
push   $0x0
push   $0x0
push   $0x45
push   $0x0
push   $0x0
push   $0x0
push   $0x0
push   $0x4e
call   1050 <sprintf@plt>
add    $0x60,%rsp
cmp    %rbx,%r14
je     124c <loc_ntoa+0xfc>
mov    %r14,%rdi
call   1030 <free@plt>
cmp    %rbx,%r15
je     1259 <loc_ntoa+0x109>
mov    %r15,%rdi
call   1030 <free@plt>
cmp    %rbx,%r12
je     1266 <loc_ntoa+0x116>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@loc_ntoa.error = internal constant [2 x i8] c"?\00"
@loc_ntoa.tmpbuf = internal global [87 x i8] zeroinitializer
@.str = [32 x i8] c"; error: unknown LOC RR version\00"
@.str.1 = [63 x i8] c"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm\00"
define i8* @loc_ntoa(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
%16 = alloca i8
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i64
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i64
%25 = alloca i64
%26 = alloca i64
%27 = alloca i64
%28 = alloca i64
%29 = alloca i8*
%30 = alloca i8*
%31 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%32 = load i32*, i32** %4
store i32* %32, i32** %6
store i64 10000000, i64* %20
%33 = load i32*, i32** %6
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %6
%35 = load i32, i32* %33
%36 = sext i32 %35 to i64
store i64 %36, i64* %28
%37 = load i8*, i8** %5
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %40
39: ; preds = %2
store i8* getelementptr inbounds ([87 x i8], [87 x i8]* @loc_ntoa.tmpbuf, i64 0, i64 0), i8** %5
br label %40
40: ; preds = %39, %2
%41 = load i64, i64* %28
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i8*, i8** %5
%45 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%46 = load i8*, i8** %5
store i8* %46, i8** %3
br label %188
47: ; preds = %40
%48 = load i32*, i32** %6
%49 = getelementptr inbounds i32, i32* %48, i32 1
store i32* %49, i32** %6
%50 = load i32, i32* %48
%51 = sext i32 %50 to i64
store i64 %51, i64* %25
%52 = load i32*, i32** %6
%53 = getelementptr inbounds i32, i32* %52, i32 1
store i32* %53, i32** %6
%54 = load i32, i32* %52
%55 = sext i32 %54 to i64
store i64 %55, i64* %26
%56 = load i32*, i32** %6
%57 = getelementptr inbounds i32, i32* %56, i32 1
store i32* %57, i32** %6
%58 = load i32, i32* %56
%59 = sext i32 %58 to i64
store i64 %59, i64* %27
%60 = load i64, i64* %24
%61 = load i32*, i32** %6
%62 = call i32 @GETLONG(i64 %60, i32* %61)
%63 = load i64, i64* %24
%64 = sub nsw i64 %63, 2147483648
%65 = trunc i64 %64 to i32
store i32 %65, i32* %21
%66 = load i64, i64* %24
%67 = load i32*, i32** %6
%68 = call i32 @GETLONG(i64 %66, i32* %67)
%69 = load i64, i64* %24
%70 = sub nsw i64 %69, 2147483648
%71 = trunc i64 %70 to i32
store i32 %71, i32* %22
%72 = load i64, i64* %24
%73 = load i32*, i32** %6
%74 = call i32 @GETLONG(i64 %72, i32* %73)
%75 = load i64, i64* %24
%76 = icmp slt i64 %75, 10000000
br i1 %76, label %77, label %81
77: ; preds = %47
%78 = load i64, i64* %24
%79 = sub nsw i64 10000000, %78
%80 = trunc i64 %79 to i32
store i32 %80, i32* %23
store i32 -1, i32* %19
br label %85
81: ; preds = %47
%82 = load i64, i64* %24
%83 = sub nsw i64 %82, 10000000
%84 = trunc i64 %83 to i32
store i32 %84, i32* %23
store i32 1, i32* %19
br label %85
85: ; preds = %81, %77
%86 = load i32, i32* %21
%87 = icmp slt i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %85
store i8 83, i8* %15
%89 = load i32, i32* %21
%90 = sub nsw i32 0, %89
store i32 %90, i32* %21
br label %92
91: ; preds = %85
store i8 78, i8* %15
br label %92
92: ; preds = %91, %88
%93 = load i32, i32* %21
%94 = srem i32 %93, 1000
store i32 %94, i32* %10
%95 = load i32, i32* %21
%96 = sdiv i32 %95, 1000
store i32 %96, i32* %21
%97 = load i32, i32* %21
%98 = srem i32 %97, 60
store i32 %98, i32* %9
%99 = load i32, i32* %21
%100 = sdiv i32 %99, 60
store i32 %100, i32* %21
%101 = load i32, i32* %21
%102 = srem i32 %101, 60
store i32 %102, i32* %8
%103 = load i32, i32* %21
%104 = sdiv i32 %103, 60
store i32 %104, i32* %21
%105 = load i32, i32* %21
store i32 %105, i32* %7
%106 = load i32, i32* %22
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %92
store i8 87, i8* %16
%109 = load i32, i32* %22
%110 = sub nsw i32 0, %109
store i32 %110, i32* %22
br label %112
111: ; preds = %92
store i8 69, i8* %16
br label %112
112: ; preds = %111, %108
%113 = load i32, i32* %22
%114 = srem i32 %113, 1000
store i32 %114, i32* %14
%115 = load i32, i32* %22
%116 = sdiv i32 %115, 1000
store i32 %116, i32* %22
%117 = load i32, i32* %22
%118 = srem i32 %117, 60
store i32 %118, i32* %13
%119 = load i32, i32* %22
%120 = sdiv i32 %119, 60
store i32 %120, i32* %22
%121 = load i32, i32* %22
%122 = srem i32 %121, 60
store i32 %122, i32* %12
%123 = load i32, i32* %22
%124 = sdiv i32 %123, 60
store i32 %124, i32* %22
%125 = load i32, i32* %22
store i32 %125, i32* %11
%126 = load i32, i32* %23
%127 = srem i32 %126, 100
store i32 %127, i32* %18
%128 = load i32, i32* %23
%129 = sdiv i32 %128, 100
%130 = load i32, i32* %19
%131 = mul nsw i32 %129, %130
store i32 %131, i32* %17
%132 = load i64, i64* %25
%133 = call i32 @precsize_ntoa(i64 %132)
%134 = call i8* @strdup(i32 %133)
store i8* %134, i8** %29
%135 = icmp eq i8* %134, null
br i1 %135, label %136, label %137
136: ; preds = %112
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8** %29
br label %137
137: ; preds = %136, %112
%138 = load i64, i64* %26
%139 = call i32 @precsize_ntoa(i64 %138)
%140 = call i8* @strdup(i32 %139)
store i8* %140, i8** %30
%141 = icmp eq i8* %140, null
br i1 %141, label %142, label %143
142: ; preds = %137
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8** %30
br label %143
143: ; preds = %142, %137
%144 = load i64, i64* %27
%145 = call i32 @precsize_ntoa(i64 %144)
%146 = call i8* @strdup(i32 %145)
store i8* %146, i8** %31
%147 = icmp eq i8* %146, null
br i1 %147, label %148, label %149
148: ; preds = %143
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8** %31
br label %149
149: ; preds = %148, %143
%150 = load i8*, i8** %5
%151 = load i32, i32* %7
%152 = load i32, i32* %8
%153 = load i32, i32* %9
%154 = load i32, i32* %10
%155 = load i8, i8* %15
%156 = sext i8 %155 to i32
%157 = load i32, i32* %11
%158 = load i32, i32* %12
%159 = load i32, i32* %13
%160 = load i32, i32* %14
%161 = load i8, i8* %16
%162 = sext i8 %161 to i32
%163 = load i32, i32* %17
%164 = load i32, i32* %18
%165 = load i8*, i8** %29
%166 = load i8*, i8** %30
%167 = load i8*, i8** %31
%168 = call i32 (i8*, i8*, ...) @sprintf(i8* %150, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 %151, i32 %152, i32 %153, i32 %154, i32 %156, i32 %157, i32 %158, i32 %159, i32 %160, i32 %162, i32 %163, i32 %164, i8* %165, i8* %166, i8* %167)
%169 = load i8*, i8** %29
%170 = icmp ne i8* %169, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %170, label %171, label %174
171: ; preds = %149
%172 = load i8*, i8** %29
%173 = call i32 @free(i8* %172)
br label %174
174: ; preds = %171, %149
%175 = load i8*, i8** %30
%176 = icmp ne i8* %175, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %176, label %177, label %180
177: ; preds = %174
%178 = load i8*, i8** %30
%179 = call i32 @free(i8* %178)
br label %180
180: ; preds = %177, %174
%181 = load i8*, i8** %31
%182 = icmp ne i8* %181, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %182, label %183, label %186
183: ; preds = %180
%184 = load i8*, i8** %31
%185 = call i32 @free(i8* %184)
br label %186
186: ; preds = %183, %180
%187 = load i8*, i8** %5
store i8* %187, i8** %3
br label %188
188: ; preds = %186, %43
%189 = load i8*, i8** %3
ret i8* %189
}

LLVM IR (-O2):
@loc_ntoa.error = internal constant [2 x i8] c"?\00"
@loc_ntoa.tmpbuf = internal global [87 x i8] zeroinitializer
@.str = [32 x i8] c"; error: unknown LOC RR version\00"
@.str.1 = [63 x i8] c"%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm\00"
define i8* @loc_ntoa(i32* %0, i8* writeonly %1) {
%3 = load i32, i32* %0
%4 = icmp eq i8* %1, null
%5 = select i1 %4, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @loc_ntoa.tmpbuf, i64 0, i64 0), i8* %1
%6 = icmp eq i32 %3, 0
br i1 %6, label %8, label %7
7: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(32) %5, i8* align 1 dereferenceable(32) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 32, i1 false)
br label %46
8: ; preds = %2
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = load i32, i32* %9
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 3
%14 = load i32, i32* %10
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %0, i64 4
%17 = load i32, i32* %13
%18 = sext i32 %17 to i64
%19 = tail call i32 @GETLONG(i64 undef, i32* %16)
%20 = tail call i32 @GETLONG(i64 undef, i32* %16)
%21 = tail call i32 @GETLONG(i64 undef, i32* %16)
%22 = tail call i32 @precsize_ntoa(i64 %12)
%23 = tail call i8* @strdup(i32 %22)
%24 = icmp eq i8* %23, null
%25 = select i1 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8* %23
%26 = tail call i32 @precsize_ntoa(i64 %15)
%27 = tail call i8* @strdup(i32 %26)
%28 = icmp eq i8* %27, null
%29 = select i1 %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8* %27
%30 = tail call i32 @precsize_ntoa(i64 %18)
%31 = tail call i8* @strdup(i32 %30)
%32 = icmp eq i8* %31, null
%33 = select i1 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0), i8* %31
%34 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 0, i32 0, i32 0, i32 78, i32 0, i32 0, i32 0, i32 0, i32 69, i32 0, i32 0, i8* %25, i8* %29, i8* %33)
%35 = icmp eq i8* %25, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %35, label %38, label %36
36: ; preds = %8
%37 = tail call i32 @free(i8* %25)
br label %38
38: ; preds = %36, %8
%39 = icmp eq i8* %29, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %39, label %42, label %40
40: ; preds = %38
%41 = tail call i32 @free(i8* %29)
br label %42
42: ; preds = %40, %38
%43 = icmp eq i8* %33, getelementptr inbounds ([2 x i8], [2 x i8]* @loc_ntoa.error, i64 0, i64 0)
br i1 %43, label %46, label %44
44: ; preds = %42
%45 = tail call i32 @free(i8* %33)
br label %46
46: ; preds = %42, %44, %7
ret i8* %5
}