#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*/ min_z;
typedef int /*<<< orphan*/ min_y;
typedef int /*<<< orphan*/ min_x;
typedef int /*<<< orphan*/ min_m;
typedef int /*<<< orphan*/ max_z;
typedef int /*<<< orphan*/ max_y;
typedef int /*<<< orphan*/ max_x;
typedef int /*<<< orphan*/ max_m;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
char *get_geometry(int);
char *malloc(int);
int /*<<< orphan*/ memcpy(double *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main(void) {
  int len = 1000;
  char filepath[len];
  int headerlen = 100;
  char *header = malloc(headerlen);
  printf("Enter full filepath to shapefile (e.g. "
         "/users/jesus/desktop/test.shp): \n");
  fgets(filepath, len, stdin);
  len = strlen(filepath);
  filepath[len - 1] = '\0';
  if (filepath[len - 4] != 's' || filepath[len - 3] != 'h' ||
      filepath[len - 2] != 'p') {
    printf("Invalid filename extension - File is not a shapefile. Exiting.\n");
    free(header);
    exit(0);
  }
  FILE *f = fopen(filepath, "r");
  if (!f) {
    printf("\nFile read error. Exiting.\n");
    free(header);
    exit(0);
  } else {
    printf("\nFile read successful.\n\n");
  }
  for (int i = 0; i < headerlen; i++) {
    header[i] = fgetc(f);
  }
  int filecode = (((header[0] & 0xff) << 24) | ((header[1] & 0xff) << 16) |
                  ((header[2] & 0xff) << 8) | ((header[3] & 0xff)));
  int file_len = (((header[24] & 0xff) << 24) | ((header[25] & 0xff) << 16) |
                  ((header[26] & 0xff) << 8) | ((header[27] & 0xff)));
  file_len *= 2;
  int version = (((header[31] & 0xff) << 24) | ((header[30] & 0xff) << 16) |
                 ((header[29] & 0xff) << 8) | ((header[28] & 0xff)));
  int geometry_type =
      (((header[35] & 0xff) << 24) | ((header[34] & 0xff) << 16) |
       ((header[33] & 0xff) << 8) | ((header[32] & 0xff)));
  double min_x, min_y, max_x, max_y;
  memcpy(&min_x, &header[36], sizeof(min_x));
  memcpy(&min_y, &header[44], sizeof(min_y));
  memcpy(&max_x, &header[52], sizeof(max_x));
  memcpy(&max_y, &header[60], sizeof(max_y));
  double min_z, max_z;
  memcpy(&min_z, &header[68], sizeof(min_z));
  memcpy(&max_z, &header[76], sizeof(max_z));
  double min_m, max_m;
  memcpy(&min_m, &header[84], sizeof(min_m));
  memcpy(&max_m, &header[92], sizeof(max_m));
  if (filecode != 9994) {
    printf("Incorrect filecode - File is not a shapefile. Exiting.\n");
    free(header);
    fclose(f);
    exit(0);
  } else {
    printf("Filecode: \t%d - Shapefile filetype verified.\n", filecode);
  }
  printf("File length: \t%d bytes\n", file_len);
  printf("Version: \t%d\n", version);
  printf("Geometry: \t%s", get_geometry(geometry_type));
  printf("\nBounding box: \t(%f, %f) - (%f, %f)\n", min_x, min_y, max_x, max_y);
  printf("Z range: \t%f - %f\n", min_z, max_z);
  printf("M range: \t%f - %f\n\n", min_m, max_m);
  free(header);
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3e8,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x64,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x90(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    0x2dc4(%rip),%rax
mov    (%rax),%edx
call   1080 <fgets@plt>
mov    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
mov    %ecx,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%ecx
sub    $0x4,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x73,%eax
jne    12a0 <main+0xf0>
mov    -0x90(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x3,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x68,%eax
jne    12a0 <main+0xf0>
mov    -0x90(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
je     12be <main+0x10e>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x90(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    12fe <main+0x14e>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1343 <main+0x193>
mov    -0x30(%rbp),%rdi
call   1070 <fgetc@plt>
mov    %al,%dl
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1313 <main+0x163>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x3(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
movsbl 0x18(%rax),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x19(%rcx),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1a(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1b(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rax
movsbl 0x1f(%rax),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1e(%rcx),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1d(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x1c(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
movsbl 0x23(%rax),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x22(%rcx),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x21(%rcx),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
movsbl 0x20(%rcx),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rsi
add    $0x24,%rsi
lea    -0x50(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x2c,%rsi
lea    -0x58(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x34,%rsi
lea    -0x60(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x3c,%rsi
lea    -0x68(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x44,%rsi
lea    -0x70(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x4c,%rsi
lea    -0x78(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x54,%rsi
lea    -0x80(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
mov    -0x28(%rbp),%rsi
add    $0x5c,%rsi
lea    -0x88(%rbp),%rdi
mov    $0x8,%edx
call   1090 <memcpy@plt>
cmpl   $0x270a,-0x38(%rbp)
je     1556 <main+0x3a6>
lea    0xb8a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x38(%rbp),%esi
lea    0xb98(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x44(%rbp),%edi
call   10b0 <get_geometry@plt>
mov    %rax,%rsi
lea    0xbb1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm3
lea    0xb9d(%rip),%rdi
mov    $0x4,%al
call   1060 <printf@plt>
movsd  -0x70(%rbp),%xmm0
movsd  -0x78(%rbp),%xmm1
lea    0xbaa(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
movsd  -0x80(%rbp),%xmm0
movsd  -0x88(%rbp),%xmm1
ff
lea    0xba2(%rip),%rdi
mov    $0x2,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x458,%rsp
mov    $0x64,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
lea    0x70(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x3e8,%esi
call   1090 <fgets@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
cmpb   $0x73,-0x4(%rax,%rbp,1)
jne    1498 <main+0x2d8>
cmpb   $0x68,-0x3(%rax,%rbp,1)
jne    1498 <main+0x2d8>
cmpb   $0x70,-0x2(%rax,%rbp,1)
jne    1498 <main+0x2d8>
lea    0xdc4(%rip),%rsi
lea    0x70(%rsp),%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     14a1 <main+0x2e1>
mov    %rax,%r14
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1080 <fgetc@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    $0x64,%rbp
jne    1260 <main+0xa0>
mov    (%rbx),%eax
bswap  %eax
mov    %eax,0x2c(%rsp)
movzbl 0x18(%rbx),%eax
mov    %eax,0x20(%rsp)
movzbl 0x19(%rbx),%eax
mov    %eax,0x24(%rsp)
movzbl 0x1a(%rbx),%ebp
movzbl 0x1b(%rbx),%eax
mov    %eax,0x28(%rsp)
movzbl 0x1f(%rbx),%eax
mov    %eax,0x14(%rsp)
movzbl 0x1e(%rbx),%eax
mov    %eax,0x18(%rsp)
movzbl 0x1d(%rbx),%r12d
movzbl 0x1c(%rbx),%eax
mov    %eax,0x1c(%rsp)
movzbl 0x23(%rbx),%eax
mov    %eax,0xc(%rsp)
movzbl 0x22(%rbx),%r13d
movzbl 0x21(%rbx),%r15d
movzbl 0x20(%rbx),%eax
mov    %eax,0x10(%rsp)
lea    0x24(%rbx),%rsi
lea    0x68(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x2c(%rbx),%rsi
lea    0x60(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x34(%rbx),%rsi
lea    0x58(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x3c(%rbx),%rsi
lea    0x50(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x44(%rbx),%rsi
lea    0x48(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x4c(%rbx),%rsi
lea    0x40(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
lea    0x54(%rbx),%rsi
lea    0x38(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
mov    %rbx,%rsi
add    $0x5c,%rsi
lea    0x30(%rsp),%rdi
mov    $0x8,%edx
call   10a0 <memcpy@plt>
cmpl   $0x270a,0x2c(%rsp)
jne    14bc <main+0x2fc>
mov    0xc(%rsp),%eax
shl    $0x18,%eax
shl    $0x10,%r13d
or     %eax,%r13d
shl    $0x8,%r15d
or     %r13d,%r15d
add    0x10(%rsp),%r15d
mov    0x14(%rsp),%ecx
shl    $0x18,%ecx
mov    0x18(%rsp),%eax
shl    $0x10,%eax
or     %ecx,%eax
shl    $0x8,%r12d
or     %eax,%r12d
add    0x1c(%rsp),%r12d
mov    0x20(%rsp),%ecx
shl    $0x18,%ecx
mov    0x24(%rsp),%eax
shl    $0x10,%eax
or     %ecx,%eax
shl    $0x8,%ebp
or     %eax,%ebp
add    0x28(%rsp),%ebp
add    %ebp,%ebp
lea    0xc31(%rip),%rdi
mov    $0x270a,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc4c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xc54(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15d,%edi
call   10c0 <get_geometry@plt>
lea    0xc49(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
movsd  0x68(%rsp),%xmm0
movsd  0x60(%rsp),%xmm1
movsd  0x58(%rsp),%xmm2
movsd  0x50(%rsp),%xmm3
lea    0xc2e(%rip),%rdi
mov    $0x4,%al
call   1070 <printf@plt>
movsd  0x48(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
lea    0xc39(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movsd  0x38(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
lea    0xc32(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    $0x1,%eax
add    $0x458,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc3(%rip),%rdi
jmp    14a8 <main+0x2e8>
lea    0xc50(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xc68(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [73 x i8] c"Enter full filepath to shapefile (e.g. /users/jesus/desktop/test.shp): \0A\00"
@stdin = global i32 0
@.str.1 = [64 x i8] c"Invalid filename extension - File is not a shapefile. Exiting.\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [28 x i8] c"\0AFile read error. Exiting.\0A\00"
@.str.4 = [25 x i8] c"\0AFile read successful.\0A\0A\00"
@.str.5 = [56 x i8] c"Incorrect filecode - File is not a shapefile. Exiting.\0A\00"
@.str.6 = [46 x i8] c"Filecode: \09%d - Shapefile filetype verified.\0A\00"
@.str.7 = [24 x i8] c"File length: \09%d bytes\0A\00"
@.str.8 = [14 x i8] c"Version: \09%d\0A\00"
@.str.9 = [14 x i8] c"Geometry: \09%s\00"
@.str.10 = [37 x i8] c"\0ABounding box: \09(%f, %f) - (%f, %f)\0A\00"
@.str.11 = [19 x i8] c"Z range: \09%f - %f\0A\00"
@.str.12 = [20 x i8] c"M range: \09%f - %f\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store i32 0, i32* %1
store i32 1000, i32* %2
%21 = load i32, i32* %2
%22 = zext i32 %21 to i64
%23 = call i8* @llvm.stacksave()
store i8* %23, i8** %3
%24 = alloca i8, i64 %22
store i64 %22, i64* %4
store i32 100, i32* %5
%25 = load i32, i32* %5
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %6
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0))
%28 = load i32, i32* %2
%29 = load i32, i32* @stdin
%30 = call i32 @fgets(i8* %24, i32 %28, i32 %29)
%31 = call i32 @strlen(i8* %24)
store i32 %31, i32* %2
%32 = load i32, i32* %2
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %24, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %2
%37 = sub nsw i32 %36, 4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %24, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 115
br i1 %42, label %59, label %43
43: ; preds = %0
%44 = load i32, i32* %2
%45 = sub nsw i32 %44, 3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %24, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 104
br i1 %50, label %59, label %51
51: ; preds = %43
%52 = load i32, i32* %2
%53 = sub nsw i32 %52, 2
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %24, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 112
br i1 %58, label %59, label %64
59: ; preds = %51, %43, %0
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0))
%61 = load i8*, i8** %6
%62 = call i32 @free(i8* %61)
%63 = call i32 @exit(i32 0)
unreachable
64: ; preds = %51
%65 = call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %65, i32** %7
%66 = load i32*, i32** %7
%67 = icmp ne i32* %66, null
br i1 %67, label %73, label %68
68: ; preds = %64
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%70 = load i8*, i8** %6
%71 = call i32 @free(i8* %70)
%72 = call i32 @exit(i32 0)
unreachable
73: ; preds = %64
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
br label %75
75: ; preds = %73
store i32 0, i32* %8
br label %76
76: ; preds = %87, %75
%77 = load i32, i32* %8
%78 = load i32, i32* %5
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %90
80: ; preds = %76
%81 = load i32*, i32** %7
%82 = call signext i8 @fgetc(i32* %81)
%83 = load i8*, i8** %6
%84 = load i32, i32* %8
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
store i8 %82, i8* %86
br label %87
87: ; preds = %80
%88 = load i32, i32* %8
%89 = add nsw i32 %88, 1
store i32 %89, i32* %8
br label %76
90: ; preds = %76
%91 = load i8*, i8** %6
%92 = getelementptr inbounds i8, i8* %91, i64 0
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = and i32 %94, 255
%96 = shl i32 %95, 24
%97 = load i8*, i8** %6
%98 = getelementptr inbounds i8, i8* %97, i64 1
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = and i32 %100, 255
%102 = shl i32 %101, 16
%103 = or i32 %96, %102
%104 = load i8*, i8** %6
%105 = getelementptr inbounds i8, i8* %104, i64 2
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = and i32 %107, 255
%109 = shl i32 %108, 8
%110 = or i32 %103, %109
%111 = load i8*, i8** %6
%112 = getelementptr inbounds i8, i8* %111, i64 3
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = and i32 %114, 255
%116 = or i32 %110, %115
store i32 %116, i32* %9
%117 = load i8*, i8** %6
%118 = getelementptr inbounds i8, i8* %117, i64 24
%119 = load i8, i8* %118
%120 = sext i8 %119 to i32
%121 = and i32 %120, 255
%122 = shl i32 %121, 24
%123 = load i8*, i8** %6
%124 = getelementptr inbounds i8, i8* %123, i64 25
%125 = load i8, i8* %124
%126 = sext i8 %125 to i32
%127 = and i32 %126, 255
%128 = shl i32 %127, 16
%129 = or i32 %122, %128
%130 = load i8*, i8** %6
%131 = getelementptr inbounds i8, i8* %130, i64 26
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = and i32 %133, 255
%135 = shl i32 %134, 8
%136 = or i32 %129, %135
%137 = load i8*, i8** %6
%138 = getelementptr inbounds i8, i8* %137, i64 27
%139 = load i8, i8* %138
%140 = sext i8 %139 to i32
%141 = and i32 %140, 255
%142 = or i32 %136, %141
store i32 %142, i32* %10
%143 = load i32, i32* %10
%144 = mul nsw i32 %143, 2
store i32 %144, i32* %10
%145 = load i8*, i8** %6
%146 = getelementptr inbounds i8, i8* %145, i64 31
%147 = load i8, i8* %146
%148 = sext i8 %147 to i32
%149 = and i32 %148, 255
%150 = shl i32 %149, 24
%151 = load i8*, i8** %6
%152 = getelementptr inbounds i8, i8* %151, i64 30
%153 = load i8, i8* %152
%154 = sext i8 %153 to i32
%155 = and i32 %154, 255
%156 = shl i32 %155, 16
%157 = or i32 %150, %156
%158 = load i8*, i8** %6
%159 = getelementptr inbounds i8, i8* %158, i64 29
%160 = load i8, i8* %159
%161 = sext i8 %160 to i32
%162 = and i32 %161, 255
%163 = shl i32 %162, 8
%164 = or i32 %157, %163
%165 = load i8*, i8** %6
%166 = getelementptr inbounds i8, i8* %165, i64 28
%167 = load i8, i8* %166
%168 = sext i8 %167 to i32
%169 = and i32 %168, 255
%170 = or i32 %164, %169
store i32 %170, i32* %11
%171 = load i8*, i8** %6
%172 = getelementptr inbounds i8, i8* %171, i64 35
%173 = load i8, i8* %172
%174 = sext i8 %173 to i32
%175 = and i32 %174, 255
%176 = shl i32 %175, 24
%177 = load i8*, i8** %6
%178 = getelementptr inbounds i8, i8* %177, i64 34
%179 = load i8, i8* %178
%180 = sext i8 %179 to i32
%181 = and i32 %180, 255
%182 = shl i32 %181, 16
%183 = or i32 %176, %182
%184 = load i8*, i8** %6
%185 = getelementptr inbounds i8, i8* %184, i64 33
%186 = load i8, i8* %185
%187 = sext i8 %186 to i32
%188 = and i32 %187, 255
%189 = shl i32 %188, 8
%190 = or i32 %183, %189
%191 = load i8*, i8** %6
%192 = getelementptr inbounds i8, i8* %191, i64 32
%193 = load i8, i8* %192
%194 = sext i8 %193 to i32
%195 = and i32 %194, 255
%196 = or i32 %190, %195
store i32 %196, i32* %12
%197 = load i8*, i8** %6
%198 = getelementptr inbounds i8, i8* %197, i64 36
%199 = call i32 @memcpy(double* %13, i8* %198, i32 8)
%200 = load i8*, i8** %6
%201 = getelementptr inbounds i8, i8* %200, i64 44
%202 = call i32 @memcpy(double* %14, i8* %201, i32 8)
%203 = load i8*, i8** %6
%204 = getelementptr inbounds i8, i8* %203, i64 52
%205 = call i32 @memcpy(double* %15, i8* %204, i32 8)
%206 = load i8*, i8** %6
%207 = getelementptr inbounds i8, i8* %206, i64 60
%208 = call i32 @memcpy(double* %16, i8* %207, i32 8)
%209 = load i8*, i8** %6
%210 = getelementptr inbounds i8, i8* %209, i64 68
%211 = call i32 @memcpy(double* %17, i8* %210, i32 8)
%212 = load i8*, i8** %6
%213 = getelementptr inbounds i8, i8* %212, i64 76
%214 = call i32 @memcpy(double* %18, i8* %213, i32 8)
%215 = load i8*, i8** %6
%216 = getelementptr inbounds i8, i8* %215, i64 84
%217 = call i32 @memcpy(double* %19, i8* %216, i32 8)
%218 = load i8*, i8** %6
%219 = getelementptr inbounds i8, i8* %218, i64 92
%220 = call i32 @memcpy(double* %20, i8* %219, i32 8)
%221 = load i32, i32* %9
%222 = icmp ne i32 %221, 9994
br i1 %222, label %223, label %230
223: ; preds = %90
%224 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.5, i64 0, i64 0))
%225 = load i8*, i8** %6
%226 = call i32 @free(i8* %225)
%227 = load i32*, i32** %7
%228 = call i32 @fclose(i32* %227)
%229 = call i32 @exit(i32 0)
unreachable
230: ; preds = %90
%231 = load i32, i32* %9
%232 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 %231)
br label %233
233: ; preds = %230
%234 = load i32, i32* %10
%235 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %234)
%236 = load i32, i32* %11
%237 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %236)
%238 = load i32, i32* %12
%239 = call i8* @get_geometry(i32 %238)
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %239)
%241 = load double, double* %13
%242 = load double, double* %14
%243 = load double, double* %15
%244 = load double, double* %16
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), double %241, double %242, double %243, double %244)
%246 = load double, double* %17
%247 = load double, double* %18
%248 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), double %246, double %247)
%249 = load double, double* %19
%250 = load double, double* %20
%251 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), double %249, double %250)
%252 = load i8*, i8** %6
%253 = call i32 @free(i8* %252)
%254 = load i32*, i32** %7
%255 = call i32 @fclose(i32* %254)
store i32 1, i32* %1
%256 = load i8*, i8** %3
%257 = load i32, i32* %1
ret i32 %257
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.2 = [2 x i8] c"r\00"
@.str.6 = [46 x i8] c"Filecode: \09%d - Shapefile filetype verified.\0A\00"
@.str.7 = [24 x i8] c"File length: \09%d bytes\0A\00"
@.str.8 = [14 x i8] c"Version: \09%d\0A\00"
@.str.9 = [14 x i8] c"Geometry: \09%s\00"
@.str.10 = [37 x i8] c"\0ABounding box: \09(%f, %f) - (%f, %f)\0A\00"
@.str.11 = [19 x i8] c"Z range: \09%f - %f\0A\00"
@.str.12 = [20 x i8] c"M range: \09%f - %f\0A\0A\00"
@str = [72 x i8] c"Enter full filepath to shapefile (e.g. /users/jesus/desktop/test.shp): \00"
@str.13 = [27 x i8] c"\0AFile read error. Exiting.\00"
@str.14 = [24 x i8] c"\0AFile read successful.\0A\00"
@str.15 = [55 x i8] c"Incorrect filecode - File is not a shapefile. Exiting.\00"
@str.16 = [63 x i8] c"Invalid filename extension - File is not a shapefile. Exiting.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca [1000 x i8]
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 0
%11 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
%13 = load i32, i32* @stdin
%14 = call i32 @fgets(i8* %10, i32 1000, i32 %13)
%15 = call i32 @strlen(i8* %10)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %17
store i8 0, i8* %18
%19 = add nsw i32 %15, -4
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 115
br i1 %23, label %24, label %36
24: ; preds = %0
%25 = add nsw i32 %15, -3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 104
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = add nsw i32 %15, -2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %9, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = icmp eq i8 %34, 112
br i1 %35, label %40, label %36
36: ; preds = %30, %24, %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str.16, i64 0, i64 0))
%38 = call i32 @free(i8* %11)
%39 = call i32 @exit(i32 0)
unreachable
40: ; preds = %30
%41 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
%45 = call i32 @free(i8* %11)
%46 = call i32 @exit(i32 0)
unreachable
47: ; preds = %40
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.14, i64 0, i64 0))
br label %116
49: ; preds = %116
%50 = load i8, i8* %11
%51 = zext i8 %50 to i32
%52 = shl nuw i32 %51, 24
%53 = getelementptr inbounds i8, i8* %11, i64 1
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = shl nuw nsw i32 %55, 16
%57 = or i32 %56, %52
%58 = getelementptr inbounds i8, i8* %11, i64 2
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = shl nuw nsw i32 %60, 8
%62 = or i32 %57, %61
%63 = getelementptr inbounds i8, i8* %11, i64 3
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = or i32 %62, %65
%67 = getelementptr inbounds i8, i8* %11, i64 24
%68 = load i8, i8* %67
%69 = getelementptr inbounds i8, i8* %11, i64 25
%70 = load i8, i8* %69
%71 = getelementptr inbounds i8, i8* %11, i64 26
%72 = load i8, i8* %71
%73 = getelementptr inbounds i8, i8* %11, i64 27
%74 = load i8, i8* %73
%75 = getelementptr inbounds i8, i8* %11, i64 31
%76 = load i8, i8* %75
%77 = getelementptr inbounds i8, i8* %11, i64 30
%78 = load i8, i8* %77
%79 = getelementptr inbounds i8, i8* %11, i64 29
%80 = load i8, i8* %79
%81 = getelementptr inbounds i8, i8* %11, i64 28
%82 = load i8, i8* %81
%83 = getelementptr inbounds i8, i8* %11, i64 35
%84 = load i8, i8* %83
%85 = getelementptr inbounds i8, i8* %11, i64 34
%86 = load i8, i8* %85
%87 = getelementptr inbounds i8, i8* %11, i64 33
%88 = load i8, i8* %87
%89 = getelementptr inbounds i8, i8* %11, i64 32
%90 = load i8, i8* %89
%91 = bitcast double* %1 to i8*
%92 = bitcast double* %2 to i8*
%93 = bitcast double* %3 to i8*
%94 = bitcast double* %4 to i8*
%95 = getelementptr inbounds i8, i8* %11, i64 36
%96 = call i32 @memcpy(double* %1, i8* %95, i32 8)
%97 = getelementptr inbounds i8, i8* %11, i64 44
%98 = call i32 @memcpy(double* %2, i8* %97, i32 8)
%99 = getelementptr inbounds i8, i8* %11, i64 52
%100 = call i32 @memcpy(double* %3, i8* %99, i32 8)
%101 = getelementptr inbounds i8, i8* %11, i64 60
%102 = call i32 @memcpy(double* %4, i8* %101, i32 8)
%103 = bitcast double* %5 to i8*
%104 = bitcast double* %6 to i8*
%105 = getelementptr inbounds i8, i8* %11, i64 68
%106 = call i32 @memcpy(double* %5, i8* %105, i32 8)
%107 = getelementptr inbounds i8, i8* %11, i64 76
%108 = call i32 @memcpy(double* %6, i8* %107, i32 8)
%109 = bitcast double* %7 to i8*
%110 = bitcast double* %8 to i8*
%111 = getelementptr inbounds i8, i8* %11, i64 84
%112 = call i32 @memcpy(double* %7, i8* %111, i32 8)
%113 = getelementptr inbounds i8, i8* %11, i64 92
%114 = call i32 @memcpy(double* %8, i8* %113, i32 8)
%115 = icmp eq i32 %66, 9994
br i1 %115, label %127, label %122
116: ; preds = %47, %116
%117 = phi i64 [ 0, %47 ], [ %120, %116 ]
%118 = call signext i8 @fgetc(i32* %41)
%119 = getelementptr inbounds i8, i8* %11, i64 %117
store i8 %118, i8* %119
%120 = add nuw nsw i64 %117, 1
%121 = icmp eq i64 %120, 100
br i1 %121, label %49, label %116
122: ; preds = %49
%123 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.15, i64 0, i64 0))
%124 = call i32 @free(i8* %11)
%125 = call i32 @fclose(i32* %41)
%126 = call i32 @exit(i32 0)
unreachable
127: ; preds = %49
%128 = zext i8 %84 to i32
%129 = shl nuw i32 %128, 24
%130 = zext i8 %86 to i32
%131 = shl nuw nsw i32 %130, 16
%132 = or i32 %131, %129
%133 = zext i8 %88 to i32
%134 = shl nuw nsw i32 %133, 8
%135 = or i32 %132, %134
%136 = zext i8 %90 to i32
%137 = or i32 %135, %136
%138 = zext i8 %76 to i32
%139 = shl nuw i32 %138, 24
%140 = zext i8 %78 to i32
%141 = shl nuw nsw i32 %140, 16
%142 = or i32 %141, %139
%143 = zext i8 %80 to i32
%144 = shl nuw nsw i32 %143, 8
%145 = or i32 %142, %144
%146 = zext i8 %82 to i32
%147 = or i32 %145, %146
%148 = zext i8 %68 to i32
%149 = shl nuw i32 %148, 24
%150 = zext i8 %70 to i32
%151 = shl nuw nsw i32 %150, 16
%152 = or i32 %151, %149
%153 = zext i8 %72 to i32
%154 = shl nuw nsw i32 %153, 8
%155 = or i32 %152, %154
%156 = zext i8 %74 to i32
%157 = or i32 %155, %156
%158 = shl nsw i32 %157, 1
%159 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 9994)
%160 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 %158)
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 %147)
%162 = call i8* @get_geometry(i32 %137)
%163 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %162)
%164 = load double, double* %1
%165 = load double, double* %2
%166 = load double, double* %3
%167 = load double, double* %4
%168 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.10, i64 0, i64 0), double %164, double %165, double %166, double %167)
%169 = load double, double* %5
%170 = load double, double* %6
%171 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.11, i64 0, i64 0), double %169, double %170)
%172 = load double, double* %7
%173 = load double, double* %8
%174 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.12, i64 0, i64 0), double %172, double %173)
%175 = call i32 @free(i8* %11)
%176 = call i32 @fclose(i32* %41)
ret i32 1
}