#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 */
char EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char getc(int /*<<< orphan*/ *);
char *malloc(int);
char *realloc(char *, int);
int /*<<< orphan*/ stderr;
char *get_chromo_name(FILE *ref) {
  int chromo_name_buffsize = 60;
  char *chromo_name;
  char d;
  if ((chromo_name = malloc(chromo_name_buffsize * sizeof(char))) == NULL) {
    fprintf(stderr, "Out of memory\n");
    exit(EXIT_FAILURE);
  }
  int chromo_name_index = 0;
  if ((d = getc(ref)) == EOF) {
    fprintf(stderr, "Unexpected end of file\n");
    exit(EXIT_FAILURE);
  }
  while ((d != '\n') && (d != ' ')) {
    if (d == EOF) {
      fprintf(stderr, "Unexpected end of file\n");
      exit(EXIT_FAILURE);
    }
    if (chromo_name_index == (chromo_name_buffsize - 1)) {
      chromo_name_buffsize *= 2;
      char *tmp = realloc(chromo_name, chromo_name_buffsize * sizeof(char));
      if (tmp != NULL) {
        chromo_name = tmp;
      } else {
        fprintf(stderr, "Out of memory\n");
        free(chromo_name);
        exit(EXIT_FAILURE);
      }
    }
    chromo_name[chromo_name_index++] = d;
    if ((d = getc(ref)) == EOF) {
      fprintf(stderr, "Unexpected end of file\n");
      exit(EXIT_FAILURE);
    }
  }
  while (d != '\n') {
    if ((d = getc(ref)) == EOF) {
      fprintf(stderr, "Unexpected end of file\n");
      exit(EXIT_FAILURE);
    }
  }
  chromo_name[chromo_name_index] = '\0';
  return chromo_name;
}


x86 assembly (clang, -O0):
<get_chromo_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x3c,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b3 <get_chromo_name+0x53>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e18(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    11fe <get_chromo_name+0x9e>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe24(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1203 <get_chromo_name+0xa3>
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x29(%rbp)
je     1222 <get_chromo_name+0xc2>
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1232 <get_chromo_name+0xd2>
jmp    1346 <get_chromo_name+0x1e6>
movsbl -0x19(%rbp),%eax
mov    0x2dab(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    126b <get_chromo_name+0x10b>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
lea    0xdb7(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    12e5 <get_chromo_name+0x185>
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1060 <realloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12b4 <get_chromo_name+0x154>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    12e0 <get_chromo_name+0x180>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
lea    0xd3c(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    12e5 <get_chromo_name+0x185>
mov    -0x19(%rbp),%dl
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2cd5(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    1341 <get_chromo_name+0x1e1>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
lea    0xce1(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    1203 <get_chromo_name+0xa3>
jmp    134b <get_chromo_name+0x1eb>
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
je     13a1 <get_chromo_name+0x241>
mov    -0x8(%rbp),%rdi
call   1080 <getc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2c7a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
jne    139c <get_chromo_name+0x23c>
mov    0x2c58(%rip),%rax
mov    (%rax),%edi
lea    0xc86(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    134b <get_chromo_name+0x1eb>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_chromo_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3c,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     1281 <get_chromo_name+0x121>
mov    %rax,%r15
mov    %r14,%rdi
call   1080 <getc@plt>
mov    %eax,%ebx
mov    0x2e53(%rip),%rax
mov    (%rax),%al
cmp    %al,%bl
je     1245 <get_chromo_name+0xe5>
mov    $0x3c,%r12d
xor    %ebp,%ebp
jmp    11d7 <get_chromo_name+0x77>
nopl   0x0(%rax)
mov    %r15,%r13
mov    %bl,0x0(%r13,%rbp,1)
add    $0x1,%rbp
mov    %r14,%rdi
call   1080 <getc@plt>
mov    %eax,%ebx
mov    0x2e1b(%rip),%rax
movzbl (%rax),%eax
mov    %r13,%r15
cmp    %al,%bl
je     1245 <get_chromo_name+0xe5>
cmp    $0x20,%bl
je     1224 <get_chromo_name+0xc4>
cmp    $0xa,%bl
je     1224 <get_chromo_name+0xc4>
cmp    %al,%bl
je     1245 <get_chromo_name+0xe5>
lea    -0x1(%r12),%eax
cmp    %rax,%rbp
jne    11b0 <get_chromo_name+0x50>
add    %r12d,%r12d
mov    %r15,%rdi
mov    %r12d,%esi
call   1060 <realloc@plt>
mov    %rax,%r13
test   %rax,%rax
jne    11b3 <get_chromo_name+0x53>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
call   1040 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    125a <get_chromo_name+0xfa>
mov    0x2dbd(%rip),%r12
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%bl
je     1268 <get_chromo_name+0x108>
mov    %r14,%rdi
call   1080 <getc@plt>
mov    %eax,%ebx
cmp    (%r12),%al
jne    1230 <get_chromo_name+0xd0>
mov    0x2d8c(%rip),%rax
mov    (%rax),%edi
lea    0xdba(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    %ebp,%eax
movb   $0x0,(%r15,%rax,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d50(%rip),%rax
mov    (%rax),%edi
lea    0xd6f(%rip),%rsi
jmp    1255 <get_chromo_name+0xf5>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"Out of memory\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i8 0
@.str.1 = [24 x i8] c"Unexpected end of file\0A\00"
define i8* @get_chromo_name(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %2
store i32 60, i32* %3
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = mul i64 %9, 1
%11 = trunc i64 %10 to i32
%12 = call i8* @malloc(i32 %11)
store i8* %12, i8** %4
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %1
store i32 0, i32* %6
%20 = load i32*, i32** %2
%21 = call signext i8 @getc(i32* %20)
store i8 %21, i8* %5
%22 = sext i8 %21 to i32
%23 = load i8, i8* @EOF
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %22, %24
br i1 %25, label %26, label %31
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %19
br label %32
32: ; preds = %97, %31
%33 = load i8, i8* %5
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, 10
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i8, i8* %5
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 32
br label %40
40: ; preds = %36, %32
%41 = phi i1 [ false, %32 ], [ %39, %36 ]
br i1 %41, label %42, label %98
42: ; preds = %40
%43 = load i8, i8* %5
%44 = sext i8 %43 to i32
%45 = load i8, i8* @EOF
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %44, %46
br i1 %47, label %48, label %53
48: ; preds = %42
%49 = load i32, i32* @stderr
%50 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%51 = load i32, i32* @EXIT_FAILURE
%52 = call i32 @exit(i32 %51)
unreachable
53: ; preds = %42
%54 = load i32, i32* %6
%55 = load i32, i32* %3
%56 = sub nsw i32 %55, 1
%57 = icmp eq i32 %54, %56
br i1 %57, label %58, label %79
58: ; preds = %53
%59 = load i32, i32* %3
%60 = mul nsw i32 %59, 2
store i32 %60, i32* %3
%61 = load i8*, i8** %4
%62 = load i32, i32* %3
%63 = sext i32 %62 to i64
%64 = mul i64 %63, 1
%65 = trunc i64 %64 to i32
%66 = call i8* @realloc(i8* %61, i32 %65)
store i8* %66, i8** %7
%67 = load i8*, i8** %7
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %71
69: ; preds = %58
%70 = load i8*, i8** %7
store i8* %70, i8** %4
br label %78
71: ; preds = %58
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%74 = load i8*, i8** %4
%75 = call i32 @free(i8* %74)
%76 = load i32, i32* @EXIT_FAILURE
%77 = call i32 @exit(i32 %76)
unreachable
78: ; preds = %69
br label %79
79: ; preds = %78, %53
%80 = load i8, i8* %5
%81 = load i8*, i8** %4
%82 = load i32, i32* %6
%83 = add nsw i32 %82, 1
store i32 %83, i32* %6
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds i8, i8* %81, i64 %84
store i8 %80, i8* %85
%86 = load i32*, i32** %2
%87 = call signext i8 @getc(i32* %86)
store i8 %87, i8* %5
%88 = sext i8 %87 to i32
%89 = load i8, i8* @EOF
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %88, %90
br i1 %91, label %92, label %97
92: ; preds = %79
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%95 = load i32, i32* @EXIT_FAILURE
%96 = call i32 @exit(i32 %95)
unreachable
97: ; preds = %79
br label %32
98: ; preds = %40
br label %99
99: ; preds = %115, %98
%100 = load i8, i8* %5
%101 = sext i8 %100 to i32
%102 = icmp ne i32 %101, 10
br i1 %102, label %103, label %116
103: ; preds = %99
%104 = load i32*, i32** %2
%105 = call signext i8 @getc(i32* %104)
store i8 %105, i8* %5
%106 = sext i8 %105 to i32
%107 = load i8, i8* @EOF
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %106, %108
br i1 %109, label %110, label %115
110: ; preds = %103
%111 = load i32, i32* @stderr
%112 = call i32 @fprintf(i32 %111, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%113 = load i32, i32* @EXIT_FAILURE
%114 = call i32 @exit(i32 %113)
unreachable
115: ; preds = %103
br label %99
116: ; preds = %99
%117 = load i8*, i8** %4
%118 = load i32, i32* %6
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8, i8* %117, i64 %119
store i8 0, i8* %120
%121 = load i8*, i8** %4
ret i8* %121
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"Out of memory\0A\00"
@EXIT_FAILURE = global i32 0
@EOF = global i8 0
@.str.1 = [24 x i8] c"Unexpected end of file\0A\00"
define i8* @get_chromo_name(i32* nocapture %0) {
%2 = tail call dereferenceable_or_null(60) i8* @malloc(i32 60)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %9
4: ; preds = %1
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %1
%10 = tail call signext i8 @getc(i32* %0)
%11 = load i8, i8* @EOF
%12 = icmp eq i8 %10, %11
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %9, %46
%19 = phi i8 [ %52, %46 ], [ %11, %9 ]
%20 = phi i64 [ %49, %46 ], [ 0, %9 ]
%21 = phi i8* [ %47, %46 ], [ %2, %9 ]
%22 = phi i8 [ %51, %46 ], [ %10, %9 ]
%23 = phi i32 [ %48, %46 ], [ 60, %9 ]
switch i8 %22, label %25 [
i8 32, label %24
i8 10, label %24
]
24: ; preds = %18, %18
br label %59
25: ; preds = %18
%26 = icmp eq i8 %22, %19
br i1 %26, label %27, label %32
27: ; preds = %25
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = add nsw i32 %23, -1
%34 = zext i32 %33 to i64
%35 = icmp eq i64 %20, %34
br i1 %35, label %36, label %46
36: ; preds = %32
%37 = shl nsw i32 %23, 1
%38 = tail call i8* @realloc(i8* %21, i32 %37)
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %46
40: ; preds = %36
%41 = load i32, i32* @stderr
%42 = tail call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%43 = tail call i32 @free(i8* %21)
%44 = load i32, i32* @EXIT_FAILURE
%45 = tail call i32 @exit(i32 %44)
unreachable
46: ; preds = %36, %32
%47 = phi i8* [ %21, %32 ], [ %38, %36 ]
%48 = phi i32 [ %23, %32 ], [ %37, %36 ]
%49 = add nuw i64 %20, 1
%50 = getelementptr inbounds i8, i8* %47, i64 %20
store i8 %22, i8* %50
%51 = tail call signext i8 @getc(i32* %0)
%52 = load i8, i8* @EOF
%53 = icmp eq i8 %51, %52
br i1 %53, label %54, label %18
54: ; preds = %46
%55 = load i32, i32* @stderr
%56 = tail call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%57 = load i32, i32* @EXIT_FAILURE
%58 = tail call i32 @exit(i32 %57)
unreachable
59: ; preds = %24, %62
%60 = phi i8 [ %63, %62 ], [ %22, %24 ]
%61 = icmp eq i8 %60, 10
br i1 %61, label %71, label %62
62: ; preds = %59
%63 = tail call signext i8 @getc(i32* %0)
%64 = load i8, i8* @EOF
%65 = icmp eq i8 %63, %64
br i1 %65, label %66, label %59
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = tail call i32 @fprintf(i32 %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%69 = load i32, i32* @EXIT_FAILURE
%70 = tail call i32 @exit(i32 %69)
unreachable
71: ; preds = %59
%72 = and i64 %20, 4294967295
%73 = getelementptr inbounds i8, i8* %21, i64 %72
store i8 0, i8* %73
ret i8* %21
}