#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 */
struct epsg_dict {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int /*<<< orphan*/ add_wkt(struct epsg_dict *, int, char *);
int fetch_srid(char *);
int getc(int /*<<< orphan*/ *);
int parse_wkt(FILE *fl_wkt, struct epsg_dict *epsg) {
  char line[8192];
  int srid;
  char *out = line;
  int c;
  while ((c = getc(fl_wkt)) != EOF) {
    if (c == '\r')
      continue;
    if (c == '\n') {
      *out = '\0';
      srid = fetch_srid(line);
      if (srid >= 0)
        add_wkt(epsg, srid, line);
      out = line;
      continue;
    }
    *out++ = c;
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_wkt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2020(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %eax,-0x2024(%rbp)
mov    0x2e81(%rip),%rcx
cmp    (%rcx),%eax
je     1204 <parse_wkt+0xd4>
cmpl   $0xd,-0x2024(%rbp)
jne    1181 <parse_wkt+0x51>
jmp    1151 <parse_wkt+0x21>
cmpl   $0xa,-0x2024(%rbp)
jne    11e0 <parse_wkt+0xb0>
mov    -0x2020(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x2010(%rbp),%rdi
call   1030 <fetch_srid@plt>
mov    %eax,-0x2014(%rbp)
cmpl   $0x0,-0x2014(%rbp)
jl     11cd <parse_wkt+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x2014(%rbp),%esi
lea    -0x2010(%rbp),%rdx
call   1050 <add_wkt@plt>
lea    -0x2010(%rbp),%rax
mov    %rax,-0x2020(%rbp)
jmp    1151 <parse_wkt+0x21>
mov    -0x2024(%rbp),%eax
mov    %al,%cl
mov    -0x2020(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x2020(%rbp)
mov    %cl,(%rax)
jmp    1151 <parse_wkt+0x21>
mov    $0x1,%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_wkt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2000,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    0x2e98(%rip),%r12
mov    %r15,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <getc@plt>
cmp    (%r12),%eax
je     11af <parse_wkt+0x7f>
cmp    $0xd,%eax
je     1160 <parse_wkt+0x30>
cmp    $0xa,%eax
jne    118e <parse_wkt+0x5e>
movb   $0x0,0x0(%r13)
mov    %r15,%rdi
call   1030 <fetch_srid@plt>
mov    %r15,%r13
test   %eax,%eax
jns    11a0 <parse_wkt+0x70>
jmp    1160 <parse_wkt+0x30>
mov    %al,0x0(%r13)
add    $0x1,%r13
jmp    1160 <parse_wkt+0x30>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15,%rdx
call   1050 <add_wkt@plt>
jmp    1150 <parse_wkt+0x20>
mov    $0x1,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.epsg_dict = type { i32 }
@EOF = global i32 0
define i32 @parse_wkt(i32* %0, %struct.epsg_dict* %1) {
%3 = alloca i32*
%4 = alloca %struct.epsg_dict*
%5 = alloca [8192 x i8]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %3
store %struct.epsg_dict* %1, %struct.epsg_dict** %4
%9 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
store i8* %9, i8** %7
br label %10
10: ; preds = %35, %33, %18, %2
%11 = load i32*, i32** %3
%12 = call i32 @getc(i32* %11)
store i32 %12, i32* %8
%13 = load i32, i32* @EOF
%14 = icmp ne i32 %12, %13
br i1 %14, label %15, label %40
15: ; preds = %10
%16 = load i32, i32* %8
%17 = icmp eq i32 %16, 13
br i1 %17, label %18, label %19
18: ; preds = %15
br label %10
19: ; preds = %15
%20 = load i32, i32* %8
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i8*, i8** %7
store i8 0, i8* %23
%24 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%25 = call i32 @fetch_srid(i8* %24)
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = icmp sge i32 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %22
%29 = load %struct.epsg_dict*, %struct.epsg_dict** %4
%30 = load i32, i32* %6
%31 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%32 = call i32 @add_wkt(%struct.epsg_dict* %29, i32 %30, i8* %31)
br label %33
33: ; preds = %28, %22
%34 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
store i8* %34, i8** %7
br label %10
35: ; preds = %19
%36 = load i32, i32* %8
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %7
store i8 %37, i8* %38
br label %10
40: ; preds = %10
ret i32 1
}

LLVM IR (-O2):
%struct.epsg_dict = type { i32 }
@EOF = global i32 0
define i32 @parse_wkt(i32* nocapture %0, %struct.epsg_dict* %1) {
%3 = alloca [8192 x i8]
%4 = getelementptr inbounds [8192 x i8], [8192 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %15, %2
%6 = phi i8* [ %4, %2 ], [ %16, %15 ]
br label %7
7: ; preds = %5, %11
%8 = call i32 @getc(i32* %0)
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %22, label %11
11: ; preds = %7
switch i32 %8, label %19 [
i32 13, label %7
i32 10, label %12
]
12: ; preds = %11
store i8 0, i8* %6
%13 = call i32 @fetch_srid(i8* %4)
%14 = icmp sgt i32 %13, -1
br i1 %14, label %17, label %15
15: ; preds = %12, %17, %19
%16 = phi i8* [ %21, %19 ], [ %4, %17 ], [ %4, %12 ]
br label %5
17: ; preds = %12
%18 = call i32 @add_wkt(%struct.epsg_dict* %1, i32 %13, i8* %4)
br label %15
19: ; preds = %11
%20 = trunc i32 %8 to i8
%21 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %20, i8* %6
br label %15
22: ; preds = %7
ret i32 1
}