#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 */

/* Variables and functions */
size_t INT_MAX;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
scalar_t__ isspace(char);
char *malloc(size_t);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
size_t read(int, char *, size_t);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcasecmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strncasecmp(char *, char *, int);
size_t testSafe(char *, int);
int userCtl(char *file) {
  char *buf;
  char *contents = NULL;
  char *chptr = NULL;
  char *next = NULL;
  int fd = -1, retval = 0;
  size_t size = 0;
  if ((fd = open(file, O_RDONLY)) == -1) {
    fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno));
    exit(1);
  }
  size = testSafe(file, fd);
  if (size > INT_MAX) {
    fprintf(stderr, "file %s is too big\n", file);
    exit(1);
  }
  buf = contents = malloc(size + 2);
  if (contents == NULL) {
    fprintf(stderr, "failed to allocate memory\n");
    exit(1);
  }
  if (read(fd, contents, size) != size) {
    perror("error reading device configuration");
    exit(1);
  }
  close(fd);
  contents[size] = '\n';
  contents[size + 1] = '\0';
  while (*contents) {
    chptr = contents;
    while (*chptr != '\n')
      chptr++;
    next = chptr + 1;
    while (chptr >= contents && isspace(*chptr))
      chptr--;
    *(++chptr) = '\0';
    if (!strncasecmp(contents, "USERCTL=", 8)) {
      contents += 8;
      if ((contents[0] == '"' && contents[strlen(contents) - 1] == '"') ||
          (contents[0] == '\'' && contents[strlen(contents) - 1] == '\'')) {
        contents++;
        contents[strlen(contents) - 1] = '\0';
      }
      if (!strcasecmp(contents, "yes") || !strcasecmp(contents, "true"))
        retval = 1;
      else
        retval = -1;
      break;
    }
    contents = next;
  }
  free(buf);
  return retval;
}


x86 assembly (clang, -O0):
<userCtl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    127c <userCtl+0x9c>
mov    0x2d91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rdx
mov    %rax,%rcx
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   10c0 <testSafe@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    0x2d49(%rip),%rcx
cmp    (%rcx),%rax
jbe    12c5 <userCtl+0xe5>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd63(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x38(%rbp),%rdi
add    $0x2,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1306 <userCtl+0x126>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xd36(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1080 <read@plt>
cmp    -0x38(%rbp),%rax
je     1336 <userCtl+0x156>
lea    0xd1f(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x0,0x1(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1518 <userCtl+0x338>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     138d <userCtl+0x1ad>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    136c <userCtl+0x18c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x45(%rbp)
jb     13c2 <userCtl+0x1e2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    13d2 <userCtl+0x1f2>
jmp    13e3 <userCtl+0x203>
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
jmp    1399 <userCtl+0x1b9>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,0x1(%rax)
mov    -0x18(%rbp),%rdi
lea    0xc68(%rip),%rsi
mov    $0x8,%edx
call   10b0 <strncasecmp@plt>
cmp    $0x0,%eax
jne    150b <userCtl+0x32b>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    145a <userCtl+0x27a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x22,%eax
je     1494 <userCtl+0x2b4>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x27,%eax
jne    14c1 <userCtl+0x2e1>
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x27,%eax
jne    14c1 <userCtl+0x2e1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
lea    0xba6(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
je     14f3 <userCtl+0x313>
mov    -0x18(%rbp),%rdi
lea    0xb91(%rip),%rsi
call   1040 <strcasecmp@plt>
cmp    $0x0,%eax
jne    14ff <userCtl+0x31f>
movl   $0x1,-0x30(%rbp)
jmp    1506 <userCtl+0x326>
movl   $0xffffffff,-0x30(%rbp)
jmp    1518 <userCtl+0x338>
mov    -0x28(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1357 <userCtl+0x177>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userCtl>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2df6(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1394 <userCtl+0x1b4>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
call   10c0 <testSafe@plt>
mov    %rax,%rbx
mov    0x2dc8(%rip),%rax
cmp    (%rax),%rbx
ja     13cb <userCtl+0x1eb>
lea    0x2(%rbx),%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     13ef <userCtl+0x20f>
mov    %rax,%r14
mov    %ebp,%edi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1080 <read@plt>
cmp    %rbx,%rax
jne    1410 <userCtl+0x230>
mov    %ebp,%edi
call   1060 <close@plt>
movw   $0xa,(%r14,%rbx,1)
lea    0xe08(%rip),%r15
mov    %r14,%rbx
jmp    1288 <userCtl+0xa8>
cs nopw 0x0(%rax,%rax,1)
movb   $0x0,0x1(%rbp)
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x8,%edx
call   10b0 <strncasecmp@plt>
test   %eax,%eax
je     12ff <userCtl+0x11f>
mov    %rbx,%r12
mov    (%rbx),%al
cmp    $0xa,%al
je     12c0 <userCtl+0xe0>
test   %al,%al
je     1378 <userCtl+0x198>
lea    0x1(%r12),%rbx
xchg   %ax,%ax
cmpb   $0xa,(%rbx)
lea    0x1(%rbx),%rbx
jne    12a0 <userCtl+0xc0>
lea    -0x1(%rbx),%rbp
cmp    %r12,%rbp
jb     1270 <userCtl+0x90>
jmp    12c8 <userCtl+0xe8>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%r12),%rbx
mov    %r12,%rbp
mov    $0xa,%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     1270 <userCtl+0x90>
add    $0xffffffffffffffff,%rbp
mov    %rbp,%rcx
xchg   %ax,%ax
mov    %rcx,%rbp
cmp    %r12,%rcx
jb     1270 <userCtl+0x90>
movsbl 0x0(%rbp),%edi
call   1070 <isspace@plt>
lea    -0x1(%rbp),%rcx
test   %rax,%rax
jne    12e0 <userCtl+0x100>
jmp    1270 <userCtl+0x90>
lea    0x8(%r12),%r15
mov    0x8(%r12),%al
cmp    $0x22,%al
jne    1322 <userCtl+0x142>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x22,-0x1(%rax,%r15,1)
je     1338 <userCtl+0x158>
mov    (%r15),%al
cmp    $0x27,%al
jne    134d <userCtl+0x16d>
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x27,-0x1(%rax,%r15,1)
jne    134d <userCtl+0x16d>
lea    0x9(%r12),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,0x8(%rax,%r12,1)
lea    0xd1e(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcasecmp@plt>
test   %eax,%eax
je     137c <userCtl+0x19c>
lea    0xd0f(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcasecmp@plt>
neg    %eax
sbb    %ebx,%ebx
or     $0x1,%ebx
jmp    1381 <userCtl+0x1a1>
xor    %ebx,%ebx
jmp    1381 <userCtl+0x1a1>
mov    $0x1,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c35(%rip),%rax
mov    (%rax),%ebx
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
lea    0xc4e(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
lea    0xc3c(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
lea    0xc2c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xc2f(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"failed to open %s: %s\0A\00"
@errno = global i32 0
@INT_MAX = global i64 0
@.str.1 = [20 x i8] c"file %s is too big\0A\00"
@.str.2 = [27 x i8] c"failed to allocate memory\0A\00"
@.str.3 = [35 x i8] c"error reading device configuration\00"
@.str.4 = [9 x i8] c"USERCTL=\00"
@.str.5 = [4 x i8] c"yes\00"
@.str.6 = [5 x i8] c"true\00"
define i32 @userCtl(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
store i8* %0, i8** %2
store i8* null, i8** %4
store i8* null, i8** %5
store i8* null, i8** %6
store i32 -1, i32* %7
store i32 0, i32* %8
store i64 0, i64* %9
%10 = load i8*, i8** %2
%11 = load i32, i32* @O_RDONLY
%12 = call i32 @open(i8* %10, i32 %11)
store i32 %12, i32* %7
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %21
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %2
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %1
%22 = load i8*, i8** %2
%23 = load i32, i32* %7
%24 = call i64 @testSafe(i8* %22, i32 %23)
store i64 %24, i64* %9
%25 = load i64, i64* %9
%26 = load i64, i64* @INT_MAX
%27 = icmp ugt i64 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %2
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %21
%34 = load i64, i64* %9
%35 = add i64 %34, 2
%36 = call i8* @malloc(i64 %35)
store i8* %36, i8** %4
store i8* %36, i8** %3
%37 = load i8*, i8** %4
%38 = icmp eq i8* %37, null
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %33
%44 = load i32, i32* %7
%45 = load i8*, i8** %4
%46 = load i64, i64* %9
%47 = call i64 @read(i32 %44, i8* %45, i64 %46)
%48 = load i64, i64* %9
%49 = icmp ne i64 %47, %48
br i1 %49, label %50, label %53
50: ; preds = %43
%51 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %43
%54 = load i32, i32* %7
%55 = call i32 @close(i32 %54)
%56 = load i8*, i8** %4
%57 = load i64, i64* %9
%58 = getelementptr inbounds i8, i8* %56, i64 %57
store i8 10, i8* %58
%59 = load i8*, i8** %4
%60 = load i64, i64* %9
%61 = add i64 %60, 1
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 0, i8* %62
br label %63
63: ; preds = %154, %53
%64 = load i8*, i8** %4
%65 = load i8, i8* %64
%66 = icmp ne i8 %65, 0
br i1 %66, label %67, label %156
67: ; preds = %63
%68 = load i8*, i8** %4
store i8* %68, i8** %5
br label %69
69: ; preds = %74, %67
%70 = load i8*, i8** %5
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 10
br i1 %73, label %74, label %77
74: ; preds = %69
%75 = load i8*, i8** %5
%76 = getelementptr inbounds i8, i8* %75, i32 1
store i8* %76, i8** %5
br label %69
77: ; preds = %69
%78 = load i8*, i8** %5
%79 = getelementptr inbounds i8, i8* %78, i64 1
store i8* %79, i8** %6
br label %80
80: ; preds = %91, %77
%81 = load i8*, i8** %5
%82 = load i8*, i8** %4
%83 = icmp uge i8* %81, %82
br i1 %83, label %84, label %89
84: ; preds = %80
%85 = load i8*, i8** %5
%86 = load i8, i8* %85
%87 = call i64 @isspace(i8 signext %86)
%88 = icmp ne i64 %87, 0
br label %89
89: ; preds = %84, %80
%90 = phi i1 [ false, %80 ], [ %88, %84 ]
br i1 %90, label %91, label %94
91: ; preds = %89
%92 = load i8*, i8** %5
%93 = getelementptr inbounds i8, i8* %92, i32 -1
store i8* %93, i8** %5
br label %80
94: ; preds = %89
%95 = load i8*, i8** %5
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %5
store i8 0, i8* %96
%97 = load i8*, i8** %4
%98 = call i32 @strncasecmp(i8* %97, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%99 = icmp ne i32 %98, 0
br i1 %99, label %154, label %100
100: ; preds = %94
%101 = load i8*, i8** %4
%102 = getelementptr inbounds i8, i8* %101, i64 8
store i8* %102, i8** %4
%103 = load i8*, i8** %4
%104 = getelementptr inbounds i8, i8* %103, i64 0
%105 = load i8, i8* %104
%106 = sext i8 %105 to i32
%107 = icmp eq i32 %106, 34
br i1 %107, label %108, label %118
108: ; preds = %100
%109 = load i8*, i8** %4
%110 = load i8*, i8** %4
%111 = call i32 @strlen(i8* %110)
%112 = sub nsw i32 %111, 1
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %109, i64 %113
%115 = load i8, i8* %114
%116 = sext i8 %115 to i32
%117 = icmp eq i32 %116, 34
br i1 %117, label %134, label %118
118: ; preds = %108, %100
%119 = load i8*, i8** %4
%120 = getelementptr inbounds i8, i8* %119, i64 0
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp eq i32 %122, 39
br i1 %123, label %124, label %143
124: ; preds = %118
%125 = load i8*, i8** %4
%126 = load i8*, i8** %4
%127 = call i32 @strlen(i8* %126)
%128 = sub nsw i32 %127, 1
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8, i8* %125, i64 %129
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp eq i32 %132, 39
br i1 %133, label %134, label %143
134: ; preds = %124, %108
%135 = load i8*, i8** %4
%136 = getelementptr inbounds i8, i8* %135, i32 1
store i8* %136, i8** %4
%137 = load i8*, i8** %4
%138 = load i8*, i8** %4
%139 = call i32 @strlen(i8* %138)
%140 = sub nsw i32 %139, 1
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i8, i8* %137, i64 %141
store i8 0, i8* %142
br label %143
143: ; preds = %134, %124, %118
%144 = load i8*, i8** %4
%145 = call i32 @strcasecmp(i8* %144, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %151
147: ; preds = %143
%148 = load i8*, i8** %4
%149 = call i32 @strcasecmp(i8* %148, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%150 = icmp ne i32 %149, 0
br i1 %150, label %152, label %151
151: ; preds = %147, %143
store i32 1, i32* %8
br label %153
152: ; preds = %147
store i32 -1, i32* %8
br label %153
153: ; preds = %152, %151
br label %156
154: ; preds = %94
%155 = load i8*, i8** %6
store i8* %155, i8** %4
br label %63
156: ; preds = %153, %63
%157 = load i8*, i8** %3
%158 = call i32 @free(i8* %157)
%159 = load i32, i32* %8
ret i32 %159
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"failed to open %s: %s\0A\00"
@errno = global i32 0
@INT_MAX = global i64 0
@.str.1 = [20 x i8] c"file %s is too big\0A\00"
@.str.2 = [27 x i8] c"failed to allocate memory\0A\00"
@.str.3 = [35 x i8] c"error reading device configuration\00"
@.str.4 = [9 x i8] c"USERCTL=\00"
@.str.5 = [4 x i8] c"yes\00"
@.str.6 = [5 x i8] c"true\00"
define i32 @userCtl(i8* %0) {
%2 = load i32, i32* @O_RDONLY
%3 = tail call i32 @open(i8* %0, i32 %2)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %1
%12 = tail call i64 @testSafe(i8* %0, i32 %3)
%13 = load i64, i64* @INT_MAX
%14 = icmp ugt i64 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = add i64 %12, 2
%21 = tail call i8* @malloc(i64 %20)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load i32, i32* @stderr
%25 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%26 = tail call i32 @exit(i32 1)
unreachable
27: ; preds = %19
%28 = tail call i64 @read(i32 %3, i8* %21, i64 %12)
%29 = icmp eq i64 %28, %12
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = tail call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @exit(i32 1)
unreachable
33: ; preds = %27
%34 = tail call i32 @close(i32 %3)
%35 = getelementptr inbounds i8, i8* %21, i64 %12
store i8 10, i8* %35
%36 = add i64 %12, 1
%37 = getelementptr inbounds i8, i8* %21, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %64, %33
%39 = phi i8* [ %21, %33 ], [ %65, %64 ]
%40 = load i8, i8* %39
switch i8 %40, label %43 [
i8 0, label %107
i8 10, label %41
]
41: ; preds = %38
%42 = getelementptr inbounds i8, i8* %39, i64 1
br label %51
43: ; preds = %38, %43
%44 = phi i8* [ %45, %43 ], [ %39, %38 ]
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 10
br i1 %47, label %48, label %43
48: ; preds = %43
%49 = getelementptr inbounds i8, i8* %44, i64 2
%50 = icmp ult i8* %45, %39
br i1 %50, label %64, label %51
51: ; preds = %41, %48
%52 = phi i8* [ %42, %41 ], [ %49, %48 ]
%53 = phi i8* [ %39, %41 ], [ %45, %48 ]
%54 = tail call i64 @isspace(i8 signext 10)
%55 = icmp eq i64 %54, 0
br i1 %55, label %64, label %56
56: ; preds = %51, %60
%57 = phi i8* [ %58, %60 ], [ %53, %51 ]
%58 = getelementptr inbounds i8, i8* %57, i64 -1
%59 = icmp ult i8* %58, %39
br i1 %59, label %64, label %60
60: ; preds = %56
%61 = load i8, i8* %58
%62 = tail call i64 @isspace(i8 signext %61)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %56
64: ; preds = %56, %60, %51, %48
%65 = phi i8* [ %49, %48 ], [ %52, %51 ], [ %52, %60 ], [ %52, %56 ]
%66 = phi i8* [ %45, %48 ], [ %53, %51 ], [ %58, %60 ], [ %58, %56 ]
%67 = getelementptr inbounds i8, i8* %66, i64 1
store i8 0, i8* %67
%68 = tail call i32 @strncasecmp(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %38
70: ; preds = %64
%71 = getelementptr inbounds i8, i8* %39, i64 8
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 34
br i1 %73, label %74, label %83
74: ; preds = %70
%75 = tail call i32 @strlen(i8* %71)
%76 = add nsw i32 %75, -1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %71, i64 %77
%79 = load i8, i8* %78
%80 = icmp eq i8 %79, 34
br i1 %80, label %93, label %81
81: ; preds = %74
%82 = load i8, i8* %71
br label %83
83: ; preds = %81, %70
%84 = phi i8 [ %82, %81 ], [ %72, %70 ]
%85 = icmp eq i8 %84, 39
br i1 %85, label %86, label %99
86: ; preds = %83
%87 = tail call i32 @strlen(i8* %71)
%88 = add nsw i32 %87, -1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %71, i64 %89
%91 = load i8, i8* %90
%92 = icmp eq i8 %91, 39
br i1 %92, label %93, label %99
93: ; preds = %86, %74
%94 = getelementptr inbounds i8, i8* %39, i64 9
%95 = tail call i32 @strlen(i8* %94)
%96 = add nsw i32 %95, -1
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %94, i64 %97
store i8 0, i8* %98
br label %99
99: ; preds = %93, %86, %83
%100 = phi i8* [ %94, %93 ], [ %71, %86 ], [ %71, %83 ]
%101 = tail call i32 @strcasecmp(i8* %100, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%102 = icmp eq i32 %101, 0
br i1 %102, label %107, label %103
103: ; preds = %99
%104 = tail call i32 @strcasecmp(i8* %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%105 = icmp eq i32 %104, 0
%106 = select i1 %105, i32 1, i32 -1
br label %107
107: ; preds = %38, %103, %99
%108 = phi i32 [ 1, %99 ], [ %106, %103 ], [ 0, %38 ]
%109 = tail call i32 @free(i8* %21)
ret i32 %108
}