#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 */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fileAllocNewExten(char const *, char *, char **);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *,
                           char const *, char const *, double, double);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ myWarn_Loc(int, char *, int, char *, char *);
int shpCreatePrj(const char *Filename, const char *gcs, const char *datum,
                 const char *spheroid, double A, double B) {
  char *filename;
  FILE *fp;
  double invFlat;
  if (fileAllocNewExten(Filename, ".prj", &filename) != 0) {
    return -1;
  }
  if ((fp = fopen(filename, "wb")) == NULL) {
    myWarn_Loc(3,
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/brianmckenna/rex2nc/refs/"
               "heads/master/src/libaat/shpfile.c",
               189, "Problems opening %s for write.\n", filename);
    free(filename);
    return -2;
  }
  invFlat = A / (A - B);
  fprintf(fp,
          "GEOGCS[\"%s\",DATUM[\"%s\",SPHEROID[\"%s\",%.1f,%.13f]],"
          "PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]",
          gcs, datum, spheroid, A, invFlat);
  fclose(fp);
  free(filename);
  return 0;
}


x86 assembly (clang, -O0):
<shpCreatePrj>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
lea    -0x40(%rbp),%rdx
call   1040 <fileAllocNewExten@plt>
cmp    $0x0,%rax
je     11ac <shpCreatePrj+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1257 <shpCreatePrj+0xf7>
mov    -0x40(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1200 <shpCreatePrj+0xa0>
mov    -0x40(%rbp),%r8
mov    $0x3,%edi
lea    0xe2e(%rip),%rsi
mov    $0xbd,%edx
lea    0xeb7(%rip),%rcx
call   1080 <myWarn_Loc@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1257 <shpCreatePrj+0xf7>
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
movsd  -0x30(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    0xe84(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shpCreatePrj>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
lea    0xe79(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fileAllocNewExten@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
jne    1220 <shpCreatePrj+0xc0>
mov    (%rsp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f1 <shpCreatePrj+0x91>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm2
subsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
divsd  %xmm2,%xmm1
lea    0xee9(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %ebx,%ebx
jmp    1217 <shpCreatePrj+0xb7>
mov    (%rsp),%r8
lea    0xe0c(%rip),%rsi
lea    0xe9a(%rip),%rcx
mov    $0x3,%edi
mov    $0xbd,%edx
call   1080 <myWarn_Loc@plt>
mov    $0xfffffffe,%ebx
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c".prj\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/brianmckenna/rex2nc/refs/heads/master/src/libaat/shpfile.c\00"
@.str.3 = [32 x i8] c"Problems opening %s for write.\0A\00"
@.str.4 = [109 x i8] c"GEOGCS[\22%s\22,DATUM[\22%s\22,SPHEROID[\22%s\22,%.1f,%.13f]],PRIMEM[\22Greenwich\22,0.0],UNIT[\22Degree\22,0.0174532925199433]]\00"
define i32 @shpCreatePrj(i8* %0, i8* %1, i8* %2, i8* %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca double
%13 = alloca double
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca double
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store double %4, double* %12
store double %5, double* %13
%17 = load i8*, i8** %8
%18 = call i64 @fileAllocNewExten(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %14)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %6
store i32 -1, i32* %7
br label %47
21: ; preds = %6
%22 = load i8*, i8** %14
%23 = call i32* @fopen(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %23, i32** %15
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load i8*, i8** %14
%27 = call i32 @myWarn_Loc(i32 3, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 189, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = load i8*, i8** %14
%29 = call i32 @free(i8* %28)
store i32 -2, i32* %7
br label %47
30: ; preds = %21
%31 = load double, double* %12
%32 = load double, double* %12
%33 = load double, double* %13
%34 = fsub double %32, %33
%35 = fdiv double %31, %34
store double %35, double* %16
%36 = load i32*, i32** %15
%37 = load i8*, i8** %9
%38 = load i8*, i8** %10
%39 = load i8*, i8** %11
%40 = load double, double* %12
%41 = load double, double* %16
%42 = call i32 @fprintf(i32* %36, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.4, i64 0, i64 0), i8* %37, i8* %38, i8* %39, double %40, double %41)
%43 = load i32*, i32** %15
%44 = call i32 @fclose(i32* %43)
%45 = load i8*, i8** %14
%46 = call i32 @free(i8* %45)
store i32 0, i32* %7
br label %47
47: ; preds = %30, %25, %20
%48 = load i32, i32* %7
ret i32 %48
}

LLVM IR (-O2):
@.str = [5 x i8] c".prj\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [149 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/brianmckenna/rex2nc/refs/heads/master/src/libaat/shpfile.c\00"
@.str.3 = [32 x i8] c"Problems opening %s for write.\0A\00"
@.str.4 = [109 x i8] c"GEOGCS[\22%s\22,DATUM[\22%s\22,SPHEROID[\22%s\22,%.1f,%.13f]],PRIMEM[\22Greenwich\22,0.0],UNIT[\22Degree\22,0.0174532925199433]]\00"
define i32 @shpCreatePrj(i8* %0, i8* %1, i8* %2, i8* %3, double %4, double %5) {
%7 = alloca i8*
%8 = bitcast i8** %7 to i8*
%9 = call i64 @fileAllocNewExten(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %7)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i8*, i8** %7
%17 = call i32 @myWarn_Loc(i32 3, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str.2, i64 0, i64 0), i32 189, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %16)
br label %23
18: ; preds = %11
%19 = fsub double %4, %5
%20 = fdiv double %4, %19
%21 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %2, i8* %3, double %4, double %20)
%22 = call i32 @fclose(i32* %13)
br label %23
23: ; preds = %15, %18
%24 = phi i32 [ 0, %18 ], [ -2, %15 ]
%25 = load i8*, i8** %7
%26 = call i32 @free(i8* %25)
br label %27
27: ; preds = %23, %6
%28 = phi i32 [ -1, %6 ], [ %24, %23 ]
ret i32 %28
}