#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 */
struct spacedColumn {
  int dummy;
};
struct lineFile {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ freeMem(char *);
scalar_t__ lineFileNext(struct lineFile *, char **, int *);
char *needMem(int);
struct spacedColumn *spacedColumnFromSample(char *);
struct spacedColumn *spacedColumnFromLineFile(struct lineFile *lf) {
  int maxLine = 64 * 1024;
  int lineSize, widestLine = 0;
  char *projection = needMem(maxLine + 1);
  char *line;
  struct spacedColumn *colList;
  int i;
  for (i = 0; i < maxLine; ++i)
    projection[i] = ' ';
  while (lineFileNext(lf, &line, &lineSize)) {
    if (lineSize > widestLine)
      widestLine = lineSize;
    for (i = 0; i < lineSize; ++i) {
      char c = line[i];
      if (c != 0 && c != ' ')
        projection[i] = line[i];
    }
  }
  projection[widestLine] = 0;
  colList = spacedColumnFromSample(projection);
  freeMem(projection);
  return colList;
}


x86 assembly (clang, -O0):
<spacedColumnFromLineFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x10000,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1060 <needMem@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1196 <spacedColumnFromLineFile+0x56>
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1170 <spacedColumnFromLineFile+0x30>
jmp    119b <spacedColumnFromLineFile+0x5b>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1050 <lineFileNext@plt>
cmp    $0x0,%rax
je     1231 <spacedColumnFromLineFile+0xf1>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11c8 <spacedColumnFromLineFile+0x88>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    122c <spacedColumnFromLineFile+0xec>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x35(%rbp)
movsbl -0x35(%rbp),%eax
cmp    $0x0,%eax
je     1219 <spacedColumnFromLineFile+0xd9>
movsbl -0x35(%rbp),%eax
cmp    $0x20,%eax
je     1219 <spacedColumnFromLineFile+0xd9>
mov    -0x28(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    121e <spacedColumnFromLineFile+0xde>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11cf <spacedColumnFromLineFile+0x8f>
jmp    119b <spacedColumnFromLineFile+0x5b>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rdi
call   1030 <spacedColumnFromSample@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <freeMem@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spacedColumnFromLineFile>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0x10001,%edi
call   1070 <needMem@plt>
mov    %rax,%rbx
mov    $0x10000,%edx
mov    %rax,%rdi
mov    $0x20,%esi
call   1050 <memset@plt>
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
mov    %r14,%rdi
call   1060 <lineFileNext@plt>
xor    %r13d,%r13d
test   %rax,%rax
je     1206 <spacedColumnFromLineFile+0xb6>
lea    0x8(%rsp),%r15
lea    0x4(%rsp),%r12
jmp    11c3 <spacedColumnFromLineFile+0x73>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <lineFileNext@plt>
test   %rax,%rax
je     1203 <spacedColumnFromLineFile+0xb3>
mov    0x4(%rsp),%eax
cmp    %r13d,%eax
cmovg  %eax,%r13d
test   %eax,%eax
jle    11b0 <spacedColumnFromLineFile+0x60>
xor    %ecx,%ecx
jmp    11ec <spacedColumnFromLineFile+0x9c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rcx
movslq %eax,%rdx
cmp    %rdx,%rcx
jge    11b0 <spacedColumnFromLineFile+0x60>
mov    0x8(%rsp),%rdx
movzbl (%rdx,%rcx,1),%edx
test   $0xdf,%dl
je     11e0 <spacedColumnFromLineFile+0x90>
mov    %dl,(%rbx,%rcx,1)
mov    0x4(%rsp),%eax
jmp    11e0 <spacedColumnFromLineFile+0x90>
movslq %r13d,%r13
movb   $0x0,(%rbx,%r13,1)
mov    %rbx,%rdi
call   1030 <spacedColumnFromSample@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <freeMem@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.spacedColumn = type { i32 }
%struct.lineFile = type { i32 }
define %struct.spacedColumn* @spacedColumnFromLineFile(%struct.lineFile* %0) {
%2 = alloca %struct.lineFile*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.spacedColumn*
%9 = alloca i32
%10 = alloca i8
store %struct.lineFile* %0, %struct.lineFile** %2
store i32 65536, i32* %3
store i32 0, i32* %5
%11 = load i32, i32* %3
%12 = add nsw i32 %11, 1
%13 = call i8* @needMem(i32 %12)
store i8* %13, i8** %6
store i32 0, i32* %9
br label %14
14: ; preds = %23, %1
%15 = load i32, i32* %9
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i8*, i8** %6
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
store i8 32, i8* %22
br label %23
23: ; preds = %18
%24 = load i32, i32* %9
%25 = add nsw i32 %24, 1
store i32 %25, i32* %9
br label %14
26: ; preds = %14
br label %27
27: ; preds = %69, %26
%28 = load %struct.lineFile*, %struct.lineFile** %2
%29 = call i64 @lineFileNext(%struct.lineFile* %28, i8** %7, i32* %4)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %70
31: ; preds = %27
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = icmp sgt i32 %32, %33
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = load i32, i32* %4
store i32 %36, i32* %5
br label %37
37: ; preds = %35, %31
store i32 0, i32* %9
br label %38
38: ; preds = %66, %37
%39 = load i32, i32* %9
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %69
42: ; preds = %38
%43 = load i8*, i8** %7
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
%47 = load i8, i8* %46
store i8 %47, i8* %10
%48 = load i8, i8* %10
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %65
51: ; preds = %42
%52 = load i8, i8* %10
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 32
br i1 %54, label %55, label %65
55: ; preds = %51
%56 = load i8*, i8** %7
%57 = load i32, i32* %9
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
%60 = load i8, i8* %59
%61 = load i8*, i8** %6
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %61, i64 %63
store i8 %60, i8* %64
br label %65
65: ; preds = %55, %51, %42
br label %66
66: ; preds = %65
%67 = load i32, i32* %9
%68 = add nsw i32 %67, 1
store i32 %68, i32* %9
br label %38
69: ; preds = %38
br label %27
70: ; preds = %27
%71 = load i8*, i8** %6
%72 = load i32, i32* %5
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
store i8 0, i8* %74
%75 = load i8*, i8** %6
%76 = call %struct.spacedColumn* @spacedColumnFromSample(i8* %75)
store %struct.spacedColumn* %76, %struct.spacedColumn** %8
%77 = load i8*, i8** %6
%78 = call i32 @freeMem(i8* %77)
%79 = load %struct.spacedColumn*, %struct.spacedColumn** %8
ret %struct.spacedColumn* %79
}

LLVM IR (-O2):
%struct.spacedColumn = type { i32 }
%struct.lineFile = type { i32 }
define %struct.spacedColumn* @spacedColumnFromLineFile(%struct.lineFile* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i8* @needMem(i32 65537)
%6 = bitcast i8** %3 to i8*
%7 = call i64 @lineFileNext(%struct.lineFile* %0, i8** %3, i32* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %36, label %12
9: ; preds = %29, %12
%10 = call i64 @lineFileNext(%struct.lineFile* %0, i8** %3, i32* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %34, label %12
12: ; preds = %1, %9
%13 = phi i32 [ %16, %9 ], [ 0, %1 ]
%14 = load i32, i32* %2
%15 = icmp sgt i32 %14, %13
%16 = select i1 %15, i32 %14, i32 %13
%17 = icmp sgt i32 %14, 0
br i1 %17, label %18, label %9
18: ; preds = %12, %29
%19 = phi i32 [ %30, %29 ], [ %14, %12 ]
%20 = phi i64 [ %31, %29 ], [ 0, %12 ]
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 %20
%23 = load i8, i8* %22
%24 = and i8 %23, -33
%25 = icmp eq i8 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %18
%27 = getelementptr inbounds i8, i8* %5, i64 %20
store i8 %23, i8* %27
%28 = load i32, i32* %2
br label %29
29: ; preds = %26, %18
%30 = phi i32 [ %28, %26 ], [ %19, %18 ]
%31 = add nuw nsw i64 %20, 1
%32 = sext i32 %30 to i64
%33 = icmp slt i64 %31, %32
br i1 %33, label %18, label %9
34: ; preds = %9
%35 = sext i32 %16 to i64
br label %36
36: ; preds = %34, %1
%37 = phi i64 [ 0, %1 ], [ %35, %34 ]
%38 = getelementptr inbounds i8, i8* %5, i64 %37
store i8 0, i8* %38
%39 = call %struct.spacedColumn* @spacedColumnFromSample(i8* %5)
%40 = call i32 @freeMem(i8* %5)
ret %struct.spacedColumn* %39
}