#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ get_line(char *, int /*<<< orphan*/);
scalar_t__ isalpha(char);
scalar_t__ piece(char *, char, char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
char *strdup(char *);
scalar_t__ strncmp(char *, char *, int);
void get_header_array(char **header_array) {
  char input_buffer[128];
  char piece_buffer[128];
  int i;
  while (get_line(input_buffer, stdin)) {
    if (strncmp(input_buffer, "SQL", 3) == 0) {
      fprintf(stderr, "%s\n", input_buffer);
      exit(1);
    }
    if (*input_buffer == '|' && isalpha(*(input_buffer + 1))) {
      for (i = 0; piece(piece_buffer, '|', input_buffer, i + 1); i++) {
        if (i == 1024) {
          fprintf(stderr, "Max columns exceeded: %d\n", 1024);
          exit(1);
        }
        header_array[i] = strdup(piece_buffer);
      }
      header_array[i - 1] = (char *)0;
      return;
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<get_header_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%esi
call   1040 <get_line@plt>
cmp    $0x0,%rax
je     12d1 <get_header_array+0x161>
lea    -0x90(%rbp),%rdi
lea    0xe54(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11e8 <get_header_array+0x78>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rdx
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
movsbl -0x90(%rbp),%eax
cmp    $0x7c,%eax
jne    12cc <get_header_array+0x15c>
movsbl -0x8f(%rbp),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     12cc <get_header_array+0x15c>
movl   $0x0,-0x114(%rbp)
lea    -0x110(%rbp),%rdi
lea    -0x90(%rbp),%rdx
mov    -0x114(%rbp),%ecx
add    $0x1,%ecx
mov    $0x7c,%esi
call   1080 <piece@plt>
cmp    $0x0,%rax
je     12ab <get_header_array+0x13b>
cmpl   $0x400,-0x114(%rbp)
jne    1279 <get_header_array+0x109>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
mov    $0x400,%edx
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    -0x110(%rbp),%rdi
call   1090 <strdup@plt>
mov    %rax,%rdx
mov    -0x8(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1218 <get_header_array+0xa8>
mov    -0x8(%rbp),%rax
mov    -0x114(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movq   $0x0,(%rax,%rcx,8)
add    $0x120,%rsp
pop    %rbp
ret
jmp    117f <get_header_array+0xf>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<get_header_array>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
mov    0x2e5d(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     129b <get_header_array+0x12b>
lea    0xe59(%rip),%r15
mov    %rsp,%rbx
jmp    11c5 <get_header_array+0x55>
nopl   0x0(%rax)
mov    (%r12),%esi
mov    %rbx,%rdi
call   1040 <get_line@plt>
test   %rax,%rax
je     129b <get_header_array+0x12b>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     12a2 <get_header_array+0x132>
cmpb   $0x7c,(%rsp)
jne    11b0 <get_header_array+0x40>
movsbl 0x1(%rsp),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     11b0 <get_header_array+0x40>
lea    0x80(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x7c,%esi
mov    $0x1,%ecx
call   1080 <piece@plt>
test   %rax,%rax
je     127a <get_header_array+0x10a>
movabs $0xffffffff00000000,%r13
ff ff ff
xor    %ebx,%ebx
lea    0x80(%rsp),%r12
mov    %rsp,%r15
movabs $0x100000000,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x400,%rbx
je     12c6 <get_header_array+0x156>
mov    %r12,%rdi
call   1090 <strdup@plt>
mov    %rax,(%r14,%rbx,8)
lea    0x2(%rbx),%ecx
mov    %r12,%rdi
mov    $0x7c,%esi
mov    %r15,%rdx
call   1080 <piece@plt>
add    %rbp,%r13
add    $0x1,%rbx
test   %rax,%rax
jne    1240 <get_header_array+0xd0>
sar    $0x20,%r13
jmp    1281 <get_header_array+0x111>
mov    $0xffffffffffffffff,%r13
movq   $0x0,(%r14,%r13,8)
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xd52(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
mov    $0x400,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"SQL\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [26 x i8] c"Max columns exceeded: %d\0A\00"
define void @get_header_array(i8** %0) {
%2 = alloca i8**
%3 = alloca [128 x i8]
%4 = alloca [128 x i8]
%5 = alloca i32
store i8** %0, i8*** %2
br label %6
6: ; preds = %62, %1
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i64 @get_line(i8* %7, i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %63
11: ; preds = %6
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%13 = call i64 @strncmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %11
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 124
br i1 %24, label %25, label %62
25: ; preds = %20
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = load i8, i8* %27
%29 = call i64 @isalpha(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %62
31: ; preds = %25
store i32 0, i32* %5
br label %32
32: ; preds = %53, %31
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%34 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
%37 = call i64 @piece(i8* %33, i8 signext 124, i8* %34, i32 %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %56
39: ; preds = %32
%40 = load i32, i32* %5
%41 = icmp eq i32 %40, 1024
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%48 = call i8* @strdup(i8* %47)
%49 = load i8**, i8*** %2
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
store i8* %48, i8** %52
br label %53
53: ; preds = %46
%54 = load i32, i32* %5
%55 = add nsw i32 %54, 1
store i32 %55, i32* %5
br label %32
56: ; preds = %32
%57 = load i8**, i8*** %2
%58 = load i32, i32* %5
%59 = sub nsw i32 %58, 1
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8*, i8** %57, i64 %60
store i8* null, i8** %61
ret void
62: ; preds = %25, %20
br label %6
63: ; preds = %6
%64 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"SQL\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [26 x i8] c"Max columns exceeded: %d\0A\00"
define void @get_header_array(i8** nocapture writeonly %0) {
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i64 @get_line(i8* %4, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %55, label %9
9: ; preds = %1
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 1
br label %11
11: ; preds = %9, %51
%12 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %11
%19 = load i8, i8* %4
%20 = icmp eq i8 %19, 124
br i1 %20, label %21, label %51
21: ; preds = %18
%22 = load i8, i8* %10
%23 = call i64 @isalpha(i8 signext %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %51, label %25
25: ; preds = %21
%26 = call i64 @piece(i8* %5, i8 signext 124, i8* %4, i32 1)
%27 = icmp eq i64 %26, 0
br i1 %27, label %48, label %28
28: ; preds = %25, %36
%29 = phi i64 [ %37, %36 ], [ 0, %25 ]
%30 = phi i64 [ %40, %36 ], [ 1, %25 ]
%31 = icmp eq i64 %29, 1024
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 1024)
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = add nuw nsw i64 %29, 1
%38 = call i8* @strdup(i8* %5)
%39 = getelementptr inbounds i8*, i8** %0, i64 %29
store i8* %38, i8** %39
%40 = add nuw nsw i64 %30, 1
%41 = trunc i64 %40 to i32
%42 = call i64 @piece(i8* %5, i8 signext 124, i8* %4, i32 %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %28
44: ; preds = %36
%45 = shl i64 %30, 32
%46 = add i64 %45, -4294967296
%47 = ashr exact i64 %46, 32
br label %48
48: ; preds = %44, %25
%49 = phi i64 [ -1, %25 ], [ %47, %44 ]
%50 = getelementptr inbounds i8*, i8** %0, i64 %49
store i8* null, i8** %50
ret void
51: ; preds = %21, %18
%52 = load i32, i32* @stdin
%53 = call i64 @get_line(i8* %4, i32 %52)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %11
55: ; preds = %51, %1
%56 = call i32 @exit(i32 0)
unreachable
}