#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 slist_t {
  int dummy;
};
typedef int ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ add_to_slist(struct slist_t *, char *, int /*<<< orphan*/,
                                int);
scalar_t__ emalloc(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strdup(char const *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
char *strrchr(char const *, char);
char *strstr(char *, char *);
int read_adm_pkg(const char *path, struct slist_t *list) {
  FILE *fp = fopen(path, "r");
  int err = 0;
  size_t len = 0;
  ssize_t bytes;
  char *line = NULL;
  bool start = false;
  const char *bn;
  bn = strrchr(path, '/');
  bn = bn ? bn + 1 : path;
  if (!fp) {
    fprintf(stderr, "ERROR: fopen %s: %s\n", path, strerror(errno));
    return -1;
  }
  while ((bytes = getline(&line, &len, fp)) > 0) {
    char *c;
    char *real;
    if (!start) {
      if (!strcmp(line, "FILE LIST:\n"))
        start = true;
      continue;
    }
    if (!strcmp(line, "./\n"))
      continue;
    if (!strncmp(line, "install/", 8))
      continue;
    if (bytes < 2)
      continue;
    if (line[bytes - 2] == '/')
      continue;
    line[bytes - 1] = 0;
    if ((c = strstr(line, "/incoming/"))) {
      char *src = c + strlen("/incoming");
      memmove(c, src, strlen(src) + 1);
    }
    if ((c = strstr(line, ".new")) && strlen(c) == 4) {
      *c = '\0';
    }
    real = (char *)emalloc(1 + strlen(line) + 1);
    sprintf(real, "/%s", line);
    add_to_slist(list, real, strdup(bn), 1000);
  }
  free(line);
  if (ferror(fp)) {
    fprintf(stderr, "ERROR: getline %s: %s\n", path, strerror(errno));
    err |= 1;
  }
  fclose(fp);
  return err;
}


x86 assembly (clang, -O0):
<read_adm_pkg>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1283 <read_adm_pkg+0x73>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x70(%rbp)
jmp    128b <read_adm_pkg+0x7b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12e2 <read_adm_pkg+0xd2>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    %rax,%rcx
lea    0xd31(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    154d <read_adm_pkg+0x33d>
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x20(%rbp),%rdx
lea    -0x40(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   10f0 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jle    14d5 <read_adm_pkg+0x2c5>
cmpl   $0x0,-0x44(%rbp)
jne    1333 <read_adm_pkg+0x123>
mov    -0x40(%rbp),%rdi
lea    0xcfe(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    132e <read_adm_pkg+0x11e>
movl   $0x1,-0x44(%rbp)
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x40(%rbp),%rdi
lea    0xce5(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%eax
jne    1351 <read_adm_pkg+0x141>
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x40(%rbp),%rdi
lea    0xccb(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    1374 <read_adm_pkg+0x164>
jmp    12e7 <read_adm_pkg+0xd7>
cmpl   $0x2,-0x34(%rbp)
jge    1383 <read_adm_pkg+0x173>
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x40(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    13a2 <read_adm_pkg+0x192>
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x40(%rbp),%rax
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x40(%rbp),%rdi
lea    0xc72(%rip),%rsi
call   1130 <strstr@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1432 <read_adm_pkg+0x222>
mov    -0x58(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    0xc58(%rip),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x68(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x90(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   10d0 <memmove@plt>
mov    -0x40(%rbp),%rdi
lea    0xc08(%rip),%rsi
call   1130 <strstr@plt>
mov    %rax,-0x58(%rbp)
cmp    $0x0,%rax
je     1469 <read_adm_pkg+0x259>
mov    -0x58(%rbp),%rdi
call   1080 <strlen@plt>
cmp    $0x4,%eax
jne    1469 <read_adm_pkg+0x259>
mov    -0x58(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
add    $0x1,%edi
call   10c0 <emalloc@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x40(%rbp),%rdx
lea    0xbb8(%rip),%rsi
call   1100 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x60(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x50(%rbp),%rdi
call   1110 <strdup@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    %eax,%edx
mov    $0x3e8,%ecx
call   1050 <add_to_slist@plt>
jmp    12e7 <read_adm_pkg+0xd7>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ferror@plt>
cmp    $0x0,%rax
je     153e <read_adm_pkg+0x32e>
mov    0x2ae8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    0x2ac6(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
mov    -0xb4(%rbp),%edi
mov    -0xb0(%rbp),%rdx
mov    %rax,%rcx
lea    0xb1e(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x24(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_adm_pkg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,0x20(%rsp)
mov    %rdi,%rbp
lea    0xdd3(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,%r13
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1090 <strrchr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
cmove  %rbp,%rcx
mov    %rcx,0x18(%rsp)
test   %r13,%r13
je     142d <read_adm_pkg+0x21d>
mov    %rbp,0x10(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %r13,%rdx
call   10f0 <getline@plt>
test   %eax,%eax
jle    13e3 <read_adm_pkg+0x1d3>
mov    %eax,%r14d
xor    %r12d,%r12d
lea    0xd81(%rip),%rbx
lea    0x8(%rsp),%r15
jmp    12cd <read_adm_pkg+0xbd>
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10a0 <strcmp@plt>
xor    %r12d,%r12d
test   %eax,%eax
sete   %r12b
mov    %rsp,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   10f0 <getline@plt>
mov    %eax,%r14d
test   %eax,%eax
jle    13e3 <read_adm_pkg+0x1d3>
mov    (%rsp),%rbp
test   %r12d,%r12d
je     12a0 <read_adm_pkg+0x90>
mov    %rbp,%rdi
lea    0xd43(%rip),%rsi
call   10a0 <strcmp@plt>
mov    $0x1,%r12d
test   %eax,%eax
je     12b4 <read_adm_pkg+0xa4>
mov    %rbp,%rdi
lea    0xd2e(%rip),%rsi
mov    $0x8,%edx
call   1040 <strncmp@plt>
test   %eax,%eax
je     12b4 <read_adm_pkg+0xa4>
cmp    $0x2,%r14d
jb     12b4 <read_adm_pkg+0xa4>
mov    (%rsp),%rax
lea    -0x2(%r14),%ecx
cmpb   $0x2f,(%rax,%rcx,1)
je     12b4 <read_adm_pkg+0xa4>
add    $0xffffffff,%r14d
movb   $0x0,(%rax,%r14,1)
mov    (%rsp),%rbx
mov    %rbx,%rdi
lea    0xcfe(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     136b <read_adm_pkg+0x15b>
mov    %rax,%rbp
lea    0xcf5(%rip),%rdi
call   1080 <strlen@plt>
movslq %eax,%rbx
add    %rbp,%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
lea    0x1(%rax),%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10d0 <memmove@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
lea    0xcd0(%rip),%rsi
call   1130 <strstr@plt>
test   %rax,%rax
je     1392 <read_adm_pkg+0x182>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <strlen@plt>
cmp    $0x4,%eax
jne    1392 <read_adm_pkg+0x182>
movb   $0x0,(%rbx)
mov    (%rsp),%rdi
call   1080 <strlen@plt>
lea    0x2(%rax),%edi
call   10c0 <emalloc@plt>
mov    %rax,%rbx
mov    (%rsp),%rdx
mov    %rax,%rdi
lea    0xc96(%rip),%rsi
call   1100 <sprintf@plt>
mov    0x18(%rsp),%rdi
call   1110 <strdup@plt>
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
mov    $0x3e8,%ecx
call   1050 <add_to_slist@plt>
lea    0xc39(%rip),%rbx
jmp    12b4 <read_adm_pkg+0xa4>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1060 <ferror@plt>
test   %rax,%rax
je     145f <read_adm_pkg+0x24f>
mov    0x2be0(%rip),%rax
mov    (%rax),%ebx
mov    0x2bcf(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xc37(%rip),%rsi
mov    %ebx,%edi
mov    0x10(%rsp),%rdx
mov    %rax,%rcx
call   10b0 <fprintf@plt>
mov    $0x1,%ebp
jmp    1461 <read_adm_pkg+0x251>
mov    0x2bac(%rip),%rax
mov    (%rax),%ebx
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
call   1120 <strerror@plt>
lea    0xbb7(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %rax,%rcx
call   10b0 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1469 <read_adm_pkg+0x259>
xor    %ebp,%ebp
mov    %r13,%rdi
call   1070 <fclose@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.slist_t = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"ERROR: fopen %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"FILE LIST:\0A\00"
@.str.3 = [4 x i8] c"./\0A\00"
@.str.4 = [9 x i8] c"install/\00"
@.str.5 = [11 x i8] c"/incoming/\00"
@.str.6 = [10 x i8] c"/incoming\00"
@.str.7 = [5 x i8] c".new\00"
@.str.8 = [4 x i8] c"/%s\00"
@.str.9 = [23 x i8] c"ERROR: getline %s: %s\0A\00"
define i32 @read_adm_pkg(i8* %0, %struct.slist_t* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.slist_t*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i8* %0, i8** %4
store %struct.slist_t* %1, %struct.slist_t** %5
%16 = load i8*, i8** %4
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
store i32 0, i32* %7
store i64 0, i64* %8
store i8* null, i8** %10
store i32 0, i32* %11
%18 = load i8*, i8** %4
%19 = call i8* @strrchr(i8* %18, i8 signext 47)
store i8* %19, i8** %12
%20 = load i8*, i8** %12
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load i8*, i8** %12
%24 = getelementptr inbounds i8, i8* %23, i64 1
br label %27
25: ; preds = %2
%26 = load i8*, i8** %4
br label %27
27: ; preds = %25, %22
%28 = phi i8* [ %24, %22 ], [ %26, %25 ]
store i8* %28, i8** %12
%29 = load i32*, i32** %6
%30 = icmp ne i32* %29, null
br i1 %30, label %37, label %31
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = load i8*, i8** %4
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %35)
store i32 -1, i32* %3
br label %138
37: ; preds = %27
br label %38
38: ; preds = %105, %74, %64, %60, %55, %50, %37
%39 = load i32*, i32** %6
%40 = call i32 @getline(i8** %10, i64* %8, i32* %39)
store i32 %40, i32* %9
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %120
42: ; preds = %38
%43 = load i32, i32* %11
%44 = icmp ne i32 %43, 0
br i1 %44, label %51, label %45
45: ; preds = %42
%46 = load i8*, i8** %10
%47 = call i32 @strcmp(i8* %46, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %45
store i32 1, i32* %11
br label %50
50: ; preds = %49, %45
br label %38
51: ; preds = %42
%52 = load i8*, i8** %10
%53 = call i32 @strcmp(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%54 = icmp ne i32 %53, 0
br i1 %54, label %56, label %55
55: ; preds = %51
br label %38
56: ; preds = %51
%57 = load i8*, i8** %10
%58 = call i32 @strncmp(i8* %57, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%59 = icmp ne i32 %58, 0
br i1 %59, label %61, label %60
60: ; preds = %56
br label %38
61: ; preds = %56
%62 = load i32, i32* %9
%63 = icmp slt i32 %62, 2
br i1 %63, label %64, label %65
64: ; preds = %61
br label %38
65: ; preds = %61
%66 = load i8*, i8** %10
%67 = load i32, i32* %9
%68 = sub nsw i32 %67, 2
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %66, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 47
br i1 %73, label %74, label %75
74: ; preds = %65
br label %38
75: ; preds = %65
%76 = load i8*, i8** %10
%77 = load i32, i32* %9
%78 = sub nsw i32 %77, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %76, i64 %79
store i8 0, i8* %80
%81 = load i8*, i8** %10
%82 = call i8* @strstr(i8* %81, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
store i8* %82, i8** %13
%83 = icmp ne i8* %82, null
br i1 %83, label %84, label %95
84: ; preds = %75
%85 = load i8*, i8** %13
%86 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
store i8* %88, i8** %15
%89 = load i8*, i8** %13
%90 = load i8*, i8** %15
%91 = load i8*, i8** %15
%92 = call i32 @strlen(i8* %91)
%93 = add nsw i32 %92, 1
%94 = call i32 @memmove(i8* %89, i8* %90, i32 %93)
br label %95
95: ; preds = %84, %75
%96 = load i8*, i8** %10
%97 = call i8* @strstr(i8* %96, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
store i8* %97, i8** %13
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %105
99: ; preds = %95
%100 = load i8*, i8** %13
%101 = call i32 @strlen(i8* %100)
%102 = icmp eq i32 %101, 4
br i1 %102, label %103, label %105
103: ; preds = %99
%104 = load i8*, i8** %13
store i8 0, i8* %104
br label %105
105: ; preds = %103, %99, %95
%106 = load i8*, i8** %10
%107 = call i32 @strlen(i8* %106)
%108 = add nsw i32 1, %107
%109 = add nsw i32 %108, 1
%110 = call i64 @emalloc(i32 %109)
%111 = inttoptr i64 %110 to i8*
store i8* %111, i8** %14
%112 = load i8*, i8** %14
%113 = load i8*, i8** %10
%114 = call i32 @sprintf(i8* %112, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %113)
%115 = load %struct.slist_t*, %struct.slist_t** %5
%116 = load i8*, i8** %14
%117 = load i8*, i8** %12
%118 = call i32 @strdup(i8* %117)
%119 = call i32 @add_to_slist(%struct.slist_t* %115, i8* %116, i32 %118, i32 1000)
br label %38
120: ; preds = %38
%121 = load i8*, i8** %10
%122 = call i32 @free(i8* %121)
%123 = load i32*, i32** %6
%124 = call i64 @ferror(i32* %123)
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %134
126: ; preds = %120
%127 = load i32, i32* @stderr
%128 = load i8*, i8** %4
%129 = load i32, i32* @errno
%130 = call i8* @strerror(i32 %129)
%131 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %128, i8* %130)
%132 = load i32, i32* %7
%133 = or i32 %132, 1
store i32 %133, i32* %7
br label %134
134: ; preds = %126, %120
%135 = load i32*, i32** %6
%136 = call i32 @fclose(i32* %135)
%137 = load i32, i32* %7
store i32 %137, i32* %3
br label %138
138: ; preds = %134, %31
%139 = load i32, i32* %3
ret i32 %139
}

LLVM IR (-O2):
%struct.slist_t = type { i32 }
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [21 x i8] c"ERROR: fopen %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [12 x i8] c"FILE LIST:\0A\00"
@.str.3 = [4 x i8] c"./\0A\00"
@.str.4 = [9 x i8] c"install/\00"
@.str.5 = [11 x i8] c"/incoming/\00"
@.str.6 = [10 x i8] c"/incoming\00"
@.str.7 = [5 x i8] c".new\00"
@.str.8 = [4 x i8] c"/%s\00"
@.str.9 = [23 x i8] c"ERROR: getline %s: %s\0A\00"
define i32 @read_adm_pkg(i8* %0, %struct.slist_t* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%9 = icmp eq i8* %8, null
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = select i1 %9, i8* %0, i8* %10
%12 = icmp eq i32* %5, null
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = call i32 @getline(i8** %4, i64* %3, i32* %5)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %21, label %82
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %19)
br label %95
21: ; preds = %13, %78
%22 = phi i32 [ %80, %78 ], [ %14, %13 ]
%23 = phi i32 [ %79, %78 ], [ 0, %13 ]
%24 = icmp eq i32 %23, 0
%25 = load i8*, i8** %4
br i1 %24, label %26, label %30
26: ; preds = %21
%27 = call i32 @strcmp(i8* dereferenceable(1) %25, i8* dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
br label %78
30: ; preds = %21
%31 = call i32 @strcmp(i8* dereferenceable(1) %25, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %78, label %33
33: ; preds = %30
%34 = call i32 @strncmp(i8* %25, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%35 = icmp eq i32 %34, 0
%36 = icmp ult i32 %22, 2
%37 = select i1 %35, i1 true, i1 %36
br i1 %37, label %78, label %38
38: ; preds = %33
%39 = load i8*, i8** %4
%40 = add nsw i32 %22, -2
%41 = zext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 47
br i1 %44, label %78, label %45
45: ; preds = %38
%46 = add nsw i32 %22, -1
%47 = zext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %39, i64 %47
store i8 0, i8* %48
%49 = load i8*, i8** %4
%50 = call i8* @strstr(i8* dereferenceable(1) %49, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp eq i8* %50, null
br i1 %51, label %60, label %52
52: ; preds = %45
%53 = call i32 @strlen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %50, i64 %54
%56 = call i32 @strlen(i8* %55)
%57 = add nsw i32 %56, 1
%58 = call i32 @memmove(i8* %50, i8* %55, i32 %57)
%59 = load i8*, i8** %4
br label %60
60: ; preds = %52, %45
%61 = phi i8* [ %59, %52 ], [ %49, %45 ]
%62 = call i8* @strstr(i8* dereferenceable(1) %61, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%63 = icmp eq i8* %62, null
br i1 %63, label %68, label %64
64: ; preds = %60
%65 = call i32 @strlen(i8* %62)
%66 = icmp eq i32 %65, 4
br i1 %66, label %67, label %68
67: ; preds = %64
store i8 0, i8* %62
br label %68
68: ; preds = %67, %64, %60
%69 = load i8*, i8** %4
%70 = call i32 @strlen(i8* %69)
%71 = add nsw i32 %70, 2
%72 = call i64 @emalloc(i32 %71)
%73 = inttoptr i64 %72 to i8*
%74 = load i8*, i8** %4
%75 = call i32 @sprintf(i8* dereferenceable(1) %73, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* %74)
%76 = call i32 @strdup(i8* %11)
%77 = call i32 @add_to_slist(%struct.slist_t* %1, i8* %73, i32 %76, i32 1000)
br label %78
78: ; preds = %38, %33, %30, %68, %26
%79 = phi i32 [ 1, %68 ], [ %29, %26 ], [ 1, %30 ], [ 1, %33 ], [ 1, %38 ]
%80 = call i32 @getline(i8** %4, i64* %3, i32* %5)
%81 = icmp sgt i32 %80, 0
br i1 %81, label %21, label %82
82: ; preds = %78, %13
%83 = load i8*, i8** %4
%84 = call i32 @free(i8* %83)
%85 = call i64 @ferror(i32* %5)
%86 = icmp eq i64 %85, 0
br i1 %86, label %92, label %87
87: ; preds = %82
%88 = load i32, i32* @stderr
%89 = load i32, i32* @errno
%90 = call i8* @strerror(i32 %89)
%91 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %0, i8* %90)
br label %92
92: ; preds = %87, %82
%93 = phi i32 [ 1, %87 ], [ 0, %82 ]
%94 = call i32 @fclose(i32* %5)
br label %95
95: ; preds = %92, %16
%96 = phi i32 [ %93, %92 ], [ -1, %16 ]
ret i32 %96
}