#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 /*<<< orphan*/ build_sql_statement(char *, char *, char);
scalar_t__ get_line(char *, int /*<<< orphan*/);
char *get_token(char **);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
scalar_t__ strcasecmp(char *, char *);
int main(int argc, char **argv) {
  char buffer[2048];
  char sql_stmt[4096];
  char delimiter = '^';
  char *buf_ptr;
  char *tok_ptr;
  if (argc == 2)
    delimiter = *argv[1];
  *sql_stmt = '\0';
  printf("set linesize 9999;\n");
  while (get_line(buffer, stdin)) {
    buf_ptr = buffer;
    while (1) {
      tok_ptr = get_token(&buf_ptr);
      if (!*tok_ptr)
        break;
      if (strcasecmp(tok_ptr, "rem") == 0)
        break;
      if (!build_sql_statement(sql_stmt, tok_ptr, delimiter)) {
        break;
      }
    }
    printf("%s\n", sql_stmt);
    *sql_stmt = '\0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1830,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x5e,-0x1811(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    118a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%al
mov    %al,-0x1811(%rbp)
movb   $0x0,-0x1810(%rbp)
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     1264 <main+0x114>
lea    -0x810(%rbp),%rax
mov    %rax,-0x1820(%rbp)
lea    -0x1820(%rbp),%rdi
call   1070 <get_token@plt>
mov    %rax,-0x1828(%rbp)
mov    -0x1828(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11f4 <main+0xa4>
jmp    1243 <main+0xf3>
mov    -0x1828(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1216 <main+0xc6>
jmp    1243 <main+0xf3>
lea    -0x1810(%rbp),%rdi
mov    -0x1828(%rbp),%rsi
movsbl -0x1811(%rbp),%edx
call   1060 <build_sql_statement@plt>
cmp    $0x0,%eax
jne    123e <main+0xee>
jmp    1243 <main+0xf3>
jmp    11cc <main+0x7c>
lea    -0x1810(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x0,-0x1810(%rbp)
jmp    119f <main+0x4f>
xor    %eax,%eax
add    $0x1830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1818,%rsp
mov    $0x5e,%bl
cmp    $0x2,%edi
jne    116e <main+0x1e>
mov    0x8(%rsi),%rax
mov    (%rax),%bl
movb   $0x0,0x10(%rsp)
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    0x1010(%rsp),%r14
mov    %r14,%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     1223 <main+0xd3>
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r13
lea    0xe4e(%rip),%r12
movsbl %bl,%ebp
jmp    11e3 <main+0x93>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1040 <puts@plt>
movb   $0x0,0x10(%rsp)
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     1223 <main+0xd3>
mov    %r14,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1070 <get_token@plt>
cmpb   $0x0,(%rax)
je     11c0 <main+0x70>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <build_sql_statement@plt>
test   %eax,%eax
jne    11f0 <main+0xa0>
jmp    11c0 <main+0x70>
xor    %eax,%eax
add    $0x1818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"set linesize 9999;\0A\00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"rem\00"
@.str.2 = [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 [2048 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 94, i8* %8
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = load i8, i8* %16
store i8 %17, i8* %8
br label %18
18: ; preds = %13, %2
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
store i8 0, i8* %19
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %47, %18
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* @stdin
%24 = call i64 @get_line(i8* %22, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %51
26: ; preds = %21
%27 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
store i8* %27, i8** %9
br label %28
28: ; preds = %26, %46
%29 = call i8* @get_token(i8** %9)
store i8* %29, i8** %10
%30 = load i8*, i8** %10
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %28
br label %47
34: ; preds = %28
%35 = load i8*, i8** %10
%36 = call i64 @strcasecmp(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %34
br label %47
39: ; preds = %34
%40 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%41 = load i8*, i8** %10
%42 = load i8, i8* %8
%43 = call i32 @build_sql_statement(i8* %40, i8* %41, i8 signext %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %39
br label %47
46: ; preds = %39
br label %28
47: ; preds = %45, %38, %33
%48 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %48)
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
store i8 0, i8* %50
br label %21
51: ; preds = %21
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [4 x i8] c"rem\00"
@str = [19 x i8] c"set linesize 9999;\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = alloca [4096 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%8 = bitcast i8** %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i8, i8* %12
br label %14
14: ; preds = %10, %2
%15 = phi i8 [ %13, %10 ], [ 94, %2 ]
store i8 0, i8* %7
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%17 = load i32, i32* @stdin
%18 = call i64 @get_line(i8* %6, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %36, label %20
20: ; preds = %14, %31
store i8* %6, i8** %5
br label %21
21: ; preds = %28, %20
%22 = call i8* @get_token(i8** %5)
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %21
%26 = call i64 @strcasecmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = call i32 @build_sql_statement(i8* %7, i8* %22, i8 signext %15)
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %21
31: ; preds = %28, %25, %21
%32 = call i32 @puts(i8* %7)
store i8 0, i8* %7
%33 = load i32, i32* @stdin
%34 = call i64 @get_line(i8* %6, i32 %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %20
36: ; preds = %31, %14
ret i32 0
}