#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*/ dump;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fw_env_close();
scalar_t__ fw_env_open();
scalar_t__ fw_env_write(char *, char *);
char *fw_string_blank(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int strlen(char *);
int fw_parse_script(char *fname) {
  FILE *fp;
  char dump[1024];
  char *name;
  char *val;
  int lineno = 0;
  int len;
  int ret = 0;
  if (fw_env_open()) {
    fprintf(stderr, "Error: environment not initialized\n");
    return -1;
  }
  if (strcmp(fname, "-") == 0)
    fp = stdin;
  else {
    fp = fopen(fname, "r");
    if (fp == NULL) {
      fprintf(stderr, "I cannot open %s for reading\n", fname);
      return -1;
    }
  }
  while (fgets(dump, sizeof(dump), fp)) {
    lineno++;
    len = strlen(dump);
    if (dump[len - 1] != '\n') {
      fprintf(stderr, "Line %d not corrected terminated or too long\n", lineno);
      ret = -1;
      break;
    }
    while (len > 0 && (dump[len - 1] == '\n' || dump[len - 1] == '\r')) {
      dump[len - 1] = '\0';
      len--;
    }
    if ((len == 0) || dump[0] == '#')
      continue;
    name = fw_string_blank(dump, 1);
    if (!name)
      continue;
    val = fw_string_blank(name, 0);
    len = strlen(name);
    if (val) {
      *val++ = '\0';
      if ((val - name) < len)
        val = fw_string_blank(val, 1);
      else
        val = NULL;
    }
    if (fw_env_write(name, val)) {
      fprintf(stderr, "fw_env_write returns with error : %s\n",
              strerror(errno));
      ret = -1;
      break;
    }
  }
  if (strcmp(fname, "-") != 0)
    fclose(fp);
  ret |= fw_env_close();
  return ret;
}


x86 assembly (clang, -O0):
<fw_parse_script>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x434(%rbp)
movl   $0x0,-0x43c(%rbp)
mov    $0x0,%al
call   1030 <fw_env_open@plt>
cmp    $0x0,%rax
je     1207 <fw_parse_script+0x57>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    153b <fw_parse_script+0x38b>
mov    -0x10(%rbp),%rdi
lea    0xe12(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1234 <fw_parse_script+0x84>
mov    0x2dc0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    127f <fw_parse_script+0xcf>
mov    -0x10(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    127a <fw_parse_script+0xca>
mov    0x2d7e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    153b <fw_parse_script+0x38b>
jmp    127f <fw_parse_script+0xcf>
jmp    1284 <fw_parse_script+0xd4>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     14fc <fw_parse_script+0x34c>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
lea    -0x420(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x438(%rbp)
mov    -0x438(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
je     130c <fw_parse_script+0x15c>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
mov    -0x434(%rbp),%edx
lea    0xd50(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x43c(%rbp)
ff ff ff
jmp    14fc <fw_parse_script+0x34c>
jmp    1311 <fw_parse_script+0x161>
xor    %eax,%eax
cmpl   $0x0,-0x438(%rbp)
mov    %al,-0x43d(%rbp)
jle    1375 <fw_parse_script+0x1c5>
mov    -0x438(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x43e(%rbp)
je     1369 <fw_parse_script+0x1b9>
mov    -0x438(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
sete   %al
mov    %al,-0x43e(%rbp)
mov    -0x43e(%rbp),%al
mov    %al,-0x43d(%rbp)
mov    -0x43d(%rbp),%al
test   $0x1,%al
jne    1388 <fw_parse_script+0x1d8>
jmp    13af <fw_parse_script+0x1ff>
mov    -0x438(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x438(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x438(%rbp)
jmp    1311 <fw_parse_script+0x161>
cmpl   $0x0,-0x438(%rbp)
je     13cc <fw_parse_script+0x21c>
movsbl -0x420(%rbp),%eax
cmp    $0x23,%eax
jne    13d1 <fw_parse_script+0x221>
jmp    1284 <fw_parse_script+0xd4>
lea    -0x420(%rbp),%rdi
mov    $0x1,%esi
call   1040 <fw_string_blank@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jne    13fc <fw_parse_script+0x24c>
jmp    1284 <fw_parse_script+0xd4>
mov    -0x428(%rbp),%rdi
xor    %esi,%esi
call   1040 <fw_string_blank@plt>
mov    %rax,-0x430(%rbp)
mov    -0x428(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x438(%rbp)
cmpq   $0x0,-0x430(%rbp)
je     1497 <fw_parse_script+0x2e7>
mov    -0x430(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x430(%rbp)
movb   $0x0,(%rax)
mov    -0x430(%rbp),%rax
mov    -0x428(%rbp),%rcx
sub    %rcx,%rax
movslq -0x438(%rbp),%rcx
cmp    %rcx,%rax
jge    1487 <fw_parse_script+0x2d7>
mov    -0x430(%rbp),%rdi
mov    $0x1,%esi
call   1040 <fw_string_blank@plt>
mov    %rax,-0x430(%rbp)
jmp    1492 <fw_parse_script+0x2e2>
movq   $0x0,-0x430(%rbp)
jmp    1497 <fw_parse_script+0x2e7>
mov    -0x428(%rbp),%rdi
mov    -0x430(%rbp),%rsi
call   10b0 <fw_env_write@plt>
cmp    $0x0,%rax
je     14f7 <fw_parse_script+0x347>
mov    0x2b1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x444(%rbp)
mov    0x2b06(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x444(%rbp),%edi
mov    %rax,%rdx
lea    0xb93(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
movl   $0xffffffff,-0x43c(%rbp)
ff ff ff
jmp    14fc <fw_parse_script+0x34c>
jmp    1284 <fw_parse_script+0xd4>
mov    -0x10(%rbp),%rdi
lea    0xb1d(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     151f <fw_parse_script+0x36f>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x0,%al
call   10a0 <fw_env_close@plt>
or     -0x43c(%rbp),%eax
mov    %eax,-0x43c(%rbp)
mov    -0x43c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fw_parse_script>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%rbp
xor    %eax,%eax
call   1030 <fw_env_open@plt>
test   %rax,%rax
je     11f1 <fw_parse_script+0x41>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13ba <fw_parse_script+0x20a>
lea    0xe2c(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1240 <fw_parse_script+0x90>
lea    0xe1a(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    124a <fw_parse_script+0x9a>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    13ba <fw_parse_script+0x20a>
mov    0x2da1(%rip),%rax
mov    (%rax),%r15
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1369 <fw_parse_script+0x1b9>
mov    %rbp,0x8(%rsp)
xor    %r14d,%r14d
jmp    12a9 <fw_parse_script+0xf9>
xor    %esi,%esi
mov    %r13,%rdi
call   10b0 <fw_env_write@plt>
test   %rax,%rax
jne    13cc <fw_parse_script+0x21c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     138e <fw_parse_script+0x1de>
add    $0x1,%r14d
mov    %r12,%rdi
call   1060 <strlen@plt>
movslq %eax,%rcx
cmpb   $0xa,-0x1(%rcx,%r12,1)
jne    136d <fw_parse_script+0x1bd>
test   %eax,%eax
jle    12f7 <fw_parse_script+0x147>
mov    %eax,%eax
jmp    12e2 <fw_parse_script+0x132>
nopl   0x0(%rax)
movb   $0x0,0x10(%rsp,%rdx,1)
lea    0x1(%rcx),%rdx
mov    %rcx,%rax
cmp    $0x1,%rdx
jbe    1290 <fw_parse_script+0xe0>
lea    -0x1(%rax),%rcx
mov    %ecx,%edx
movzbl 0x10(%rsp,%rdx,1),%ebx
cmp    $0xd,%bl
je     12d0 <fw_parse_script+0x120>
cmp    $0xa,%bl
je     12d0 <fw_parse_script+0x120>
test   %eax,%eax
je     1290 <fw_parse_script+0xe0>
cmpb   $0x23,0x10(%rsp)
je     1290 <fw_parse_script+0xe0>
mov    %r12,%rdi
mov    $0x1,%esi
call   1040 <fw_string_blank@plt>
test   %rax,%rax
je     1290 <fw_parse_script+0xe0>
mov    %rax,%r13
mov    %rax,%rdi
xor    %esi,%esi
call   1040 <fw_string_blank@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1060 <strlen@plt>
test   %rbp,%rbp
je     1272 <fw_parse_script+0xc2>
mov    %rbp,%rcx
add    $0x1,%rbp
movb   $0x0,(%rcx)
mov    %rbp,%rcx
sub    %r13,%rcx
cltq
cmp    %rax,%rcx
jge    1272 <fw_parse_script+0xc2>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1040 <fw_string_blank@plt>
mov    %rax,%rsi
jmp    1274 <fw_parse_script+0xc4>
xor    %ebx,%ebx
jmp    1395 <fw_parse_script+0x1e5>
mov    0x2c64(%rip),%rax
mov    (%rax),%edi
lea    0xcc9(%rip),%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1390 <fw_parse_script+0x1e0>
xor    %ebx,%ebx
mov    0x8(%rsp),%rbp
lea    0xc88(%rip),%rsi
mov    %rbp,%rdi
call   1080 <strcmp@plt>
test   %rax,%rax
je     13b1 <fw_parse_script+0x201>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
call   10a0 <fw_env_close@plt>
or     %ebx,%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c05(%rip),%rax
mov    (%rax),%ebx
mov    0x2bf4(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xc8a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    1387 <fw_parse_script+0x1d7>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [36 x i8] c"Error: environment not initialized\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [30 x i8] c"I cannot open %s for reading\0A\00"
@.str.4 = [46 x i8] c"Line %d not corrected terminated or too long\0A\00"
@.str.5 = [38 x i8] c"fw_env_write returns with error : %s\0A\00"
@errno = global i32 0
define i32 @fw_parse_script(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [1024 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %8
store i32 0, i32* %10
%11 = call i64 (...) @fw_env_open()
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %146
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = load i32*, i32** @stdin
store i32* %21, i32** %4
br label %32
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %24, i32** %4
%25 = load i32*, i32** %4
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %3
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %29)
store i32 -1, i32* %2
br label %146
31: ; preds = %22
br label %32
32: ; preds = %31, %20
br label %33
33: ; preds = %133, %99, %93, %32
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%35 = load i32*, i32** %4
%36 = call i64 @fgets(i8* %34, i32 1024, i32* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %134
38: ; preds = %33
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
store i32 %42, i32* %9
%43 = load i32, i32* %9
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp ne i32 %48, 10
br i1 %49, label %50, label %54
50: ; preds = %38
%51 = load i32, i32* @stderr
%52 = load i32, i32* %8
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %52)
store i32 -1, i32* %10
br label %134
54: ; preds = %38
br label %55
55: ; preds = %78, %54
%56 = load i32, i32* %9
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %76
58: ; preds = %55
%59 = load i32, i32* %9
%60 = sub nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 10
br i1 %65, label %74, label %66
66: ; preds = %58
%67 = load i32, i32* %9
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp eq i32 %72, 13
br label %74
74: ; preds = %66, %58
%75 = phi i1 [ true, %58 ], [ %73, %66 ]
br label %76
76: ; preds = %74, %55
%77 = phi i1 [ false, %55 ], [ %75, %74 ]
br i1 %77, label %78, label %85
78: ; preds = %76
%79 = load i32, i32* %9
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %81
store i8 0, i8* %82
%83 = load i32, i32* %9
%84 = add nsw i32 %83, -1
store i32 %84, i32* %9
br label %55
85: ; preds = %76
%86 = load i32, i32* %9
%87 = icmp eq i32 %86, 0
br i1 %87, label %93, label %88
88: ; preds = %85
%89 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 35
br i1 %92, label %93, label %94
93: ; preds = %88, %85
br label %33
94: ; preds = %88
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%96 = call i8* @fw_string_blank(i8* %95, i32 1)
store i8* %96, i8** %6
%97 = load i8*, i8** %6
%98 = icmp ne i8* %97, null
br i1 %98, label %100, label %99
99: ; preds = %94
br label %33
100: ; preds = %94
%101 = load i8*, i8** %6
%102 = call i8* @fw_string_blank(i8* %101, i32 0)
store i8* %102, i8** %7
%103 = load i8*, i8** %6
%104 = call i32 @strlen(i8* %103)
store i32 %104, i32* %9
%105 = load i8*, i8** %7
%106 = icmp ne i8* %105, null
br i1 %106, label %107, label %123
107: ; preds = %100
%108 = load i8*, i8** %7
%109 = getelementptr inbounds i8, i8* %108, i32 1
store i8* %109, i8** %7
store i8 0, i8* %108
%110 = load i8*, i8** %7
%111 = load i8*, i8** %6
%112 = ptrtoint i8* %110 to i64
%113 = ptrtoint i8* %111 to i64
%114 = sub i64 %112, %113
%115 = load i32, i32* %9
%116 = sext i32 %115 to i64
%117 = icmp slt i64 %114, %116
br i1 %117, label %118, label %121
118: ; preds = %107
%119 = load i8*, i8** %7
%120 = call i8* @fw_string_blank(i8* %119, i32 1)
store i8* %120, i8** %7
br label %122
121: ; preds = %107
store i8* null, i8** %7
br label %122
122: ; preds = %121, %118
br label %123
123: ; preds = %122, %100
%124 = load i8*, i8** %6
%125 = load i8*, i8** %7
%126 = call i64 @fw_env_write(i8* %124, i8* %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %133
128: ; preds = %123
%129 = load i32, i32* @stderr
%130 = load i32, i32* @errno
%131 = call i8* @strerror(i32 %130)
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %129, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %131)
store i32 -1, i32* %10
br label %134
133: ; preds = %123
br label %33
134: ; preds = %128, %50, %33
%135 = load i8*, i8** %3
%136 = call i64 @strcmp(i8* %135, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %134
%139 = load i32*, i32** %4
%140 = call i32 @fclose(i32* %139)
br label %141
141: ; preds = %138, %134
%142 = call i32 (...) @fw_env_close()
%143 = load i32, i32* %10
%144 = or i32 %143, %142
store i32 %144, i32* %10
%145 = load i32, i32* %10
store i32 %145, i32* %2
br label %146
146: ; preds = %141, %27, %13
%147 = load i32, i32* %2
ret i32 %147
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [36 x i8] c"Error: environment not initialized\0A\00"
@.str.1 = [2 x i8] c"-\00"
@stdin = global i32* null
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [30 x i8] c"I cannot open %s for reading\0A\00"
@.str.4 = [46 x i8] c"Line %d not corrected terminated or too long\0A\00"
@.str.5 = [38 x i8] c"fw_env_write returns with error : %s\0A\00"
@errno = global i32 0
define i32 @fw_parse_script(i8* %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i64 (...) @fw_env_open()
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %93
9: ; preds = %1
%10 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = load i32*, i32** @stdin
br label %20
14: ; preds = %9
%15 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %93
20: ; preds = %14, %12
%21 = phi i32* [ %13, %12 ], [ %15, %14 ]
%22 = call i64 @fgets(i8* %3, i32 1024, i32* %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %84, label %24
24: ; preds = %20, %56
%25 = phi i32 [ %26, %56 ], [ 0, %20 ]
%26 = add nuw nsw i32 %25, 1
%27 = call i32 @strlen(i8* %3)
%28 = add nsw i32 %27, -1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %37
33: ; preds = %24
%34 = icmp sgt i32 %27, 0
br i1 %34, label %35, label %50
35: ; preds = %33
%36 = zext i32 %27 to i64
br label %40
37: ; preds = %24
%38 = load i32, i32* @stderr
%39 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %84
40: ; preds = %35, %46
%41 = phi i64 [ %36, %35 ], [ %42, %46 ]
%42 = add nsw i64 %41, -1
%43 = and i64 %42, 4294967295
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
switch i8 %45, label %48 [
i8 10, label %46
i8 13, label %46
]
46: ; preds = %40, %40
store i8 0, i8* %44
%47 = icmp ugt i64 %41, 1
br i1 %47, label %40, label %56
48: ; preds = %40
%49 = trunc i64 %41 to i32
br label %50
50: ; preds = %48, %33
%51 = phi i32 [ %27, %33 ], [ %49, %48 ]
%52 = icmp eq i32 %51, 0
%53 = load i8, i8* %3
%54 = icmp eq i8 %53, 35
%55 = select i1 %52, i1 true, i1 %54
br i1 %55, label %56, label %59
56: ; preds = %46, %50, %59, %75
%57 = call i64 @fgets(i8* %3, i32 1024, i32* %21)
%58 = icmp eq i64 %57, 0
br i1 %58, label %84, label %24
59: ; preds = %50
%60 = call i8* @fw_string_blank(i8* %3, i32 1)
%61 = icmp eq i8* %60, null
br i1 %61, label %56, label %62
62: ; preds = %59
%63 = call i8* @fw_string_blank(i8* %60, i32 0)
%64 = call i32 @strlen(i8* %60)
%65 = icmp eq i8* %63, null
br i1 %65, label %75, label %66
66: ; preds = %62
%67 = getelementptr inbounds i8, i8* %63, i64 1
store i8 0, i8* %63
%68 = ptrtoint i8* %67 to i64
%69 = ptrtoint i8* %60 to i64
%70 = sub i64 %68, %69
%71 = sext i32 %64 to i64
%72 = icmp slt i64 %70, %71
br i1 %72, label %73, label %75
73: ; preds = %66
%74 = call i8* @fw_string_blank(i8* %67, i32 1)
br label %75
75: ; preds = %66, %73, %62
%76 = phi i8* [ %74, %73 ], [ null, %62 ], [ null, %66 ]
%77 = call i64 @fw_env_write(i8* %60, i8* %76)
%78 = icmp eq i64 %77, 0
br i1 %78, label %56, label %79
79: ; preds = %75
%80 = load i32, i32* @stderr
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %56, %20, %79, %37
%85 = phi i32 [ -1, %37 ], [ -1, %79 ], [ 0, %20 ], [ 0, %56 ]
%86 = call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %90, label %88
88: ; preds = %84
%89 = call i32 @fclose(i32* %21)
br label %90
90: ; preds = %88, %84
%91 = call i32 (...) @fw_env_close()
%92 = or i32 %91, %85
br label %93
93: ; preds = %90, %17, %6
%94 = phi i32 [ -1, %6 ], [ %92, %90 ], [ -1, %17 ]
ret i32 %94
}