#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_stmt(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 *buf_ptr;
  char *tok_ptr;
  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;
      build_sql_stmt(sql_stmt, tok_ptr);
    }
  }
  printf("%s\n", sql_stmt);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x810(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     120b <main+0xbb>
lea    -0x810(%rbp),%rax
mov    %rax,-0x1818(%rbp)
lea    -0x1818(%rbp),%rdi
call   1070 <get_token@plt>
mov    %rax,-0x1820(%rbp)
mov    -0x1820(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11cc <main+0x7c>
jmp    1206 <main+0xb6>
mov    -0x1820(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11ee <main+0x9e>
jmp    1206 <main+0xb6>
lea    -0x1810(%rbp),%rdi
mov    -0x1820(%rbp),%rsi
call   1060 <build_sql_stmt@plt>
jmp    11a4 <main+0x54>
jmp    1177 <main+0x27>
lea    -0x1810(%rbp),%rsi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x1820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1818,%rsp
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e74(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x1010(%rsp),%r14
mov    %r14,%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     11fd <main+0xad>
lea    0x8(%rsp),%r13
lea    0xe68(%rip),%r15
lea    0x10(%rsp),%r12
jmp    11b0 <main+0x60>
nop
mov    0x0(%rbp),%esi
mov    %r14,%rdi
call   1050 <get_line@plt>
test   %rax,%rax
je     11fd <main+0xad>
mov    %r14,0x8(%rsp)
mov    %r13,%rdi
call   1070 <get_token@plt>
cmpb   $0x0,(%rax)
je     11a0 <main+0x50>
mov    %rax,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     11a0 <main+0x50>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1060 <build_sql_stmt@plt>
mov    %r13,%rdi
call   1070 <get_token@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
jne    11d0 <main+0x80>
jmp    11a0 <main+0x50>
lea    0x10(%rsp),%rdi
call   1040 <puts@plt>
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*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %33, %2
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @stdin
%14 = call i64 @get_line(i8* %12, i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %34
16: ; preds = %11
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
store i8* %17, i8** %8
br label %18
18: ; preds = %16, %29
%19 = call i8* @get_token(i8** %8)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18
br label %33
24: ; preds = %18
%25 = load i8*, i8** %9
%26 = call i64 @strcasecmp(i8* %25, 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 %28, label %29
28: ; preds = %24
br label %33
29: ; preds = %24
%30 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%31 = load i8*, i8** %9
%32 = call i32 @build_sql_stmt(i8* %30, i8* %31)
br label %18
33: ; preds = %28, %23
br label %11
34: ; preds = %11
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %35)
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 readnone %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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i64 @get_line(i8* %6, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %2, %26
store i8* %6, i8** %5
%14 = call i8* @get_token(i8** %5)
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %26, label %17
17: ; preds = %13, %21
%18 = phi i8* [ %23, %21 ], [ %14, %13 ]
%19 = call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %17
%22 = call i32 @build_sql_stmt(i8* %7, i8* %18)
%23 = call i8* @get_token(i8** %5)
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %17
26: ; preds = %21, %17, %13
%27 = load i32, i32* @stdin
%28 = call i64 @get_line(i8* %6, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %13
30: ; preds = %26, %2
%31 = call i32 @puts(i8* %7)
ret i32 0
}