#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 MAXPATHLEN;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ io_err(char *, int);
scalar_t__ opt_is_valid(char *);
int parse_line(char *);
char *strchr(char *, char);
int parse_config(FILE *stream) {
  int lineno;
  char line[MAXPATHLEN], *idx;
  for (lineno = 1; fgets(line, MAXPATHLEN, stream) != NULL; lineno++) {
    idx = strchr(line, '#');
    if (idx != NULL)
      *idx = '\0';
    if (opt_is_valid(line)) {
      if (parse_line(line) == -1) {
        io_err("Could not parse line %d\n", lineno);
        return -1;
      }
    } else {
      io_err("Unrecognized option on line %d.\n", lineno);
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x40(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rdx
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1254 <parse_config+0x104>
mov    -0x40(%rbp),%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11d3 <parse_config+0x83>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
call   1030 <opt_is_valid@plt>
cmp    $0x0,%rax
je     121f <parse_config+0xcf>
mov    -0x40(%rbp),%rdi
call   1070 <parse_line@plt>
cmp    $0xffffffff,%eax
jne    121a <parse_config+0xca>
mov    -0x14(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1050 <io_err@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1262 <parse_config+0x112>
jmp    1241 <parse_config+0xf1>
mov    -0x14(%rbp),%esi
lea    0xdf0(%rip),%rdi
call   1050 <io_err@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1262 <parse_config+0x112>
jmp    1246 <parse_config+0xf6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118f <parse_config+0x3f>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_config>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e80(%rip),%r13
mov    0x0(%r13),%esi
mov    %rsp,%r12
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
mov    %r14,%rdx
call   1060 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
je     1205 <parse_config+0xb5>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11b5 <parse_config+0x65>
movb   $0x0,(%rax)
mov    %r12,%rdi
call   1030 <opt_is_valid@plt>
test   %rax,%rax
je     11e8 <parse_config+0x98>
mov    %r12,%rdi
call   1070 <parse_line@plt>
cmp    $0xffffffff,%eax
je     11f1 <parse_config+0xa1>
add    $0x1,%ebx
mov    0x0(%r13),%esi
mov    %r12,%rdi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11a0 <parse_config+0x50>
jmp    1205 <parse_config+0xb5>
lea    0xe2a(%rip),%rdi
jmp    11f8 <parse_config+0xa8>
lea    0xe08(%rip),%rdi
mov    %ebx,%esi
call   1050 <io_err@plt>
mov    $0xffffffff,%r15d
mov    %r15d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@MAXPATHLEN = global i32 0
@.str = [25 x i8] c"Could not parse line %d\0A\00"
@.str.1 = [33 x i8] c"Unrecognized option on line %d.\0A\00"
define i32 @parse_config(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i32
store i32* %0, i32** %3
%9 = load i32, i32* @MAXPATHLEN
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %5
%12 = alloca i8, i64 %10
store i64 %10, i64* %6
store i32 1, i32* %4
br label %13
13: ; preds = %38, %1
%14 = load i32, i32* @MAXPATHLEN
%15 = load i32*, i32** %3
%16 = call i32* @fgets(i8* %12, i32 %14, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %41
18: ; preds = %13
%19 = call i8* @strchr(i8* %12, i8 signext 35)
store i8* %19, i8** %7
%20 = load i8*, i8** %7
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = load i8*, i8** %7
store i8 0, i8* %23
br label %24
24: ; preds = %22, %18
%25 = call i64 @opt_is_valid(i8* %12)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = call i32 @parse_line(i8* %12)
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %4
%32 = call i32 @io_err(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %31)
store i32 -1, i32* %2
store i32 1, i32* %8
br label %42
33: ; preds = %27
br label %37
34: ; preds = %24
%35 = load i32, i32* %4
%36 = call i32 @io_err(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %35)
store i32 -1, i32* %2
store i32 1, i32* %8
br label %42
37: ; preds = %33
br label %38
38: ; preds = %37
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %13
41: ; preds = %13
store i32 0, i32* %2
store i32 1, i32* %8
br label %42
42: ; preds = %41, %34, %30
%43 = load i8*, i8** %5
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
@.str = [25 x i8] c"Could not parse line %d\0A\00"
@.str.1 = [33 x i8] c"Unrecognized option on line %d.\0A\00"
define i32 @parse_config(i32* nocapture %0) {
%2 = load i32, i32* @MAXPATHLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = call i32* @fgets(i8* %4, i32 %2, i32* %0)
%6 = icmp eq i32* %5, null
br i1 %6, label %26, label %7
7: ; preds = %1, %18
%8 = phi i32 [ %19, %18 ], [ 1, %1 ]
%9 = call i8* @strchr(i8* %4, i8 signext 35)
%10 = icmp eq i8* %9, null
br i1 %10, label %12, label %11
11: ; preds = %7
store i8 0, i8* %9
br label %12
12: ; preds = %11, %7
%13 = call i64 @opt_is_valid(i8* %4)
%14 = icmp eq i64 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = call i32 @parse_line(i8* %4)
%17 = icmp eq i32 %16, -1
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = add nuw nsw i32 %8, 1
%20 = load i32, i32* @MAXPATHLEN
%21 = call i32* @fgets(i8* %4, i32 %20, i32* %0)
%22 = icmp eq i32* %21, null
br i1 %22, label %26, label %7
23: ; preds = %12, %15
%24 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %15 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), %12 ]
%25 = call i32 @io_err(i8* %24, i32 %8)
br label %26
26: ; preds = %18, %23, %1
%27 = phi i32 [ 0, %1 ], [ -1, %23 ], [ 0, %18 ]
ret i32 %27
}