#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*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                           char *, char *, char *, char *);
char *get_table_name(char *, char *);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ search_replace_string(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
void measurement_update_parameter_save_event(char *application_name,
                                             char *station, char *datatype,
                                             char *measurement_update_method,
                                             char *login_name, char *now_date,
                                             char *now_time, char *notes) {
  char sys_string[4096];
  char *table_name;
  FILE *p;
  if (!notes || strcmp(notes, "notes") == 0)
    notes = "";
  else
    search_replace_string(notes, "\"", "'");
  table_name = get_table_name(application_name, "measurement_update_event");
  sprintf(sys_string,
          "insert_statement.e %s %s '^'	|"
          "tee_appaserver_error.sh	|"
          "sql.e				 ",
          table_name,
          "station,datatype,measurement_update_method,measurement_update_date,"
          "measurement_update_time,login_name,notes");
  p = popen(sys_string, "w");
  fprintf(p, "%s^%s^%s^%s^%s^%s^%s\n", station, datatype,
          measurement_update_method, now_date, now_time, login_name, notes);
  pclose(p);
}


x86 assembly (clang, -O0):
<measurement_update_parameter_save_event>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1060,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,0x18(%rbp)
je     11c0 <measurement_update_parameter_save_event+0x50>
mov    0x18(%rbp),%rdi
lea    0xf14(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11d0 <measurement_update_parameter_save_event+0x60>
lea    0xf1b(%rip),%rax
mov    %rax,0x18(%rbp)
jmp    11e7 <measurement_update_parameter_save_event+0x77>
mov    0x18(%rbp),%rdi
lea    0xe25(%rip),%rsi
lea    0xe20(%rip),%rdx
call   1030 <search_replace_string@plt>
mov    -0x8(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1070 <get_table_name@plt>
mov    %rax,-0x1038(%rbp)
lea    -0x1030(%rbp),%rdi
mov    -0x1038(%rbp),%rdx
lea    0xe0a(%rip),%rsi
lea    0xe45(%rip),%rcx
call   1090 <sprintf@plt>
lea    -0x1030(%rbp),%rdi
lea    0xe9e(%rip),%rsi
call   1080 <popen@plt>
mov    %rax,-0x1040(%rbp)
mov    -0x1040(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%r11
mov    -0x28(%rbp),%r10
mov    0x18(%rbp),%rax
lea    0xe6a(%rip),%rsi
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1060 <fprintf@plt>
mov    -0x1040(%rbp),%rdi
call   1040 <pclose@plt>
add    $0x1060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<measurement_update_parameter_save_event>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1028,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x18(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    0x1068(%rsp),%r14
mov    0x1060(%rsp),%rax
mov    %rax,0x8(%rsp)
lea    0xf2f(%rip),%r15
test   %r14,%r14
je     11e5 <measurement_update_parameter_save_event+0x75>
lea    0xf06(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11e5 <measurement_update_parameter_save_event+0x75>
lea    0xe2d(%rip),%rsi
lea    0xe28(%rip),%rdx
mov    %r14,%rdi
call   1030 <search_replace_string@plt>
mov    %r14,%r15
lea    0xe18(%rip),%rsi
mov    %rbp,%rdi
call   1070 <get_table_name@plt>
lea    0xe22(%rip),%rsi
lea    0xe5d(%rip),%rcx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rdx
call   1090 <sprintf@plt>
lea    0xeb2(%rip),%rsi
mov    %rbp,%rdi
call   1080 <popen@plt>
mov    %rax,%rbp
sub    $0x8,%rsp
lea    0xe9e(%rip),%rsi
mov    %rax,%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r12,%r8
mov    0x18(%rsp),%r9
push   %r15
push   0x28(%rsp)
push   0x20(%rsp)
call   1060 <fprintf@plt>
add    $0x20,%rsp
mov    %rbp,%rdi
add    $0x1028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <pclose@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"notes\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\22\00"
@.str.3 = [2 x i8] c"'\00"
@.str.4 = [25 x i8] c"measurement_update_event\00"
@.str.5 = [66 x i8] c"insert_statement.e %s %s '^'\09|tee_appaserver_error.sh\09|sql.e\09\09\09\09 \00"
@.str.6 = [108 x i8] c"station,datatype,measurement_update_method,measurement_update_date,measurement_update_time,login_name,notes\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [22 x i8] c"%s^%s^%s^%s^%s^%s^%s\0A\00"
define void @measurement_update_parameter_save_event(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca [4096 x i8]
%18 = alloca i8*
%19 = alloca i32*
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i8* %6, i8** %15
store i8* %7, i8** %16
%20 = load i8*, i8** %16
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %8
%23 = load i8*, i8** %16
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22, %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %16
br label %30
27: ; preds = %22
%28 = load i8*, i8** %16
%29 = call i32 @search_replace_string(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %30
30: ; preds = %27, %26
%31 = load i8*, i8** %9
%32 = call i8* @get_table_name(i8* %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
store i8* %32, i8** %18
%33 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%34 = load i8*, i8** %18
%35 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* %34, i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.6, i64 0, i64 0))
%36 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%37 = call i32* @popen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %37, i32** %19
%38 = load i32*, i32** %19
%39 = load i8*, i8** %10
%40 = load i8*, i8** %11
%41 = load i8*, i8** %12
%42 = load i8*, i8** %14
%43 = load i8*, i8** %15
%44 = load i8*, i8** %13
%45 = load i8*, i8** %16
%46 = call i32 @fprintf(i32* %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %39, i8* %40, i8* %41, i8* %42, i8* %43, i8* %44, i8* %45)
%47 = load i32*, i32** %19
%48 = call i32 @pclose(i32* %47)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"notes\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"\22\00"
@.str.3 = [2 x i8] c"'\00"
@.str.4 = [25 x i8] c"measurement_update_event\00"
@.str.5 = [66 x i8] c"insert_statement.e %s %s '^'\09|tee_appaserver_error.sh\09|sql.e\09\09\09\09 \00"
@.str.6 = [108 x i8] c"station,datatype,measurement_update_method,measurement_update_date,measurement_update_time,login_name,notes\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [22 x i8] c"%s^%s^%s^%s^%s^%s^%s\0A\00"
define void @measurement_update_parameter_save_event(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca [4096 x i8]
%10 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%11 = icmp eq i8* %7, null
br i1 %11, label %17, label %12
12: ; preds = %8
%13 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %12
%16 = tail call i32 @search_replace_string(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %8, %12, %15
%18 = phi i8* [ %7, %15 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %12 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %8 ]
%19 = tail call i8* @get_table_name(i8* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0), i8* %19, i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.6, i64 0, i64 0))
%21 = call i32* @popen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%22 = tail call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %2, i8* %3, i8* %5, i8* %6, i8* %4, i8* %18)
%23 = tail call i32 @pclose(i32* %21)
ret void
}