#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fatal(char *, int /*<<< orphan*/);
int /*<<< orphan*/ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/);
int hash(char *, char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
void split(FILE **out, int output_ct) {
  char *line = NULL;
  size_t linebuf_sz = 0;
  ssize_t read_sz;
  char *end;
  while ((read_sz = getline(&line, &linebuf_sz, stdin)) != -1) {
    end = strchr(line, '\t');
    if (end == NULL)
      end = (line + read_sz - 1);
    fputs(line, out[hash(line, end) % output_ct]);
  }
  if (!feof(stdin))
    fatal("error reading intput: %s", strerror(errno));
  if (line)
    free(line);
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e42(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <getline@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     122b <split+0xab>
mov    -0x18(%rbp),%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11f1 <split+0x71>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <hash@plt>
mov    -0x40(%rbp),%rdi
cltd
idivl  -0xc(%rbp)
mov    -0x38(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,8),%rsi
call   1060 <fputs@plt>
jmp    119f <split+0x1f>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%eax
jne    125e <split+0xde>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %eax,%esi
lea    0xda7(%rip),%rdi
call   10a0 <fatal@plt>
cmpq   $0x0,-0x18(%rbp)
je     1272 <split+0xf2>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r12d
mov    %rdi,%r13
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2e3b(%rip),%r14
mov    (%r14),%edx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1080 <getline@plt>
cmp    $0xffffffff,%eax
je     1224 <split+0xa4>
mov    %eax,%ebp
lea    0x10(%rsp),%r15
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
call   1050 <strchr@plt>
test   %rax,%rax
movslq %ebp,%rcx
lea    -0x1(%rbx,%rcx,1),%rsi
cmovne %rax,%rsi
mov    %rbx,%rdi
call   1040 <hash@plt>
cltd
idiv   %r12d
movslq %edx,%rax
mov    0x0(%r13,%rax,8),%rsi
mov    %rbx,%rdi
call   1060 <fputs@plt>
mov    (%r14),%edx
lea    0x8(%rsp),%rdi
mov    %r15,%rsi
call   1080 <getline@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11d0 <split+0x50>
mov    (%r14),%edi
call   1070 <feof@plt>
test   %eax,%eax
jne    124c <split+0xcc>
mov    0x2da1(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xdbb(%rip),%rdi
mov    %eax,%esi
call   10a0 <fatal@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     125b <split+0xdb>
call   1030 <free@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [25 x i8] c"error reading intput: %s\00"
@errno = global i32 0
define void @split(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
store i32** %0, i32*** %3
store i32 %1, i32* %4
store i8* null, i8** %5
store i64 0, i64* %6
br label %9
9: ; preds = %24, %2
%10 = load i32, i32* @stdin
%11 = call i32 @getline(i8** %5, i64* %6, i32 %10)
store i32 %11, i32* %7
%12 = icmp ne i32 %11, -1
br i1 %12, label %13, label %36
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = call i8* @strchr(i8* %14, i8 signext 9)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = getelementptr inbounds i8, i8* %22, i64 -1
store i8* %23, i8** %8
br label %24
24: ; preds = %18, %13
%25 = load i8*, i8** %5
%26 = load i32**, i32*** %3
%27 = load i8*, i8** %5
%28 = load i8*, i8** %8
%29 = call i32 @hash(i8* %27, i8* %28)
%30 = load i32, i32* %4
%31 = srem i32 %29, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32*, i32** %26, i64 %32
%34 = load i32*, i32** %33
%35 = call i32 @fputs(i8* %25, i32* %34)
br label %9
36: ; preds = %9
%37 = load i32, i32* @stdin
%38 = call i32 @feof(i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i32, i32* @errno
%42 = call i32 @strerror(i32 %41)
%43 = call i32 @fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %40, %36
%45 = load i8*, i8** %5
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i8*, i8** %5
%49 = call i32 @free(i8* %48)
br label %50
50: ; preds = %47, %44
ret void
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [25 x i8] c"error reading intput: %s\00"
@errno = global i32 0
define void @split(i32** nocapture %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = load i32, i32* @stdin
%8 = call i32 @getline(i8** %3, i64* %4, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %28, label %10
10: ; preds = %2, %10
%11 = phi i32 [ %26, %10 ], [ %8, %2 ]
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* dereferenceable(1) %12, i8 signext 9)
%14 = icmp eq i8* %13, null
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 -1
%17 = getelementptr inbounds i8, i8* %16, i64 %15
%18 = select i1 %14, i8* %17, i8* %13
%19 = call i32 @hash(i8* %12, i8* %18)
%20 = srem i32 %19, %1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32*, i32** %0, i64 %21
%23 = load i32*, i32** %22
%24 = call i32 @fputs(i8* %12, i32* %23)
%25 = load i32, i32* @stdin
%26 = call i32 @getline(i8** %3, i64* %4, i32 %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %10
28: ; preds = %10, %2
%29 = load i32, i32* @stdin
%30 = call i32 @feof(i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* @errno
%34 = call i32 @strerror(i32 %33)
%35 = call i32 @fatal(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %28
%37 = load i8*, i8** %3
%38 = icmp eq i8* %37, null
br i1 %38, label %41, label %39
39: ; preds = %36
%40 = call i32 @free(i8* %37)
br label %41
41: ; preds = %39, %36
ret void
}