#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 *, char const *);
int /*<<< orphan*/ free(char *);
int fscanf(int /*<<< orphan*/ *, char *, char *);
char *malloc(scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int sprintf(char *, char *, char const *, char const *);
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 == NULL) {
    printf("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 == NULL) {
    ret = -errno;
    printf("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 == NULL) {
      ret = -errno;
      printf("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) {
      printf("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   10a0 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1224 <_write_sysfs_string+0x74>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
mov    0x2dbe(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    143a <_write_sysfs_string+0x28a>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xde3(%rip),%rsi
call   10d0 <sprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    124e <_write_sysfs_string+0x9e>
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x38(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1292 <_write_sysfs_string+0xe2>
xor    %eax,%eax
mov    0x2d5a(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xd9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xd7c(%rip),%rsi
call   1090 <fprintf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    12d7 <_write_sysfs_string+0x127>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12d2 <_write_sysfs_string+0x122>
lea    0xd68(%rip),%rdi
call   10c0 <perror@plt>
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     12fd <_write_sysfs_string+0x14d>
xor    %eax,%eax
mov    0x2cdd(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
jmp    142b <_write_sysfs_string+0x27b>
cmpl   $0x0,-0x24(%rbp)
je     1426 <_write_sysfs_string+0x276>
mov    -0x38(%rbp),%rdi
lea    0xd4c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1347 <_write_sysfs_string+0x197>
xor    %eax,%eax
mov    0x2ca1(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
lea    0xd25(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rdx
lea    0xcc7(%rip),%rsi
call   1070 <fscanf@plt>
cmp    $0x1,%eax
je     13bf <_write_sysfs_string+0x20f>
mov    0x2c65(%rip),%rax
cmpl   $0x0,(%rax)
je     1387 <_write_sysfs_string+0x1d7>
xor    %eax,%eax
mov    0x2c53(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x44(%rbp)
jmp    1395 <_write_sysfs_string+0x1e5>
xor    %eax,%eax
mov    0x2c58(%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     13ba <_write_sysfs_string+0x20a>
lea    0xc80(%rip),%rdi
call   10c0 <perror@plt>
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     13e5 <_write_sysfs_string+0x235>
xor    %eax,%eax
mov    0x2bf5(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x28(%rbp)
jmp    142b <_write_sysfs_string+0x27b>
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     1421 <_write_sysfs_string+0x271>
mov    -0x38(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xc6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x28(%rbp)
jmp    1426 <_write_sysfs_string+0x276>
jmp    142b <_write_sysfs_string+0x27b>
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   1060 <strlen@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    (%rax,%rbp,1),%rdi
add    $0x2,%rdi
call   10b0 <malloc@plt>
test   %rax,%rax
je     1277 <_write_sysfs_string+0xb7>
mov    %rax,%r14
lea    0xdf7(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r13,%rcx
call   10e0 <sprintf@plt>
test   %eax,%eax
js     1293 <_write_sysfs_string+0xd3>
mov    %r12d,0xc(%rsp)
mov    %rbx,0x10(%rsp)
lea    0xdda(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     129a <_write_sysfs_string+0xda>
mov    %rax,%r12
lea    0xdc0(%rip),%rsi
mov    %rax,%rdi
mov    0x10(%rsp),%rdx
call   10a0 <fprintf@plt>
mov    %eax,%ebp
mov    %r12,%rdi
call   1050 <fclose@plt>
test   %ebp,%ebp
js     1374 <_write_sysfs_string+0x1b4>
test   %rax,%rax
je     12bb <_write_sysfs_string+0xfb>
mov    0x2d62(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1379 <_write_sysfs_string+0x1b9>
lea    0xe2b(%rip),%rdi
call   1040 <puts@plt>
mov    0x2d4e(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
jmp    1381 <_write_sysfs_string+0x1c1>
mov    %eax,%ebp
jmp    1379 <_write_sysfs_string+0x1b9>
mov    0x2d2f(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
lea    0xd5c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1379 <_write_sysfs_string+0x1b9>
cmpl   $0x0,0xc(%rsp)
je     1379 <_write_sysfs_string+0x1b9>
lea    0xd77(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     133b <_write_sysfs_string+0x17b>
mov    %rax,%rbx
lea    0xd1f(%rip),%rsi
mov    %rax,%rdi
mov    %r14,%rdx
call   1080 <fscanf@plt>
cmp    $0x1,%eax
jne    1354 <_write_sysfs_string+0x194>
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
jne    1267 <_write_sysfs_string+0xa7>
mov    %r14,%rdi
mov    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     1379 <_write_sysfs_string+0x1b9>
lea    0xd25(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
mov    %r13,%r8
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebp
jmp    1379 <_write_sysfs_string+0x1b9>
mov    0x2c8e(%rip),%rax
xor    %ebp,%ebp
sub    (%rax),%ebp
lea    0xd3e(%rip),%rdi
call   1040 <puts@plt>
jmp    1379 <_write_sysfs_string+0x1b9>
mov    0x2c75(%rip),%rax
mov    (%rax),%ebp
test   %ebp,%ebp
jne    136a <_write_sysfs_string+0x1aa>
mov    0x2c80(%rip),%rax
mov    (%rax),%ebp
neg    %ebp
mov    %rbx,%rdi
call   1050 <fclose@plt>
test   %rax,%rax
jne    1392 <_write_sysfs_string+0x1d2>
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    0xc82(%rip),%rdi
call   10d0 <perror@plt>
jmp    1379 <_write_sysfs_string+0x1b9>

LLVM IR (-O0):
@.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 = [69 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 eq i8* %20, null
br i1 %21, label %22, label %26
22: ; preds = %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @ENOMEM
%25 = sub nsw i32 0, %24
store i32 %25, i32* %5
br label %122
26: ; preds = %4
%27 = load i8*, i8** %12
%28 = load i8*, i8** %7
%29 = load i8*, i8** %6
%30 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %28, i8* %29)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %26
br label %118
34: ; preds = %26
%35 = load i8*, i8** %12
%36 = call i32* @fopen(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %36, i32** %11
%37 = load i32*, i32** %11
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %34
%40 = load i32, i32* @errno
%41 = sub nsw i32 0, %40
store i32 %41, i32* %10
%42 = load i8*, i8** %12
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %118
44: ; preds = %34
%45 = load i32*, i32** %11
%46 = load i8*, i8** %8
%47 = call i32 @fprintf(i32* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %46)
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = icmp slt i32 %48, 0
br i1 %49, label %50, label %57
50: ; preds = %44
%51 = load i32*, i32** %11
%52 = call i64 @fclose(i32* %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54, %50
br label %118
57: ; preds = %44
%58 = load i32*, i32** %11
%59 = call i64 @fclose(i32* %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %57
%62 = load i32, i32* @errno
%63 = sub nsw i32 0, %62
store i32 %63, i32* %10
br label %118
64: ; preds = %57
%65 = load i32, i32* %9
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %117
67: ; preds = %64
%68 = load i8*, i8** %12
%69 = call i32* @fopen(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %69, i32** %11
%70 = load i32*, i32** %11
%71 = icmp eq i32* %70, null
br i1 %71, label %72, label %76
72: ; preds = %67
%73 = load i32, i32* @errno
%74 = sub nsw i32 0, %73
store i32 %74, i32* %10
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %118
76: ; preds = %67
%77 = load i32*, i32** %11
%78 = load i8*, i8** %12
%79 = call i32 @fscanf(i32* %77, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %78)
%80 = icmp ne i32 %79, 1
br i1 %80, label %81, label %98
81: ; preds = %76
%82 = load i32, i32* @errno
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32, i32* @errno
%86 = sub nsw i32 0, %85
br label %90
87: ; preds = %81
%88 = load i32, i32* @ENODATA
%89 = sub nsw i32 0, %88
br label %90
90: ; preds = %87, %84
%91 = phi i32 [ %86, %84 ], [ %89, %87 ]
store i32 %91, i32* %10
%92 = load i32*, i32** %11
%93 = call i64 @fclose(i32* %92)
%94 = icmp ne i64 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %90
%96 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %97
97: ; preds = %95, %90
br label %118
98: ; preds = %76
%99 = load i32*, i32** %11
%100 = call i64 @fclose(i32* %99)
%101 = icmp ne i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %98
%103 = load i32, i32* @errno
%104 = sub nsw i32 0, %103
store i32 %104, i32* %10
br label %118
105: ; preds = %98
%106 = load i8*, i8** %12
%107 = load i8*, i8** %8
%108 = call i64 @strcmp(i8* %106, i8* %107)
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %116
110: ; preds = %105
%111 = load i8*, i8** %12
%112 = load i8*, i8** %8
%113 = load i8*, i8** %7
%114 = load i8*, i8** %6
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.8, i64 0, i64 0), i8* %111, i8* %112, i8* %113, i8* %114)
store i32 -1, i32* %10
br label %116
116: ; preds = %110, %105
br label %117
117: ; preds = %116, %64
br label %118
118: ; preds = %117, %102, %97, %72, %61, %56, %39, %33
%119 = load i8*, i8** %12
%120 = call i32 @free(i8* %119)
%121 = load i32, i32* %10
store i32 %121, i32* %5
br label %122
122: ; preds = %118, %22
%123 = load i32, i32* %5
ret i32 %123
}

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