#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 */

/* Variables and functions */
char *pipe2string(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ timlib_atof_array(double *, char *);
void get_statistics_for_station_datatype(double *f_array, char *station,
                                         char *datatype, char *date_string) {
  char sys_string[1024];
  char *results;
  sprintf(sys_string,
          "echo \"select count(*), 				"
          "		sum( measurement_value ), 		"
          "		avg( measurement_value ),		"
          "		min( measurement_value ),		"
          "		max( measurement_value )		"
          "       from measurement				"
          "	 where station = '%s'				"
          "	   and datatype = '%s'			        "
          "	   and measurement_date = '%s';\"	       |"
          "sql.e '|'						",
          station, datatype, date_string);
  results = pipe2string(sys_string);
  if (results)
    timlib_atof_array(f_array, results);
}


x86 assembly (clang, -O0):
<get_statistics_for_station_datatype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xe9b(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <pipe2string@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     119b <get_statistics_for_station_datatype+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x428(%rbp),%rsi
call   1040 <timlib_atof_array@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_statistics_for_station_datatype>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rcx,%r8
mov    %rdx,%rcx
mov    %rsi,%rdx
mov    %rdi,%r14
lea    0xeb3(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <pipe2string@plt>
test   %rax,%rax
je     1170 <get_statistics_for_station_datatype+0x40>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <timlib_atof_array@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [288 x i8] c"echo \22select count(*), \09\09\09\09\09\09sum( measurement_value ), \09\09\09\09avg( measurement_value ),\09\09\09\09min( measurement_value ),\09\09\09\09max( measurement_value )\09\09 from measurement\09\09\09\09\09 where station = '%s'\09\09\09\09\09 and datatype = '%s'\09\09\09 \09 and measurement_date = '%s';\22\09 |sql.e '|'\09\09\09\09\09\09\00"
define void @get_statistics_for_station_datatype(double* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
store double* %0, double** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%15 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([288 x i8], [288 x i8]* @.str, i64 0, i64 0), i8* %12, i8* %13, i8* %14)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%17 = call i8* @pipe2string(i8* %16)
store i8* %17, i8** %10
%18 = load i8*, i8** %10
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %24
20: ; preds = %4
%21 = load double*, double** %5
%22 = load i8*, i8** %10
%23 = call i32 @timlib_atof_array(double* %21, i8* %22)
br label %24
24: ; preds = %20, %4
ret void
}

LLVM IR (-O2):
@.str = [288 x i8] c"echo \22select count(*), \09\09\09\09\09\09sum( measurement_value ), \09\09\09\09avg( measurement_value ),\09\09\09\09min( measurement_value ),\09\09\09\09max( measurement_value )\09\09 from measurement\09\09\09\09\09 where station = '%s'\09\09\09\09\09 and datatype = '%s'\09\09\09 \09 and measurement_date = '%s';\22\09 |sql.e '|'\09\09\09\09\09\09\00"
define void @get_statistics_for_station_datatype(double* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [1024 x i8]
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([288 x i8], [288 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i8* %3)
%8 = call i8* @pipe2string(i8* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = call i32 @timlib_atof_array(double* %0, i8* %8)
br label %12
12: ; preds = %10, %4
ret void
}