#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 */
scalar_t__ alloc_array(size_t, int);
int /*<<< orphan*/ exit(int);
int fscanf(int /*<<< orphan*/ *, char *, size_t *);
int /*<<< orphan*/ perror(char *);
char *parse_highlights(FILE *highlight_fstream, size_t height) {
  size_t num;
  char *highlights = (char *)alloc_array(height, sizeof(char));
  if (highlights == NULL) {
    perror("can't malloc\n");
    exit(1);
  }
  while (fscanf(highlight_fstream, "%zd", &num) == 1) {
    if (num >= height) {
      perror("at least one of the lines specified in the given file is out of "
             "bound\n");
    }
    highlights[num] = 1;
  }
  return highlights;
}


x86 assembly (clang, -O0):
<parse_highlights>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <alloc_array@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1183 <parse_highlights+0x43>
lea    0xe8c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1188 <parse_highlights+0x48>
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11d0 <parse_highlights+0x90>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     11bf <parse_highlights+0x7f>
lea    0xe58(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
movb   $0x1,(%rax,%rcx,1)
jmp    1188 <parse_highlights+0x48>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_highlights>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
mov    $0x1,%esi
call   1030 <alloc_array@plt>
test   %rax,%rax
je     11d0 <parse_highlights+0x90>
mov    %rax,%rbx
lea    0xea1(%rip),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11be <parse_highlights+0x7e>
lea    0xe8a(%rip),%r12
mov    %rsp,%r13
lea    0xe84(%rip),%rbp
jmp    11a7 <parse_highlights+0x67>
movb   $0x1,(%rbx,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    11be <parse_highlights+0x7e>
mov    (%rsp),%rax
cmp    %r14,%rax
jb     1190 <parse_highlights+0x50>
mov    %rbp,%rdi
call   1050 <perror@plt>
mov    (%rsp),%rax
jmp    1190 <parse_highlights+0x50>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe29(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"can't malloc\0A\00"
@.str.1 = [4 x i8] c"%zd\00"
@.str.2 = [71 x i8] c"at least one of the lines specified in the given file is out of bound\0A\00"
define i8* @parse_highlights(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
store i32* %0, i32** %3
store i64 %1, i64* %4
%7 = load i64, i64* %4
%8 = call i64 @alloc_array(i64 %7, i32 1)
%9 = inttoptr i64 %8 to i8*
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
br label %16
16: ; preds = %26, %15
%17 = load i32*, i32** %3
%18 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %5)
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i64, i64* %5
%22 = load i64, i64* %4
%23 = icmp uge i64 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @perror(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = load i8*, i8** %6
%28 = load i64, i64* %5
%29 = getelementptr inbounds i8, i8* %27, i64 %28
store i8 1, i8* %29
br label %16
30: ; preds = %16
%31 = load i8*, i8** %6
ret i8* %31
}

LLVM IR (-O2):
@.str = [14 x i8] c"can't malloc\0A\00"
@.str.1 = [4 x i8] c"%zd\00"
@.str.2 = [71 x i8] c"at least one of the lines specified in the given file is out of bound\0A\00"
define i8* @parse_highlights(i32* nocapture %0, i64 %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = tail call i64 @alloc_array(i64 %1, i32 1)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %25
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %8, %20
%15 = load i64, i64* %3
%16 = icmp ult i64 %15, %1
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = call i32 @perror(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%19 = load i64, i64* %3
br label %20
20: ; preds = %17, %14
%21 = phi i64 [ %19, %17 ], [ %15, %14 ]
%22 = getelementptr inbounds i8, i8* %6, i64 %21
store i8 1, i8* %22
%23 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%24 = icmp eq i32 %23, 1
br i1 %24, label %14, label %25
25: ; preds = %20, %8
ret i8* %6
}