#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 */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ get_line(char *, int /*<<< orphan*/);
char *get_table_name(char *, char *);
int /*<<< orphan*/ piece(char *, char, char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ system(char *);
int main(int argc, char **argv) {
  char *entity;
  char input_line[1024];
  char station[128], datatype[128], measurement_date[128];
  int station_piece, datatype_piece, date_piece;
  char *table_name;
  int really_yn;
  if (argc != 6) {
    fprintf(
        stderr,
        "Usage: %s entity station_piece datatype_piece date_piece really_yn\n",
        argv[0]);
    exit(1);
  }
  entity = argv[1];
  station_piece = atoi(argv[2]);
  datatype_piece = atoi(argv[3]);
  date_piece = atoi(argv[4]);
  really_yn = *argv[5];
  table_name = get_table_name(entity, "measurement");
  while (get_line(input_line, stdin)) {
    piece(station, '|', input_line, station_piece);
    piece(datatype, '|', input_line, datatype_piece);
    piece(measurement_date, '|', input_line, date_piece);
    if (really_yn == 'y') {
      char sys_string[1024];
      sprintf(sys_string,
              "echo \"delete from %s					"
              "	where station = '%s'				"
              "  	and datatype = '%s'				"
              "  	and measurement_date = '%s';\" | sql		",
              table_name, station, datatype, measurement_date);
      system(sys_string);
    }
    printf("%s\n", input_line);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x6,-0x8(%rbp)
je     11d9 <main+0x49>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe36(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x5a4(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x5a8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x5ac(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movsbl (%rax),%eax
mov    %eax,-0x5bc(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1070 <get_table_name@plt>
mov    %rax,-0x5b8(%rbp)
lea    -0x420(%rbp),%rdi
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
call   1030 <get_line@plt>
cmp    $0x0,%rax
je     131f <main+0x18f>
lea    -0x4a0(%rbp),%rdi
lea    -0x420(%rbp),%rdx
mov    -0x5a4(%rbp),%ecx
mov    $0x7c,%esi
call   10b0 <piece@plt>
lea    -0x520(%rbp),%rdi
lea    -0x420(%rbp),%rdx
mov    -0x5a8(%rbp),%ecx
mov    $0x7c,%esi
call   10b0 <piece@plt>
lea    -0x5a0(%rbp),%rdi
lea    -0x420(%rbp),%rdx
mov    -0x5ac(%rbp),%ecx
mov    $0x7c,%esi
call   10b0 <piece@plt>
cmpl   $0x79,-0x5bc(%rbp)
jne    1307 <main+0x177>
lea    -0x9c0(%rbp),%rdi
mov    -0x5b8(%rbp),%rdx
lea    -0x4a0(%rbp),%rcx
lea    -0x520(%rbp),%r8
lea    -0x5a0(%rbp),%r9
lea    0xd5a(%rip),%rsi
call   1090 <sprintf@plt>
lea    -0x9c0(%rbp),%rdi
call   1040 <system@plt>
lea    -0x420(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1050 <printf@plt>
jmp    1246 <main+0xb6>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x998,%rsp
mov    %rsi,%rbp
cmp    $0x6,%edi
jne    120f <main+0x7f>
mov    0x8(%rbp),%r14
mov    0x10(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,0x4(%rsp)
mov    0x18(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,(%rsp)
mov    0x20(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%r13d
mov    0x28(%rbp),%rax
mov    (%rax),%r15b
lea    0xe64(%rip),%rsi
mov    %r14,%rdi
call   1070 <get_table_name@plt>
mov    %rax,0x8(%rsp)
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
lea    0x190(%rsp),%rdi
call   1030 <get_line@plt>
test   %rax,%rax
jne    1232 <main+0xa2>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0x190(%rsp),%rbp
lea    0x110(%rsp),%r14
lea    0xe7c(%rip),%rbx
jmp    1271 <main+0xe1>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1030 <get_line@plt>
test   %rax,%rax
je     1208 <main+0x78>
lea    0x90(%rsp),%rdi
mov    $0x7c,%esi
mov    %rbp,%rdx
mov    0x4(%rsp),%ecx
call   10b0 <piece@plt>
lea    0x10(%rsp),%rdi
mov    $0x7c,%esi
mov    %rbp,%rdx
mov    (%rsp),%ecx
call   10b0 <piece@plt>
mov    %r14,%rdi
mov    $0x7c,%esi
mov    %rbp,%rdx
mov    %r13d,%ecx
call   10b0 <piece@plt>
cmp    $0x79,%r15b
jne    1250 <main+0xc0>
mov    %r13d,%r12d
lea    0x590(%rsp),%r13
mov    %r13,%rdi
lea    0xd83(%rip),%rsi
mov    0x8(%rsp),%rdx
lea    0x90(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %r14,%r9
call   1090 <sprintf@plt>
mov    %r13,%rdi
mov    %r12d,%r13d
call   1040 <system@plt>
jmp    1250 <main+0xc0>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [68 x i8] c"Usage: %s entity station_piece datatype_piece date_piece really_yn\0A\00"
@.str.1 = [12 x i8] c"measurement\00"
@stdin = global i32 0
@.str.2 = [117 x i8] c"echo \22delete from %s\09\09\09\09\09\09where station = '%s'\09\09\09\09 \09and datatype = '%s'\09\09\09\09 \09and measurement_date = '%s';\22 | sql\09\09\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [1024 x i8]
%8 = alloca [128 x i8]
%9 = alloca [128 x i8]
%10 = alloca [128 x i8]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 6
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %11
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %12
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 4
%40 = load i8*, i8** %39
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %13
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 5
%44 = load i8*, i8** %43
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
store i32 %46, i32* %15
%47 = load i8*, i8** %6
%48 = call i8* @get_table_name(i8* %47, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
store i8* %48, i8** %14
br label %49
49: ; preds = %78, %26
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%51 = load i32, i32* @stdin
%52 = call i64 @get_line(i8* %50, i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %81
54: ; preds = %49
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%56 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%57 = load i32, i32* %11
%58 = call i32 @piece(i8* %55, i8 signext 124, i8* %56, i32 %57)
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%61 = load i32, i32* %12
%62 = call i32 @piece(i8* %59, i8 signext 124, i8* %60, i32 %61)
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%65 = load i32, i32* %13
%66 = call i32 @piece(i8* %63, i8 signext 124, i8* %64, i32 %65)
%67 = load i32, i32* %15
%68 = icmp eq i32 %67, 121
br i1 %68, label %69, label %78
69: ; preds = %54
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%71 = load i8*, i8** %14
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%73 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%74 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%75 = call i32 @sprintf(i8* %70, i8* getelementptr inbounds ([117 x i8], [117 x i8]* @.str.2, i64 0, i64 0), i8* %71, i8* %72, i8* %73, i8* %74)
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %16, i64 0, i64 0
%77 = call i32 @system(i8* %76)
br label %78
78: ; preds = %69, %54
%79 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%80 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %79)
br label %49
81: ; preds = %49
%82 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [68 x i8] c"Usage: %s entity station_piece datatype_piece date_piece really_yn\0A\00"
@.str.1 = [12 x i8] c"measurement\00"
@stdin = global i32 0
@.str.2 = [117 x i8] c"echo \22delete from %s\09\09\09\09\09\09where station = '%s'\09\09\09\09 \09and datatype = '%s'\09\09\09\09 \09and measurement_date = '%s';\22 | sql\09\09\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [128 x i8]
%5 = alloca [128 x i8]
%6 = alloca [128 x i8]
%7 = alloca [1024 x i8]
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%12 = icmp eq i32 %0, 6
br i1 %12, label %18, label %13
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %1
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i32 @atoi(i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 3
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = getelementptr inbounds i8*, i8** %1, i64 4
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
%30 = getelementptr inbounds i8*, i8** %1, i64 5
%31 = load i8*, i8** %30
%32 = load i8, i8* %31
%33 = tail call i8* @get_table_name(i8* %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%34 = load i32, i32* @stdin
%35 = call i64 @get_line(i8* %8, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %52, label %37
37: ; preds = %18
%38 = icmp eq i8 %32, 121
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
br label %40
40: ; preds = %37, %47
%41 = call i32 @piece(i8* %9, i8 signext 124, i8* %8, i32 %23)
%42 = call i32 @piece(i8* %10, i8 signext 124, i8* %8, i32 %26)
%43 = call i32 @piece(i8* %11, i8 signext 124, i8* %8, i32 %29)
br i1 %38, label %44, label %47
44: ; preds = %40
%45 = call i32 @sprintf(i8* %39, i8* dereferenceable(1) getelementptr inbounds ([117 x i8], [117 x i8]* @.str.2, i64 0, i64 0), i8* %33, i8* %9, i8* %10, i8* %11)
%46 = call i32 @system(i8* %39)
br label %47
47: ; preds = %44, %40
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%49 = load i32, i32* @stdin
%50 = call i64 @get_line(i8* %8, i32 %49)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %40
52: ; preds = %47, %18
%53 = call i32 @exit(i32 0)
unreachable
}