#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 /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int wfh_readint(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wfh_writeint(int /*<<< orphan*/ *, int, int);
int wfh_putlength(const char *filename, int length) {
  FILE *file1 = NULL;
  int ret = -1;
  char com1[100];
  int s;
  file1 = fopen(filename, "r+b");
  if (!file1) {
    return ret;
  }
  if (fread(com1, 1, 4, file1) != 4) {
    fclose(file1);
    return ret;
  }
  if (com1[0] != 'R' || com1[1] != 'I' || com1[2] != 'F' || com1[3] != 'F') {
    fclose(file1);
    return ret;
  }
  if (fseek(file1, 4, SEEK_SET) != 0) {
    fclose(file1);
    return ret;
  }
  wfh_writeint(
      file1, 4 + 4 + 4 + 4 + 4 + 2 + 2 + 4 + 4 + 2 + 2 + 4 + 4 + length - 8, 4);
  if (fseek(file1, 8, SEEK_SET) != 0) {
    fclose(file1);
    return ret;
  }
  if (fread(com1, 1, 4, file1) != 4) {
    fclose(file1);
    return ret;
  }
  if (com1[0] != 'W' || com1[1] != 'A' || com1[2] != 'V' || com1[3] != 'E') {
    fclose(file1);
    return ret;
  }
  if (fread(com1, 1, 4, file1) != 4) {
    fclose(file1);
    return ret;
  }
  if (com1[0] != 'f' || com1[1] != 'm' || com1[2] != 't' || com1[3] != ' ') {
    fclose(file1);
    return ret;
  }
  s = wfh_readint(file1, 4);
  if (fseek(file1, s, SEEK_CUR) != 0) {
    fclose(file1);
    return ret;
  }
  if (fread(com1, 1, 4, file1) != 4) {
    fclose(file1);
    return ret;
  }
  if (com1[0] != 'd' || com1[1] != 'a' || com1[2] != 't' || com1[3] != 'a') {
    fclose(file1);
    return ret;
  }
  if (fseek(file1, 40, SEEK_SET) != 0) {
    fclose(file1);
    return ret;
  }
  wfh_writeint(file1, length, 4);
  fclose(file1);
  ret = 0;
  return ret;
}


x86 assembly (clang, -O0):
<wfh_putlength>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0xffffffff,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ab <wfh_putlength+0x4b>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
cmp    $0x4,%eax
je     11e2 <wfh_putlength+0x82>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
movsbl -0x90(%rbp),%eax
cmp    $0x52,%eax
jne    1222 <wfh_putlength+0xc2>
movsbl -0x8f(%rbp),%eax
cmp    $0x49,%eax
jne    1222 <wfh_putlength+0xc2>
movsbl -0x8e(%rbp),%eax
cmp    $0x46,%eax
jne    1222 <wfh_putlength+0xc2>
movsbl -0x8d(%rbp),%eax
cmp    $0x46,%eax
je     1236 <wfh_putlength+0xd6>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
mov    -0x20(%rbp),%rdi
mov    0x2d97(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     126b <wfh_putlength+0x10b>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2c,%esi
sub    $0x8,%esi
mov    $0x4,%edx
call   1080 <wfh_writeint@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d4b(%rip),%rax
mov    (%rax),%edx
mov    $0x8,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     12b7 <wfh_putlength+0x157>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
cmp    $0x4,%eax
je     12ee <wfh_putlength+0x18e>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
movsbl -0x90(%rbp),%eax
cmp    $0x57,%eax
jne    132e <wfh_putlength+0x1ce>
movsbl -0x8f(%rbp),%eax
cmp    $0x41,%eax
jne    132e <wfh_putlength+0x1ce>
movsbl -0x8e(%rbp),%eax
cmp    $0x56,%eax
jne    132e <wfh_putlength+0x1ce>
movsbl -0x8d(%rbp),%eax
cmp    $0x45,%eax
je     1342 <wfh_putlength+0x1e2>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
cmp    $0x4,%eax
je     1379 <wfh_putlength+0x219>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
movsbl -0x90(%rbp),%eax
cmp    $0x66,%eax
jne    13b9 <wfh_putlength+0x259>
movsbl -0x8f(%rbp),%eax
cmp    $0x6d,%eax
jne    13b9 <wfh_putlength+0x259>
movsbl -0x8e(%rbp),%eax
cmp    $0x74,%eax
jne    13b9 <wfh_putlength+0x259>
movsbl -0x8d(%rbp),%eax
cmp    $0x20,%eax
je     13cd <wfh_putlength+0x26d>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
mov    -0x20(%rbp),%rdi
mov    $0x4,%esi
call   1030 <wfh_readint@plt>
mov    %eax,-0x94(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x94(%rbp),%esi
mov    0x2bf6(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     1417 <wfh_putlength+0x2b7>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1040 <fread@plt>
cmp    $0x4,%eax
je     144e <wfh_putlength+0x2ee>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
movsbl -0x90(%rbp),%eax
cmp    $0x64,%eax
jne    148e <wfh_putlength+0x32e>
movsbl -0x8f(%rbp),%eax
cmp    $0x61,%eax
jne    148e <wfh_putlength+0x32e>
movsbl -0x8e(%rbp),%eax
cmp    $0x74,%eax
jne    148e <wfh_putlength+0x32e>
movsbl -0x8d(%rbp),%eax
cmp    $0x61,%eax
je     14a2 <wfh_putlength+0x342>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
mov    -0x20(%rbp),%rdi
mov    0x2b2b(%rip),%rax
mov    (%rax),%edx
mov    $0x28,%esi
call   1060 <fseek@plt>
cmp    $0x0,%rax
je     14d7 <wfh_putlength+0x377>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    14fe <wfh_putlength+0x39e>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x4,%edx
call   1080 <wfh_writeint@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wfh_putlength>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %esi,%r14d
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11fc <wfh_putlength+0x9c>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    $0xffffffff,%ebp
cmp    $0x4,%eax
jne    11f2 <wfh_putlength+0x92>
movdqa (%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x46464952,%eax
jne    11f2 <wfh_putlength+0x92>
mov    0x2e21(%rip),%r15
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1060 <fseek@plt>
test   %rax,%rax
jne    11f2 <wfh_putlength+0x92>
lea    0x24(%r14),%esi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1080 <wfh_writeint@plt>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x8,%esi
call   1060 <fseek@plt>
test   %rax,%rax
je     120e <wfh_putlength+0xae>
mov    %rbx,%rdi
call   1050 <fclose@plt>
jmp    1201 <wfh_putlength+0xa1>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    11f2 <wfh_putlength+0x92>
movdqa (%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x45564157,%eax
jne    11f2 <wfh_putlength+0x92>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    11f2 <wfh_putlength+0x92>
movdqa (%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x20746d66,%eax
jne    11f2 <wfh_putlength+0x92>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <wfh_readint@plt>
mov    0x2d72(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <fseek@plt>
test   %rax,%rax
jne    11f2 <wfh_putlength+0x92>
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    11f2 <wfh_putlength+0x92>
movdqa (%rsp),%xmm0
movd   %xmm0,%eax
cmp    $0x61746164,%eax
jne    11f2 <wfh_putlength+0x92>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    $0x28,%esi
call   1060 <fseek@plt>
test   %rax,%rax
jne    11f2 <wfh_putlength+0x92>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    $0x4,%edx
call   1080 <wfh_writeint@plt>
xor    %ebp,%ebp
jmp    11f2 <wfh_putlength+0x92>

LLVM IR (-O0):
@.str = [4 x i8] c"r+b\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i32 @wfh_putlength(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* null, i32** %6
store i32 -1, i32* %7
%10 = load i8*, i8** %4
%11 = call i32* @fopen(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = load i32, i32* %7
store i32 %15, i32* %3
br label %199
16: ; preds = %2
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%18 = load i32*, i32** %6
%19 = call i32 @fread(i8* %17, i32 1, i32 4, i32* %18)
%20 = icmp ne i32 %19, 4
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32*, i32** %6
%23 = call i32 @fclose(i32* %22)
%24 = load i32, i32* %7
store i32 %24, i32* %3
br label %199
25: ; preds = %16
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 82
br i1 %29, label %45, label %30
30: ; preds = %25
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 73
br i1 %34, label %45, label %35
35: ; preds = %30
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 2
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 70
br i1 %39, label %45, label %40
40: ; preds = %35
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 70
br i1 %44, label %45, label %49
45: ; preds = %40, %35, %30, %25
%46 = load i32*, i32** %6
%47 = call i32 @fclose(i32* %46)
%48 = load i32, i32* %7
store i32 %48, i32* %3
br label %199
49: ; preds = %40
%50 = load i32*, i32** %6
%51 = load i32, i32* @SEEK_SET
%52 = call i64 @fseek(i32* %50, i32 4, i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %49
%55 = load i32*, i32** %6
%56 = call i32 @fclose(i32* %55)
%57 = load i32, i32* %7
store i32 %57, i32* %3
br label %199
58: ; preds = %49
%59 = load i32*, i32** %6
%60 = load i32, i32* %5
%61 = add nsw i32 44, %60
%62 = sub nsw i32 %61, 8
%63 = call i32 @wfh_writeint(i32* %59, i32 %62, i32 4)
%64 = load i32*, i32** %6
%65 = load i32, i32* @SEEK_SET
%66 = call i64 @fseek(i32* %64, i32 8, i32 %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %58
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
%71 = load i32, i32* %7
store i32 %71, i32* %3
br label %199
72: ; preds = %58
%73 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%74 = load i32*, i32** %6
%75 = call i32 @fread(i8* %73, i32 1, i32 4, i32* %74)
%76 = icmp ne i32 %75, 4
br i1 %76, label %77, label %81
77: ; preds = %72
%78 = load i32*, i32** %6
%79 = call i32 @fclose(i32* %78)
%80 = load i32, i32* %7
store i32 %80, i32* %3
br label %199
81: ; preds = %72
%82 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %84, 87
br i1 %85, label %101, label %86
86: ; preds = %81
%87 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 65
br i1 %90, label %101, label %91
91: ; preds = %86
%92 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 2
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp ne i32 %94, 86
br i1 %95, label %101, label %96
96: ; preds = %91
%97 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 3
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 69
br i1 %100, label %101, label %105
101: ; preds = %96, %91, %86, %81
%102 = load i32*, i32** %6
%103 = call i32 @fclose(i32* %102)
%104 = load i32, i32* %7
store i32 %104, i32* %3
br label %199
105: ; preds = %96
%106 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%107 = load i32*, i32** %6
%108 = call i32 @fread(i8* %106, i32 1, i32 4, i32* %107)
%109 = icmp ne i32 %108, 4
br i1 %109, label %110, label %114
110: ; preds = %105
%111 = load i32*, i32** %6
%112 = call i32 @fclose(i32* %111)
%113 = load i32, i32* %7
store i32 %113, i32* %3
br label %199
114: ; preds = %105
%115 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp ne i32 %117, 102
br i1 %118, label %134, label %119
119: ; preds = %114
%120 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
%121 = load i8, i8* %120
%122 = sext i8 %121 to i32
%123 = icmp ne i32 %122, 109
br i1 %123, label %134, label %124
124: ; preds = %119
%125 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 2
%126 = load i8, i8* %125
%127 = sext i8 %126 to i32
%128 = icmp ne i32 %127, 116
br i1 %128, label %134, label %129
129: ; preds = %124
%130 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 3
%131 = load i8, i8* %130
%132 = sext i8 %131 to i32
%133 = icmp ne i32 %132, 32
br i1 %133, label %134, label %138
134: ; preds = %129, %124, %119, %114
%135 = load i32*, i32** %6
%136 = call i32 @fclose(i32* %135)
%137 = load i32, i32* %7
store i32 %137, i32* %3
br label %199
138: ; preds = %129
%139 = load i32*, i32** %6
%140 = call i32 @wfh_readint(i32* %139, i32 4)
store i32 %140, i32* %9
%141 = load i32*, i32** %6
%142 = load i32, i32* %9
%143 = load i32, i32* @SEEK_CUR
%144 = call i64 @fseek(i32* %141, i32 %142, i32 %143)
%145 = icmp ne i64 %144, 0
br i1 %145, label %146, label %150
146: ; preds = %138
%147 = load i32*, i32** %6
%148 = call i32 @fclose(i32* %147)
%149 = load i32, i32* %7
store i32 %149, i32* %3
br label %199
150: ; preds = %138
%151 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%152 = load i32*, i32** %6
%153 = call i32 @fread(i8* %151, i32 1, i32 4, i32* %152)
%154 = icmp ne i32 %153, 4
br i1 %154, label %155, label %159
155: ; preds = %150
%156 = load i32*, i32** %6
%157 = call i32 @fclose(i32* %156)
%158 = load i32, i32* %7
store i32 %158, i32* %3
br label %199
159: ; preds = %150
%160 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%161 = load i8, i8* %160
%162 = sext i8 %161 to i32
%163 = icmp ne i32 %162, 100
br i1 %163, label %179, label %164
164: ; preds = %159
%165 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 1
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = icmp ne i32 %167, 97
br i1 %168, label %179, label %169
169: ; preds = %164
%170 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 2
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp ne i32 %172, 116
br i1 %173, label %179, label %174
174: ; preds = %169
%175 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 3
%176 = load i8, i8* %175
%177 = sext i8 %176 to i32
%178 = icmp ne i32 %177, 97
br i1 %178, label %179, label %183
179: ; preds = %174, %169, %164, %159
%180 = load i32*, i32** %6
%181 = call i32 @fclose(i32* %180)
%182 = load i32, i32* %7
store i32 %182, i32* %3
br label %199
183: ; preds = %174
%184 = load i32*, i32** %6
%185 = load i32, i32* @SEEK_SET
%186 = call i64 @fseek(i32* %184, i32 40, i32 %185)
%187 = icmp ne i64 %186, 0
br i1 %187, label %188, label %192
188: ; preds = %183
%189 = load i32*, i32** %6
%190 = call i32 @fclose(i32* %189)
%191 = load i32, i32* %7
store i32 %191, i32* %3
br label %199
192: ; preds = %183
%193 = load i32*, i32** %6
%194 = load i32, i32* %5
%195 = call i32 @wfh_writeint(i32* %193, i32 %194, i32 4)
%196 = load i32*, i32** %6
%197 = call i32 @fclose(i32* %196)
store i32 0, i32* %7
%198 = load i32, i32* %7
store i32 %198, i32* %3
br label %199
199: ; preds = %192, %188, %179, %155, %146, %134, %110, %101, %77, %68, %54, %45, %21, %14
%200 = load i32, i32* %3
ret i32 %200
}

LLVM IR (-O2):
@.str = [4 x i8] c"r+b\00"
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i32 @wfh_putlength(i8* nocapture %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %67, label %7
7: ; preds = %2
%8 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %5)
%9 = icmp eq i32 %8, 4
%10 = bitcast [100 x i8]* %3 to <4 x i8>*
%11 = load <4 x i8>, <4 x i8>* %10
%12 = freeze <4 x i8> %11
%13 = bitcast <4 x i8> %12 to i32
%14 = icmp eq i32 %13, 1179011410
%15 = and i1 %9, %14
br i1 %15, label %16, label %64
16: ; preds = %7
%17 = load i32, i32* @SEEK_SET
%18 = tail call i64 @fseek(i32* %5, i32 4, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %64
20: ; preds = %16
%21 = add nsw i32 %1, 36
%22 = tail call i32 @wfh_writeint(i32* %5, i32 %21, i32 4)
%23 = load i32, i32* @SEEK_SET
%24 = tail call i64 @fseek(i32* %5, i32 8, i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %64
26: ; preds = %20
%27 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %5)
%28 = icmp eq i32 %27, 4
%29 = bitcast [100 x i8]* %3 to <4 x i8>*
%30 = load <4 x i8>, <4 x i8>* %29
%31 = freeze <4 x i8> %30
%32 = bitcast <4 x i8> %31 to i32
%33 = icmp eq i32 %32, 1163280727
%34 = and i1 %28, %33
br i1 %34, label %35, label %64
35: ; preds = %26
%36 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %5)
%37 = icmp eq i32 %36, 4
%38 = bitcast [100 x i8]* %3 to <4 x i8>*
%39 = load <4 x i8>, <4 x i8>* %38
%40 = freeze <4 x i8> %39
%41 = bitcast <4 x i8> %40 to i32
%42 = icmp eq i32 %41, 544501094
%43 = and i1 %37, %42
br i1 %43, label %44, label %64
44: ; preds = %35
%45 = tail call i32 @wfh_readint(i32* %5, i32 4)
%46 = load i32, i32* @SEEK_CUR
%47 = tail call i64 @fseek(i32* %5, i32 %45, i32 %46)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %64
49: ; preds = %44
%50 = call i32 @fread(i8* %4, i32 1, i32 4, i32* %5)
%51 = icmp eq i32 %50, 4
%52 = bitcast [100 x i8]* %3 to <4 x i8>*
%53 = load <4 x i8>, <4 x i8>* %52
%54 = freeze <4 x i8> %53
%55 = bitcast <4 x i8> %54 to i32
%56 = icmp eq i32 %55, 1635017060
%57 = and i1 %51, %56
br i1 %57, label %58, label %64
58: ; preds = %49
%59 = load i32, i32* @SEEK_SET
%60 = tail call i64 @fseek(i32* %5, i32 40, i32 %59)
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = tail call i32 @wfh_writeint(i32* %5, i32 %1, i32 4)
br label %64
64: ; preds = %58, %49, %44, %35, %26, %20, %16, %7, %62
%65 = phi i32 [ 0, %62 ], [ -1, %7 ], [ -1, %16 ], [ -1, %20 ], [ -1, %26 ], [ -1, %35 ], [ -1, %44 ], [ -1, %49 ], [ -1, %58 ]
%66 = tail call i32 @fclose(i32* %5)
br label %67
67: ; preds = %64, %2
%68 = phi i32 [ -1, %2 ], [ %65, %64 ]
ret i32 %68
}