#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*/ CloseFile(int /*<<< orphan*/ **);
scalar_t__ GetALine(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *OpenFile(char *, char *);
int /*<<< orphan*/ removeAFile(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *strdup(char *);
int /*<<< orphan*/ wgrib22(char **, char *);
char *getCoordsString(char *inputFileName, char *site, double longitude,
                      double latitude) {
  int success = 0;
  char *grib_cargv[9], temp[4096], temp2[4096];
  grib_cargv[0] = "wgrib2";
  grib_cargv[1] = strdup(inputFileName);
  grib_cargv[2] = "-colon";
  grib_cargv[3] = ",";
  grib_cargv[4] = "-lon";
  sprintf(temp, "%5.6f", longitude);
  grib_cargv[5] = strdup(temp);
  sprintf(temp, "%5.6f", latitude);
  grib_cargv[6] = strdup(temp);
  grib_cargv[7] = "-end";
  grib_cargv[8] = NULL;
  sprintf(temp2, "%s.txt", site);
  wgrib22(grib_cargv, strdup(temp2));
  FILE *dailyCoordsFile = OpenFile(temp2, "r");
  if (GetALine(dailyCoordsFile, temp))
    success = 1;
  CloseFile(&dailyCoordsFile);
  removeAFile(temp2);
  if (success == 1)
    return strdup(temp);
  return NULL;
}


x86 assembly (clang, -O0):
<getCoordsString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2090,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x78(%rbp)
lea    0xe54(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe50(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe47(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    -0x1080(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe35(%rip),%rsi
mov    $0x1,%al
call   1080 <sprintf@plt>
lea    -0x1080(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x58(%rbp)
lea    -0x1080(%rbp),%rdi
movsd  -0x28(%rbp),%xmm0
lea    0xe0b(%rip),%rsi
mov    $0x1,%al
call   1080 <sprintf@plt>
lea    -0x1080(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x50(%rbp)
lea    0xdf3(%rip),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
lea    -0x2080(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x2090(%rbp)
lea    -0x2080(%rbp),%rdi
call   1090 <strdup@plt>
mov    -0x2090(%rbp),%rdi
mov    %rax,%rsi
call   1050 <wgrib22@plt>
lea    -0x2080(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1040 <OpenFile@plt>
mov    %rax,-0x2088(%rbp)
mov    -0x2088(%rbp),%rdi
lea    -0x1080(%rbp),%rsi
call   1070 <GetALine@plt>
cmp    $0x0,%rax
je     12b1 <getCoordsString+0x141>
movl   $0x1,-0x2c(%rbp)
lea    -0x2088(%rbp),%rdi
call   1030 <CloseFile@plt>
lea    -0x2080(%rbp),%rdi
call   1060 <removeAFile@plt>
cmpl   $0x1,-0x2c(%rbp)
jne    12e8 <getCoordsString+0x178>
lea    -0x1080(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    12f0 <getCoordsString+0x180>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x2090,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCoordsString>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2070,%rsp
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rsi,%r14
lea    0xe6a(%rip),%rax
mov    %rax,0x20(%rsp)
call   1090 <strdup@plt>
mov    %rax,0x28(%rsp)
lea    0xe5b(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xe56(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe4c(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0xe45(%rip),%rbx
lea    0x70(%rsp),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1080 <sprintf@plt>
mov    %r12,%rdi
call   1090 <strdup@plt>
mov    %rax,0x48(%rsp)
mov    %r12,%rdi
mov    %rbx,%rsi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1080 <sprintf@plt>
mov    %r12,%rdi
call   1090 <strdup@plt>
mov    %rax,0x50(%rsp)
lea    0xdff(%rip),%rax
mov    %rax,0x58(%rsp)
movq   $0x0,0x60(%rsp)
lea    0xdef(%rip),%rsi
xor    %r15d,%r15d
lea    0x1070(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %r13,%rdi
call   1090 <strdup@plt>
lea    0x20(%rsp),%rdi
mov    %rax,%rsi
call   1050 <wgrib22@plt>
lea    0xdc2(%rip),%rsi
mov    %r13,%rdi
call   1040 <OpenFile@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
mov    %r12,%rsi
call   1070 <GetALine@plt>
mov    %rax,%rbx
lea    0x18(%rsp),%rdi
call   1030 <CloseFile@plt>
mov    %r13,%rdi
call   1060 <removeAFile@plt>
test   %rbx,%rbx
je     12a4 <getCoordsString+0x134>
lea    0x70(%rsp),%rdi
call   1090 <strdup@plt>
mov    %rax,%r15
mov    %r15,%rax
add    $0x2070,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"wgrib2\00"
@.str.1 = [7 x i8] c"-colon\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c"-lon\00"
@.str.4 = [6 x i8] c"%5.6f\00"
@.str.5 = [5 x i8] c"-end\00"
@.str.6 = [7 x i8] c"%s.txt\00"
@.str.7 = [2 x i8] c"r\00"
define i8* @getCoordsString(i8* %0, i8* %1, double %2, double %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca double
%9 = alloca double
%10 = alloca i32
%11 = alloca [9 x i8*]
%12 = alloca [4096 x i8]
%13 = alloca [4096 x i8]
%14 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store double %2, double* %8
store double %3, double* %9
store i32 0, i32* %10
%15 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %15
%16 = load i8*, i8** %6
%17 = call i8* @strdup(i8* %16)
%18 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 1
store i8* %17, i8** %18
%19 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %19
%20 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%23 = load double, double* %8
%24 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %23)
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%26 = call i8* @strdup(i8* %25)
%27 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 5
store i8* %26, i8** %27
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%29 = load double, double* %9
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %29)
%31 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%32 = call i8* @strdup(i8* %31)
%33 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 6
store i8* %32, i8** %33
%34 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 8
store i8* null, i8** %35
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%37 = load i8*, i8** %7
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [9 x i8*], [9 x i8*]* %11, i64 0, i64 0
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%41 = call i8* @strdup(i8* %40)
%42 = call i32 @wgrib22(i8** %39, i8* %41)
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%44 = call i32* @OpenFile(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %44, i32** %14
%45 = load i32*, i32** %14
%46 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%47 = call i64 @GetALine(i32* %45, i8* %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %4
store i32 1, i32* %10
br label %50
50: ; preds = %49, %4
%51 = call i32 @CloseFile(i32** %14)
%52 = getelementptr inbounds [4096 x i8], [4096 x i8]* %13, i64 0, i64 0
%53 = call i32 @removeAFile(i8* %52)
%54 = load i32, i32* %10
%55 = icmp eq i32 %54, 1
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%58 = call i8* @strdup(i8* %57)
store i8* %58, i8** %5
br label %60
59: ; preds = %50
store i8* null, i8** %5
br label %60
60: ; preds = %59, %56
%61 = load i8*, i8** %5
ret i8* %61
}

LLVM IR (-O2):
@.str = [7 x i8] c"wgrib2\00"
@.str.1 = [7 x i8] c"-colon\00"
@.str.2 = [2 x i8] c",\00"
@.str.3 = [5 x i8] c"-lon\00"
@.str.4 = [6 x i8] c"%5.6f\00"
@.str.5 = [5 x i8] c"-end\00"
@.str.6 = [7 x i8] c"%s.txt\00"
@.str.7 = [2 x i8] c"r\00"
define noalias i8* @getCoordsString(i8* nocapture %0, i8* %1, double %2, double %3) {
%5 = alloca [9 x i8*]
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i32*
%9 = bitcast [9 x i8*]* %5 to i8*
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %12
%13 = tail call i8* @strdup(i8* %0)
%14 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 1
store i8* %13, i8** %14
%15 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %17
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %2)
%19 = call i8* @strdup(i8* %10)
%20 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 5
store i8* %19, i8** %20
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %3)
%22 = call i8* @strdup(i8* %10)
%23 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 6
store i8* %22, i8** %23
%24 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 7
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %24
%25 = getelementptr inbounds [9 x i8*], [9 x i8*]* %5, i64 0, i64 8
store i8* null, i8** %25
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %1)
%27 = call i8* @strdup(i8* %11)
%28 = call i32 @wgrib22(i8** %12, i8* %27)
%29 = bitcast i32** %8 to i8*
%30 = call i32* @OpenFile(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %30, i32** %8
%31 = call i64 @GetALine(i32* %30, i8* %10)
%32 = icmp eq i64 %31, 0
%33 = call i32 @CloseFile(i32** %8)
%34 = call i32 @removeAFile(i8* %11)
br i1 %32, label %37, label %35
35: ; preds = %4
%36 = call i8* @strdup(i8* %10)
br label %37
37: ; preds = %4, %35
%38 = phi i8* [ %36, %35 ], [ null, %4 ]
ret i8* %38
}