#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 *up_string(char *);
char *get_station_from_file(char *application_name, char *file_with_path) {
  char sys_string[1024];
  char *station;
  sprintf(sys_string,
          "head -1 %s						|"
          "sed 's/YYYY MM DD/DATE/g'				|"
          "toupper.e						|"
          "column.e 1						|"
          "station_alias_to_station %s 0 '|' 2>/dev/null		 ",
          file_with_path, application_name);
  station = pipe2string(sys_string);
  if (!station || !*station)
    return (char *)0;
  else
    return up_string(station);
}


x86 assembly (clang, -O0):
<get_station_from_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xea7(%rip),%rsi
call   1040 <sprintf@plt>
lea    -0x420(%rbp),%rdi
call   1030 <pipe2string@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     118f <get_station_from_file+0x5f>
mov    -0x428(%rbp),%rax
cmpb   $0x0,(%rax)
jne    119c <get_station_from_file+0x6c>
movq   $0x0,-0x8(%rbp)
jmp    11ac <get_station_from_file+0x7c>
mov    -0x428(%rbp),%rdi
call   1050 <up_string@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_station_from_file>:
push   %rbx
sub    $0x400,%rsp
mov    %rsi,%rdx
mov    %rdi,%rcx
lea    0xebb(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <pipe2string@plt>
test   %rax,%rax
je     116c <get_station_from_file+0x3c>
cmpb   $0x0,(%rax)
je     116c <get_station_from_file+0x3c>
mov    %rax,%rdi
call   1050 <up_string@plt>
jmp    116e <get_station_from_file+0x3e>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [129 x i8] c"head -1 %s\09\09\09\09\09\09|sed 's/YYYY MM DD/DATE/g'\09\09\09\09|toupper.e\09\09\09\09\09\09|column.e 1\09\09\09\09\09\09|station_alias_to_station %s 0 '|' 2>/dev/null\09\09 \00"
define i8* @get_station_from_file(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = call i8* @pipe2string(i8* %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %2
%17 = load i8*, i8** %7
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16, %2
store i8* null, i8** %3
br label %24
21: ; preds = %16
%22 = load i8*, i8** %7
%23 = call i8* @up_string(i8* %22)
store i8* %23, i8** %3
br label %24
24: ; preds = %21, %20
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
@.str = [129 x i8] c"head -1 %s\09\09\09\09\09\09|sed 's/YYYY MM DD/DATE/g'\09\09\09\09|toupper.e\09\09\09\09\09\09|column.e 1\09\09\09\09\09\09|station_alias_to_station %s 0 '|' 2>/dev/null\09\09 \00"
define i8* @get_station_from_file(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([129 x i8], [129 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %0)
%6 = call i8* @pipe2string(i8* %4)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i8, i8* %6
%10 = icmp eq i8 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i8* @up_string(i8* %6)
br label %13
13: ; preds = %2, %8, %11
%14 = phi i8* [ %12, %11 ], [ null, %8 ], [ null, %2 ]
ret i8* %14
}