#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;

/* Variables and functions */
int lacf_getline_impl(char **, size_t *, void *);
char *strchr(char *, char);
int /*<<< orphan*/ strip_space(char *);
int strlen(char *);
__attribute__((unused)) ssize_t parser_get_next_line_impl(void *fp,
                                                          char **linep,
                                                          size_t *linecap,
                                                          unsigned *linenum) {
  (void)(fp != NULL);
  (void)(linenum != NULL);
  for (;;) {
    ssize_t len = lacf_getline_impl(linep, linecap, fp);
    char *hash;
    if (len == -1)
      return (-1);
    (*linenum)++;
    hash = strchr(*linep, '#');
    if (hash != NULL)
      *hash = '\0';
    strip_space(*linep);
    if (**linep == 0)
      continue;
    len = strlen(*linep);
    for (ssize_t i = 0; i < len; i++) {
      if ((*linep)[i] == '\t')
        (*linep)[i] = ' ';
    }
    return (len);
  }
}


x86 assembly (clang, -O0):
<parser_get_next_line_impl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1060 <lacf_getline_impl@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1182 <parser_get_next_line_impl+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    123a <parser_get_next_line_impl+0xfa>
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     11b4 <parser_get_next_line_impl+0x74>
mov    -0x38(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strip_space@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11d8 <parser_get_next_line_impl+0x98>
jmp    1158 <parser_get_next_line_impl+0x18>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1234 <parser_get_next_line_impl+0xf4>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x9,%eax
jne    1221 <parser_get_next_line_impl+0xe1>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x3c(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
jmp    1226 <parser_get_next_line_impl+0xe6>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ee <parser_get_next_line_impl+0xae>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser_get_next_line_impl>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r12
jmp    1171 <parser_get_next_line_impl+0x31>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <strip_space@plt>
mov    0x0(%r13),%rdi
cmpb   $0x0,(%rdi)
jne    11ae <parser_get_next_line_impl+0x6e>
mov    %r13,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1060 <lacf_getline_impl@plt>
cmp    $0xffffffff,%eax
je     11a7 <parser_get_next_line_impl+0x67>
addl   $0x1,(%r14)
mov    0x0(%r13),%rbx
mov    %rbx,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1160 <parser_get_next_line_impl+0x20>
movb   $0x0,(%rax)
mov    0x0(%r13),%rbx
jmp    1160 <parser_get_next_line_impl+0x20>
mov    $0xffffffff,%eax
jmp    11d3 <parser_get_next_line_impl+0x93>
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d3 <parser_get_next_line_impl+0x93>
mov    %eax,%ecx
cmp    $0x1,%eax
jne    11dd <parser_get_next_line_impl+0x9d>
xor    %edx,%edx
test   $0x1,%cl
je     11d3 <parser_get_next_line_impl+0x93>
mov    0x0(%r13),%rcx
cmpb   $0x9,(%rcx,%rdx,1)
jne    11d3 <parser_get_next_line_impl+0x93>
movb   $0x20,(%rcx,%rdx,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
mov    %ecx,%esi
and    $0xfffffffe,%esi
xor    %edx,%edx
jmp    11f9 <parser_get_next_line_impl+0xb9>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%rdx
cmp    %rdx,%rsi
je     11c0 <parser_get_next_line_impl+0x80>
mov    0x0(%r13),%rdi
cmpb   $0x9,(%rdi,%rdx,1)
jne    1207 <parser_get_next_line_impl+0xc7>
movb   $0x20,(%rdi,%rdx,1)
mov    0x0(%r13),%rdi
cmpb   $0x9,0x1(%rdi,%rdx,1)
jne    11f0 <parser_get_next_line_impl+0xb0>
movb   $0x20,0x1(%rdi,%rdx,1)
jmp    11f0 <parser_get_next_line_impl+0xb0>

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

LLVM IR (-O2):
define i32 @parser_get_next_line_impl(i8* %0, i8** %1, i64* %2, i32* nocapture %3) {
br label %5
5: ; preds = %16, %4
%6 = tail call i32 @lacf_getline_impl(i8** %1, i64* %2, i8* %0)
%7 = icmp eq i32 %6, -1
br i1 %7, label %59, label %8
8: ; preds = %5
%9 = load i32, i32* %3
%10 = add i32 %9, 1
store i32 %10, i32* %3
%11 = load i8*, i8** %1
%12 = tail call i8* @strchr(i8* dereferenceable(1) %11, i8 signext 35)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %8
store i8 0, i8* %12
%15 = load i8*, i8** %1
br label %16
16: ; preds = %14, %8
%17 = phi i8* [ %15, %14 ], [ %11, %8 ]
%18 = tail call i32 @strip_space(i8* %17)
%19 = load i8*, i8** %1
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %5, label %22
22: ; preds = %16
%23 = tail call i32 @strlen(i8* %19)
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %59
25: ; preds = %22
%26 = zext i32 %23 to i64
%27 = and i64 %26, 1
%28 = icmp eq i32 %23, 1
br i1 %28, label %50, label %29
29: ; preds = %25
%30 = and i64 %26, 4294967294
br label %31
31: ; preds = %46, %29
%32 = phi i64 [ 0, %29 ], [ %47, %46 ]
%33 = phi i64 [ 0, %29 ], [ %48, %46 ]
%34 = load i8*, i8** %1
%35 = getelementptr inbounds i8, i8* %34, i64 %32
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 9
br i1 %37, label %38, label %39
38: ; preds = %31
store i8 32, i8* %35
br label %39
39: ; preds = %31, %38
%40 = or i64 %32, 1
%41 = load i8*, i8** %1
%42 = getelementptr inbounds i8, i8* %41, i64 %40
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 9
br i1 %44, label %45, label %46
45: ; preds = %39
store i8 32, i8* %42
br label %46
46: ; preds = %45, %39
%47 = add nuw nsw i64 %32, 2
%48 = add i64 %33, 2
%49 = icmp eq i64 %48, %30
br i1 %49, label %50, label %31
50: ; preds = %46, %25
%51 = phi i64 [ 0, %25 ], [ %47, %46 ]
%52 = icmp eq i64 %27, 0
br i1 %52, label %59, label %53
53: ; preds = %50
%54 = load i8*, i8** %1
%55 = getelementptr inbounds i8, i8* %54, i64 %51
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 9
br i1 %57, label %58, label %59
58: ; preds = %53
store i8 32, i8* %55
br label %59
59: ; preds = %5, %50, %58, %53, %22
%60 = phi i32 [ %23, %22 ], [ %23, %53 ], [ %23, %58 ], [ %23, %50 ], [ -1, %5 ]
ret i32 %60
}