#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 ENODATA;
int ENOMEM;
int errno;
scalar_t__ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ perror(char *);
int sprintf(char *, char *, char const *, char const *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char const *);
scalar_t__ strlen(char const *);
int _write_sysfs_string(const char *filename, const char *basedir,
                        const char *val, int verify) {
  int ret = 0;
  FILE *sysfsfp;
  char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
  if (!temp) {
    fprintf(stderr, "Memory allocation failed\n");
    return -ENOMEM;
  }
  ret = sprintf(temp, "%s/%s", basedir, filename);
  if (ret < 0)
    goto error_free;
  sysfsfp = fopen(temp, "w");
  if (!sysfsfp) {
    ret = -errno;
    fprintf(stderr, "Could not open %s\n", temp);
    goto error_free;
  }
  ret = fprintf(sysfsfp, "%s", val);
  if (ret < 0) {
    if (fclose(sysfsfp))
      perror("_write_sysfs_string(): Failed to close dir");
    goto error_free;
  }
  if (fclose(sysfsfp)) {
    ret = -errno;
    goto error_free;
  }
  if (verify) {
    sysfsfp = fopen(temp, "r");
    if (!sysfsfp) {
      ret = -errno;
      fprintf(stderr, "Could not open file to verify\n");
      goto error_free;
    }
    if (fscanf(sysfsfp, "%s", temp) != 1) {
      ret = errno ? -errno : -ENODATA;
      if (fclose(sysfsfp))
        perror("_write_sysfs_string(): Failed to close dir");
      goto error_free;
    }
    if (fclose(sysfsfp)) {
      ret = -errno;
      goto error_free;
    }
    if (strcmp(temp, val) != 0) {
      fprintf(stderr,
              "Possible failure in string write of %s "
              "Should be %s written to %s/%s\n",
              temp, val, basedir, filename);
      ret = -1;
    }
  }
error_free:
  free(temp);
  return ret;
}


x86 assembly (clang, -O0):
<_write_sysfs_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x40(%rbp),%rdi
add    %rax,%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    121d <_write_sysfs_string+0x7d>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
xor    %eax,%eax
mov    0x2dc5(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    1452 <_write_sysfs_string+0x2b2>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xdea(%rip),%rsi
call   10c0 <sprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1247 <_write_sysfs_string+0xa7>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x38(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1294 <_write_sysfs_string+0xf4>
xor    %eax,%eax
mov    0x2d59(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x30(%rbp),%rax
mov    %eax,%edi
mov    -0x20(%rbp),%rdx
lea    0xd78(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    12dd <_write_sysfs_string+0x13d>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12d8 <_write_sysfs_string+0x138>
lea    0xd62(%rip),%rdi
call   10b0 <perror@plt>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1303 <_write_sysfs_string+0x163>
xor    %eax,%eax
mov    0x2ccf(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
jmp    1443 <_write_sysfs_string+0x2a3>
cmpl   $0x0,-0x24(%rbp)
je     143e <_write_sysfs_string+0x29e>
mov    -0x38(%rbp),%rdi
lea    0xd46(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1356 <_write_sysfs_string+0x1b6>
xor    %eax,%eax
mov    0x2c93(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xcb8(%rip),%rsi
call   1060 <fscanf@plt>
cmp    $0x1,%eax
je     13ce <_write_sysfs_string+0x22e>
mov    0x2c4e(%rip),%rax
cmpl   $0x0,(%rax)
je     1396 <_write_sysfs_string+0x1f6>
xor    %eax,%eax
mov    0x2c3c(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x44(%rbp)
jmp    13a4 <_write_sysfs_string+0x204>
xor    %eax,%eax
mov    0x2c49(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     13c9 <_write_sysfs_string+0x229>
lea    0xc71(%rip),%rdi
call   10b0 <perror@plt>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     13f4 <_write_sysfs_string+0x254>
xor    %eax,%eax
mov    0x2bde(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1439 <_write_sysfs_string+0x299>
mov    0x2bbe(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    0xc54(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x28(%rbp)
jmp    143e <_write_sysfs_string+0x29e>
jmp    1443 <_write_sysfs_string+0x2a3>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_write_sysfs_string>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r12d
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r13
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1050 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   1090 <malloc@plt>
test   %rax,%rax
je     125d <_write_sysfs_string+0xbd>
mov    %rax,%r14
lea    0xe31(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
call   10c0 <sprintf@plt>
test   %eax,%eax
js     1284 <_write_sysfs_string+0xe4>
mov    %r12d,0xc(%rsp)
mov    %rbx,0x10(%rsp)
lea    0xe10(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     128b <_write_sysfs_string+0xeb>
mov    %rax,%r12
lea    0xdf6(%rip),%rsi
mov    %r12d,%edi
mov    0x10(%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1040 <fclose@plt>
test   %ebp,%ebp
js     1382 <_write_sysfs_string+0x1e2>
test   %rax,%rax
je     12b5 <_write_sysfs_string+0x115>
mov    0x2d74(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1387 <_write_sysfs_string+0x1e7>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xd93(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d5b(%rip),%rax
sub    (%rax),%ebp
jmp    138f <_write_sysfs_string+0x1ef>
mov    %eax,%ebp
jmp    1387 <_write_sysfs_string+0x1e7>
mov    0x2d36(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1387 <_write_sysfs_string+0x1e7>
cmpl   $0x0,0xc(%rsp)
je     1387 <_write_sysfs_string+0x1e7>
lea    0xd97(%rip),%rsi
mov    %r14,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     133e <_write_sysfs_string+0x19e>
mov    %rax,%rbx
lea    0xd3f(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1060 <fscanf@plt>
cmp    $0x1,%eax
jne    1362 <_write_sysfs_string+0x1c2>
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    124d <_write_sysfs_string+0xad>
mov    %r14,%rdi
mov    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1387 <_write_sysfs_string+0x1e7>
mov    0x2cb5(%rip),%rax
mov    (%rax),%edi
lea    0xd5b(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
mov    %r13,%r9
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%ebp
jmp    1387 <_write_sysfs_string+0x1e7>
mov    0x2c83(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
mov    0x2c80(%rip),%rax
mov    (%rax),%edi
lea    0xd07(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1387 <_write_sysfs_string+0x1e7>
mov    0x2c5f(%rip),%rax
mov    (%rax),%ebp
test   %ebp,%ebp
jne    1378 <_write_sysfs_string+0x1d8>
mov    0x2c72(%rip),%rax
mov    (%rax),%ebp
neg    %ebp
mov    %rbx,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    13a0 <_write_sysfs_string+0x200>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc8e(%rip),%rdi
call   10b0 <perror@plt>
jmp    1387 <_write_sysfs_string+0x1e7>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Memory allocation failed\0A\00"
@ENOMEM = global i32 0
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.3 = [19 x i8] c"Could not open %s\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [43 x i8] c"_write_sysfs_string(): Failed to close dir\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [31 x i8] c"Could not open file to verify\0A\00"
@ENODATA = global i32 0
@.str.8 = [70 x i8] c"Possible failure in string write of %s Should be %s written to %s/%s\0A\00"
define i32 @_write_sysfs_string(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 0, i32* %10
%13 = load i8*, i8** %7
%14 = call i64 @strlen(i8* %13)
%15 = load i8*, i8** %6
%16 = call i64 @strlen(i8* %15)
%17 = add nsw i64 %14, %16
%18 = add nsw i64 %17, 2
%19 = call i8* @malloc(i64 %18)
store i8* %19, i8** %12
%20 = load i8*, i8** %12
%21 = icmp ne i8* %20, null
br i1 %21, label %27, label %22
22: ; preds = %4
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%25 = load i32, i32* @ENOMEM
%26 = sub nsw i32 0, %25
store i32 %26, i32* %5
br label %127
27: ; preds = %4
%28 = load i8*, i8** %12
%29 = load i8*, i8** %7
%30 = load i8*, i8** %6
%31 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30)
store i32 %31, i32* %10
%32 = load i32, i32* %10
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %27
br label %123
35: ; preds = %27
%36 = load i8*, i8** %12
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %37, i32** %11
%38 = load i32*, i32** %11
%39 = icmp ne i32* %38, null
br i1 %39, label %46, label %40
40: ; preds = %35
%41 = load i32, i32* @errno
%42 = sub nsw i32 0, %41
store i32 %42, i32* %10
%43 = load i32, i32* @stderr
%44 = load i8*, i8** %12
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %44)
br label %123
46: ; preds = %35
%47 = load i32*, i32** %11
%48 = ptrtoint i32* %47 to i32
%49 = load i8*, i8** %8
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %49)
store i32 %50, i32* %10
%51 = load i32, i32* %10
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %46
%54 = load i32*, i32** %11
%55 = call i64 @fclose(i32* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %59
59: ; preds = %57, %53
br label %123
60: ; preds = %46
%61 = load i32*, i32** %11
%62 = call i64 @fclose(i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %60
%65 = load i32, i32* @errno
%66 = sub nsw i32 0, %65
store i32 %66, i32* %10
br label %123
67: ; preds = %60
%68 = load i32, i32* %9
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %122
70: ; preds = %67
%71 = load i8*, i8** %12
%72 = call i32* @fopen(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %72, i32** %11
%73 = load i32*, i32** %11
%74 = icmp ne i32* %73, null
br i1 %74, label %80, label %75
75: ; preds = %70
%76 = load i32, i32* @errno
%77 = sub nsw i32 0, %76
store i32 %77, i32* %10
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %123
80: ; preds = %70
%81 = load i32*, i32** %11
%82 = load i8*, i8** %12
%83 = call i32 @fscanf(i32* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %82)
%84 = icmp ne i32 %83, 1
br i1 %84, label %85, label %102
85: ; preds = %80
%86 = load i32, i32* @errno
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %85
%89 = load i32, i32* @errno
%90 = sub nsw i32 0, %89
br label %94
91: ; preds = %85
%92 = load i32, i32* @ENODATA
%93 = sub nsw i32 0, %92
br label %94
94: ; preds = %91, %88
%95 = phi i32 [ %90, %88 ], [ %93, %91 ]
store i32 %95, i32* %10
%96 = load i32*, i32** %11
%97 = call i64 @fclose(i32* %96)
%98 = icmp ne i64 %97, 0
br i1 %98, label %99, label %101
99: ; preds = %94
%100 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %101
101: ; preds = %99, %94
br label %123
102: ; preds = %80
%103 = load i32*, i32** %11
%104 = call i64 @fclose(i32* %103)
%105 = icmp ne i64 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %102
%107 = load i32, i32* @errno
%108 = sub nsw i32 0, %107
store i32 %108, i32* %10
br label %123
109: ; preds = %102
%110 = load i8*, i8** %12
%111 = load i8*, i8** %8
%112 = call i64 @strcmp(i8* %110, i8* %111)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %121
114: ; preds = %109
%115 = load i32, i32* @stderr
%116 = load i8*, i8** %12
%117 = load i8*, i8** %8
%118 = load i8*, i8** %7
%119 = load i8*, i8** %6
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.8, i64 0, i64 0), i8* %116, i8* %117, i8* %118, i8* %119)
store i32 -1, i32* %10
br label %121
121: ; preds = %114, %109
br label %122
122: ; preds = %121, %67
br label %123
123: ; preds = %122, %106, %101, %75, %64, %59, %40, %34
%124 = load i8*, i8** %12
%125 = call i32 @free(i8* %124)
%126 = load i32, i32* %10
store i32 %126, i32* %5
br label %127
127: ; preds = %123, %22
%128 = load i32, i32* %5
ret i32 %128
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Memory allocation failed\0A\00"
@ENOMEM = global i32 0
@.str.1 = [6 x i8] c"%s/%s\00"
@.str.2 = [2 x i8] c"w\00"
@errno = global i32 0
@.str.3 = [19 x i8] c"Could not open %s\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [43 x i8] c"_write_sysfs_string(): Failed to close dir\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [31 x i8] c"Could not open file to verify\0A\00"
@ENODATA = global i32 0
@.str.8 = [70 x i8] c"Possible failure in string write of %s Should be %s written to %s/%s\0A\00"
define i32 @_write_sysfs_string(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%7 = add i64 %5, 2
%8 = add i64 %7, %6
%9 = tail call i8* @malloc(i64 %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @ENOMEM
%15 = sub nsw i32 0, %14
br label %79
16: ; preds = %4
%17 = tail call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %76, label %19
19: ; preds = %16
%20 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* @errno
%24 = sub nsw i32 0, %23
%25 = load i32, i32* @stderr
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %9)
br label %76
27: ; preds = %19
%28 = ptrtoint i32* %20 to i64
%29 = trunc i64 %28 to i32
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%31 = icmp slt i32 %30, 0
%32 = tail call i64 @fclose(i32* %20)
%33 = icmp eq i64 %32, 0
br i1 %31, label %34, label %37
34: ; preds = %27
br i1 %33, label %76, label %35
35: ; preds = %34
%36 = tail call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %76
37: ; preds = %27
br i1 %33, label %41, label %38
38: ; preds = %37
%39 = load i32, i32* @errno
%40 = sub nsw i32 0, %39
br label %76
41: ; preds = %37
%42 = icmp eq i32 %3, 0
br i1 %42, label %76, label %43
43: ; preds = %41
%44 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* @errno
%48 = sub nsw i32 0, %47
%49 = load i32, i32* @stderr
%50 = tail call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %76
51: ; preds = %43
%52 = tail call i32 @fscanf(i32* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%53 = icmp eq i32 %52, 1
br i1 %53, label %64, label %54
54: ; preds = %51
%55 = load i32, i32* @errno
%56 = icmp eq i32 %55, 0
%57 = load i32, i32* @ENODATA
%58 = select i1 %56, i32 %57, i32 %55
%59 = sub nsw i32 0, %58
%60 = tail call i64 @fclose(i32* %44)
%61 = icmp eq i64 %60, 0
br i1 %61, label %76, label %62
62: ; preds = %54
%63 = tail call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %76
64: ; preds = %51
%65 = tail call i64 @fclose(i32* %44)
%66 = icmp eq i64 %65, 0
br i1 %66, label %70, label %67
67: ; preds = %64
%68 = load i32, i32* @errno
%69 = sub nsw i32 0, %68
br label %76
70: ; preds = %64
%71 = tail call i64 @strcmp(i8* %9, i8* %2)
%72 = icmp eq i64 %71, 0
br i1 %72, label %76, label %73
73: ; preds = %70
%74 = load i32, i32* @stderr
%75 = tail call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.8, i64 0, i64 0), i8* %9, i8* %2, i8* %1, i8* %0)
br label %76
76: ; preds = %41, %73, %70, %54, %62, %34, %35, %16, %67, %46, %38, %22
%77 = phi i32 [ %17, %16 ], [ %30, %35 ], [ %30, %34 ], [ %40, %38 ], [ %59, %62 ], [ %59, %54 ], [ %69, %67 ], [ -1, %73 ], [ %30, %70 ], [ %48, %46 ], [ %30, %41 ], [ %24, %22 ]
%78 = tail call i32 @free(i8* %9)
br label %79
79: ; preds = %76, %11
%80 = phi i32 [ %77, %76 ], [ %15, %11 ]
ret i32 %80
}