#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 */
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ trim_string(char *);
int read_line(FILE *in, char *buf, long buflen) {
  while (!feof(in)) {
    if (fgets(buf, buflen, in) != NULL) {
      trim_string(buf);
      if ((buf[0] != '#') && (buf[0] != ';')) {
        return 0;
      }
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1162 <read_line+0x32>
jmp    11bc <read_line+0x8c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11b7 <read_line+0x87>
mov    -0x18(%rbp),%rdi
call   1030 <trim_string@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
je     11b2 <read_line+0x82>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3b,%eax
je     11b2 <read_line+0x82>
movl   $0x0,-0x4(%rbp)
jmp    11c3 <read_line+0x93>
jmp    11b7 <read_line+0x87>
jmp    1144 <read_line+0x14>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%rbp
mov    %rdi,%rbx
call   1050 <feof@plt>
mov    $0x1,%r14d
jmp    1158 <read_line+0x28>
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <feof@plt>
test   %eax,%eax
jne    1186 <read_line+0x56>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1150 <read_line+0x20>
mov    %rbp,%rdi
call   1030 <trim_string@plt>
movzbl 0x0(%rbp),%eax
cmp    $0x3b,%al
je     1150 <read_line+0x20>
cmp    $0x23,%al
je     1150 <read_line+0x20>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @read_line(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
br label %8
8: ; preds = %35, %3
%9 = load i32*, i32** %5
%10 = call i32 @feof(i32* %9)
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %36
13: ; preds = %8
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = load i32*, i32** %5
%17 = call i32* @fgets(i8* %14, i64 %15, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %35
19: ; preds = %13
%20 = load i8*, i8** %6
%21 = call i32 @trim_string(i8* %20)
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 35
br i1 %26, label %27, label %34
27: ; preds = %19
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 59
br i1 %32, label %33, label %34
33: ; preds = %27
store i32 0, i32* %4
br label %37
34: ; preds = %27, %19
br label %35
35: ; preds = %34, %13
br label %8
36: ; preds = %8
store i32 1, i32* %4
br label %37
37: ; preds = %36, %33
%38 = load i32, i32* %4
ret i32 %38
}

LLVM IR (-O2):
define i32 @read_line(i32* nocapture %0, i8* %1, i64 %2) {
%4 = tail call i32 @feof(i32* %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %3, %12
%7 = tail call i32* @fgets(i8* %1, i64 %2, i32* %0)
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @trim_string(i8* %1)
%11 = load i8, i8* %1
switch i8 %11, label %15 [
i8 35, label %12
i8 59, label %12
]
12: ; preds = %9, %9, %6
%13 = tail call i32 @feof(i32* %0)
%14 = icmp eq i32 %13, 0
br i1 %14, label %6, label %15
15: ; preds = %9, %12, %3
%16 = phi i32 [ 1, %3 ], [ 1, %12 ], [ 0, %9 ]
ret i32 %16
}