#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 */
struct config {
  int dummy;
};
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
scalar_t__ config_line(struct config *, int, char *);
int /*<<< orphan*/ errno;
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ print_errlog(char *, int, int /*<<< orphan*/, char *,
                                char const *);
int /*<<< orphan*/ print_log(char *, int);
int read(int, char *, int);
int config_read(struct config *o, const char *path) {
  int fd, s, i, line_e, line_num;
  char buf[1024], line[1024];
  fd = open(path, O_RDONLY);
  if (fd < 0) {
    do {
      print_errlog("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/"
                   "heads/master/acp-c/config.c",
                   175, errno, "Cannot open configuration. path=%s", path);
    } while (0);
    return -1;
  }
  line_num = 0;
  line_e = 0;
  while ((s = read(fd, buf, sizeof(buf))) > 0) {
    for (i = 0; i < s; i++) {
      if (line_e >= sizeof(line)) {
        print_log("A line in the configuration file is too long. line=%d",
                  line_num);
        return -1;
      }
      line[line_e++] = buf[i];
      if (buf[i] == '\r') {
        line_e--;
      } else if (buf[i] == '\n') {
        line_e--;
        line[line_e] = '\0';
        line_num++;
        line_e = 0;
        if (0 != config_line(o, line_num, line)) {
          return -1;
        }
      }
    }
  }
  if (line_e > 0) {
    line_num++;
    if (0 != config_line(o, line_num, line)) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<config_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11b8 <config_read+0x68>
jmp    1187 <config_read+0x37>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%r8
lea    0xe65(%rip),%rdi
mov    $0xaf,%esi
lea    0xee6(%rip),%rcx
call   1060 <print_errlog@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <config_read+0x1eb>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    12ef <config_read+0x19f>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    12ea <config_read+0x19a>
movslq -0x28(%rbp),%rax
cmp    $0x400,%rax
jb     1224 <config_read+0xd4>
mov    -0x2c(%rbp),%esi
lea    0xe9d(%rip),%rdi
call   1030 <print_log@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <config_read+0x1eb>
movslq -0x24(%rbp),%rax
mov    -0x430(%rbp,%rax,1),%cl
mov    -0x28(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x28(%rbp)
cltq
mov    %cl,-0x830(%rbp,%rax,1)
movslq -0x24(%rbp),%rax
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
jne    1266 <config_read+0x116>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    12d7 <config_read+0x187>
movslq -0x24(%rbp),%rax
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    12d2 <config_read+0x182>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
movslq -0x28(%rbp),%rax
movb   $0x0,-0x830(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x830(%rbp),%rdx
call   1040 <config_line@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     12cd <config_read+0x17d>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <config_read+0x1eb>
jmp    12d2 <config_read+0x182>
jmp    12d7 <config_read+0x187>
jmp    12dc <config_read+0x18c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ed <config_read+0x9d>
jmp    11c6 <config_read+0x76>
cmpl   $0x0,-0x28(%rbp)
jle    1334 <config_read+0x1e4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%esi
lea    -0x830(%rbp),%rdx
call   1040 <config_line@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     132f <config_read+0x1df>
movl   $0xffffffff,-0x4(%rbp)
jmp    133b <config_read+0x1eb>
jmp    1334 <config_read+0x1e4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<config_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbp
mov    %rdi,%r13
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1070 <open@plt>
test   %eax,%eax
js     123e <config_read+0xee>
mov    %eax,%r14d
lea    0x400(%rsp),%rsi
mov    %eax,%edi
mov    $0x400,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    123a <config_read+0xea>
xor    %ebp,%ebp
xor    %ebx,%ebx
mov    %eax,%r15d
xor    %r12d,%r12d
jmp    11bc <config_read+0x6c>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
add    $0x1,%r12
cmp    %r12,%r15
je     1200 <config_read+0xb0>
cmp    $0x400,%ebx
jae    1264 <config_read+0x114>
mov    %ebx,%eax
movzbl 0x400(%rsp,%r12,1),%ecx
mov    %cl,(%rsp,%rax,1)
cmp    $0xd,%cl
je     11b3 <config_read+0x63>
cmp    $0xa,%cl
jne    11b0 <config_read+0x60>
movb   $0x0,(%rsp,%rax,1)
add    $0x1,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
mov    %rsp,%rdx
call   1040 <config_line@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11b3 <config_read+0x63>
jmp    1272 <config_read+0x122>
nopl   (%rax)
mov    %r14d,%edi
lea    0x400(%rsp),%rsi
mov    $0x400,%edx
call   1050 <read@plt>
test   %eax,%eax
jg     11a3 <config_read+0x53>
test   %ebx,%ebx
je     123a <config_read+0xea>
add    $0x1,%ebp
mov    %rsp,%rdx
mov    %r13,%rdi
mov    %ebp,%esi
call   1040 <config_line@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1277 <config_read+0x127>
xor    %eax,%eax
jmp    1277 <config_read+0x127>
mov    0x2d93(%rip),%rax
mov    (%rax),%edx
lea    0xdb2(%rip),%rdi
lea    0xe38(%rip),%rcx
mov    $0xaf,%esi
mov    %rbp,%r8
call   1060 <print_errlog@plt>
jmp    1272 <config_read+0x122>
lea    0xe45(%rip),%rdi
mov    %ebp,%esi
call   1030 <print_log@plt>
mov    $0xffffffff,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.config = type { i32 }
@O_RDONLY = global i32 0
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/heads/master/acp-c/config.c\00"
@errno = global i32 0
@.str.1 = [35 x i8] c"Cannot open configuration. path=%s\00"
@.str.2 = [54 x i8] c"A line in the configuration file is too long. line=%d\00"
define i32 @config_read(%struct.config* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.config*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
store %struct.config* %0, %struct.config** %4
store i8* %1, i8** %5
%13 = load i8*, i8** %5
%14 = load i32, i32* @O_RDONLY
%15 = call i32 @open(i8* %13, i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %2
br label %19
19: ; preds = %18
%20 = load i32, i32* @errno
%21 = load i8*, i8** %5
%22 = call i32 @print_errlog(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 175, i32 %20, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19
store i32 -1, i32* %3
br label %102
24: ; preds = %2
store i32 0, i32* %10
store i32 0, i32* %9
br label %25
25: ; preds = %87, %24
%26 = load i32, i32* %6
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%28 = call i32 @read(i32 %26, i8* %27, i32 1024)
store i32 %28, i32* %7
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %88
30: ; preds = %25
store i32 0, i32* %8
br label %31
31: ; preds = %84, %30
%32 = load i32, i32* %8
%33 = load i32, i32* %7
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %87
35: ; preds = %31
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = icmp uge i64 %37, 1024
br i1 %38, label %39, label %42
39: ; preds = %35
%40 = load i32, i32* %10
%41 = call i32 @print_log(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %40)
store i32 -1, i32* %3
br label %102
42: ; preds = %35
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %49
store i8 %46, i8* %50
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 13
br i1 %56, label %57, label %60
57: ; preds = %42
%58 = load i32, i32* %9
%59 = add nsw i32 %58, -1
store i32 %59, i32* %9
br label %83
60: ; preds = %42
%61 = load i32, i32* %8
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 %62
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 10
br i1 %66, label %67, label %82
67: ; preds = %60
%68 = load i32, i32* %9
%69 = add nsw i32 %68, -1
store i32 %69, i32* %9
%70 = load i32, i32* %9
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %71
store i8 0, i8* %72
%73 = load i32, i32* %10
%74 = add nsw i32 %73, 1
store i32 %74, i32* %10
store i32 0, i32* %9
%75 = load %struct.config*, %struct.config** %4
%76 = load i32, i32* %10
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%78 = call i64 @config_line(%struct.config* %75, i32 %76, i8* %77)
%79 = icmp ne i64 0, %78
br i1 %79, label %80, label %81
80: ; preds = %67
store i32 -1, i32* %3
br label %102
81: ; preds = %67
br label %82
82: ; preds = %81, %60
br label %83
83: ; preds = %82, %57
br label %84
84: ; preds = %83
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
store i32 %86, i32* %8
br label %31
87: ; preds = %31
br label %25
88: ; preds = %25
%89 = load i32, i32* %9
%90 = icmp sgt i32 %89, 0
br i1 %90, label %91, label %101
91: ; preds = %88
%92 = load i32, i32* %10
%93 = add nsw i32 %92, 1
store i32 %93, i32* %10
%94 = load %struct.config*, %struct.config** %4
%95 = load i32, i32* %10
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%97 = call i64 @config_line(%struct.config* %94, i32 %95, i8* %96)
%98 = icmp ne i64 0, %97
br i1 %98, label %99, label %100
99: ; preds = %91
store i32 -1, i32* %3
br label %102
100: ; preds = %91
br label %101
101: ; preds = %100, %88
store i32 0, i32* %3
br label %102
102: ; preds = %101, %99, %80, %39, %23
%103 = load i32, i32* %3
ret i32 %103
}

LLVM IR (-O2):
%struct.config = type { i32 }
@O_RDONLY = global i32 0
@.str = [141 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jam2in/arcus-misc/refs/heads/master/acp-c/config.c\00"
@errno = global i32 0
@.str.1 = [35 x i8] c"Cannot open configuration. path=%s\00"
@.str.2 = [54 x i8] c"A line in the configuration file is too long. line=%d\00"
define i32 @config_read(%struct.config* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %1, i32 %7)
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = call i32 @read(i32 %8, i8* %5, i32 1024)
%12 = icmp sgt i32 %11, 0
br i1 %12, label %19, label %55
13: ; preds = %2
%14 = load i32, i32* @errno
%15 = tail call i32 @print_errlog(i8* getelementptr inbounds ([141 x i8], [141 x i8]* @.str, i64 0, i64 0), i32 175, i32 %14, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %56
16: ; preds = %44
%17 = call i32 @read(i32 %8, i8* %5, i32 1024)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %49
19: ; preds = %10, %16
%20 = phi i32 [ %17, %16 ], [ %11, %10 ]
%21 = phi i32 [ %46, %16 ], [ 0, %10 ]
%22 = phi i32 [ %45, %16 ], [ 0, %10 ]
%23 = zext i32 %20 to i64
br label %24
24: ; preds = %19, %44
%25 = phi i64 [ 0, %19 ], [ %47, %44 ]
%26 = phi i32 [ %21, %19 ], [ %46, %44 ]
%27 = phi i32 [ %22, %19 ], [ %45, %44 ]
%28 = icmp ugt i32 %27, 1023
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 @print_log(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %56
31: ; preds = %24
%32 = zext i32 %27 to i64
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %25
%34 = load i8, i8* %33
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 %32
store i8 %34, i8* %35
%36 = icmp eq i8 %34, 13
br i1 %36, label %44, label %37
37: ; preds = %31
%38 = add nuw nsw i32 %27, 1
%39 = icmp eq i8 %34, 10
br i1 %39, label %40, label %44
40: ; preds = %37
store i8 0, i8* %35
%41 = add nsw i32 %26, 1
%42 = call i64 @config_line(%struct.config* %0, i32 %41, i8* %6)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %56
44: ; preds = %31, %40, %37
%45 = phi i32 [ 0, %40 ], [ %38, %37 ], [ %27, %31 ]
%46 = phi i32 [ %41, %40 ], [ %26, %37 ], [ %26, %31 ]
%47 = add nuw nsw i64 %25, 1
%48 = icmp eq i64 %47, %23
br i1 %48, label %16, label %24
49: ; preds = %16
%50 = icmp eq i32 %45, 0
br i1 %50, label %55, label %51
51: ; preds = %49
%52 = add nsw i32 %46, 1
%53 = call i64 @config_line(%struct.config* %0, i32 %52, i8* %6)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %10, %51, %49
br label %56
56: ; preds = %40, %51, %55, %29, %13
%57 = phi i32 [ -1, %13 ], [ -1, %29 ], [ 0, %55 ], [ -1, %51 ], [ -1, %40 ]
ret i32 %57
}