#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*/ SEEK_CUR;
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ sql_createTable(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *fp;
  char initial;
  fp = fopen(argv[1], "r+");
  if (!fp) {
    fprintf(stderr, "ERROR ON OPENING SQL FILE\n");
    return 1;
  }
  fscanf(fp, "%c", &initial);
  rewind(fp);
  while (1) {
    char c = fgetc(fp);
    if (feof(fp))
      break;
    if (c == '\n')
      c = ' ';
    fseek(fp, -1, SEEK_CUR);
    fprintf(fp, "%c", c);
  }
  rewind(fp);
  switch (initial) {
  case 'S':
    break;
  case 'I':
    break;
  case 'C':
    sql_createTable(fp);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11dd <main+0x5d>
mov    0x2e18(%rip),%rax
movslq (%rax),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12bb <main+0x13b>
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
lea    -0x19(%rbp),%rdx
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x1a(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     121e <main+0x9e>
jmp    1261 <main+0xe1>
movsbl -0x1a(%rbp),%eax
cmp    $0xa,%eax
jne    122f <main+0xaf>
movb   $0x20,-0x1a(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%esi
call   1080 <fseek@plt>
mov    -0x18(%rbp),%rdi
movsbl -0x1a(%rbp),%edx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    11fa <main+0x7a>
mov    -0x18(%rbp),%rdi
call   1030 <rewind@plt>
movsbl -0x19(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x43,%eax
je     12ab <main+0x12b>
jmp    127f <main+0xff>
mov    -0x20(%rbp),%eax
sub    $0x49,%eax
je     12a6 <main+0x126>
jmp    1290 <main+0x110>
mov    -0x20(%rbp),%eax
sub    $0x53,%eax
jne    12b4 <main+0x134>
jmp    12a1 <main+0x121>
jmp    12b4 <main+0x134>
jmp    12b4 <main+0x134>
mov    -0x18(%rbp),%rdi
call   10a0 <sql_createTable@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
lea    0xe5e(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     1257 <main+0xc7>
mov    %rax,%r14
lea    0xe64(%rip),%rsi
lea    0x7(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
mov    %r14,%rdi
call   1030 <rewind@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
jne    123c <main+0xac>
mov    $0x20,%r15d
mov    0x2df5(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0xa,%bl
movzbl %bl,%ebx
cmove  %r15d,%ebx
mov    0x0(%rbp),%edx
mov    %r14,%rdi
mov    $0xffffffff,%esi
call   1080 <fseek@plt>
movsbl %bl,%edi
mov    %r14,%rsi
call   1060 <fputc@plt>
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1070 <feof@plt>
test   %rax,%rax
je     1200 <main+0x70>
mov    %r14,%rdi
call   1030 <rewind@plt>
xor    %ebx,%ebx
cmpb   $0x43,0x7(%rsp)
jne    127c <main+0xec>
mov    %r14,%rdi
call   10b0 <sql_createTable@plt>
jmp    127c <main+0xec>
mov    0x2d7a(%rip),%rax
movslq (%rax),%rcx
lea    0xd9b(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ERROR ON OPENING SQL FILE\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %20, label %15
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i32*
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %56
20: ; preds = %2
%21 = load i32*, i32** %6
%22 = call i32 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%23 = load i32*, i32** %6
%24 = call i32 @rewind(i32* %23)
br label %25
25: ; preds = %20, %37
%26 = load i32*, i32** %6
%27 = call signext i8 @fgetc(i32* %26)
store i8 %27, i8* %8
%28 = load i32*, i32** %6
%29 = call i64 @feof(i32* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
br label %45
32: ; preds = %25
%33 = load i8, i8* %8
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %32
store i8 32, i8* %8
br label %37
37: ; preds = %36, %32
%38 = load i32*, i32** %6
%39 = load i32, i32* @SEEK_CUR
%40 = call i32 @fseek(i32* %38, i32 -1, i32 %39)
%41 = load i32*, i32** %6
%42 = load i8, i8* %8
%43 = sext i8 %42 to i32
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %25
45: ; preds = %31
%46 = load i32*, i32** %6
%47 = call i32 @rewind(i32* %46)
%48 = load i8, i8* %7
%49 = sext i8 %48 to i32
switch i32 %49, label %55 [
i32 83, label %50
i32 73, label %51
i32 67, label %52
]
50: ; preds = %45
br label %55
51: ; preds = %45
br label %55
52: ; preds = %45
%53 = load i32*, i32** %6
%54 = call i32 @sql_createTable(i32* %53)
br label %55
55: ; preds = %45, %52, %51, %50
store i32 0, i32* %3
br label %56
56: ; preds = %55, %15
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"r+\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ERROR ON OPENING SQL FILE\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@SEEK_CUR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i64 26, i64 1, i32* %11)
br label %36
13: ; preds = %2
%14 = call i32 @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%15 = call i32 @rewind(i32* %6)
%16 = call signext i8 @fgetc(i32* %6)
%17 = call i64 @feof(i32* %6)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %30
19: ; preds = %13, %19
%20 = phi i8 [ %27, %19 ], [ %16, %13 ]
%21 = icmp eq i8 %20, 10
%22 = select i1 %21, i8 32, i8 %20
%23 = load i32, i32* @SEEK_CUR
%24 = call i32 @fseek(i32* %6, i32 -1, i32 %23)
%25 = sext i8 %22 to i32
%26 = call i32 @fputc(i32 %25, i32* %6)
%27 = call signext i8 @fgetc(i32* %6)
%28 = call i64 @feof(i32* %6)
%29 = icmp eq i64 %28, 0
br i1 %29, label %19, label %30
30: ; preds = %19, %13
%31 = call i32 @rewind(i32* %6)
%32 = load i8, i8* %3
%33 = icmp eq i8 %32, 67
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = call i32 @sql_createTable(i32* %6)
br label %36
36: ; preds = %34, %30, %8
%37 = phi i32 [ 1, %8 ], [ 0, %30 ], [ 0, %34 ]
ret i32 %37
}