#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 */
unsigned char calc_sum(unsigned char *, unsigned char);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ memcmp(unsigned char *, char *, int);
int /*<<< orphan*/ stderr;
char *strndup(char *, unsigned char);
unsigned int LH5HeaderParse(unsigned char *Buffer, int BufferSize,
                            unsigned int *original_size,
                            unsigned int *packed_size, char **name,
                            unsigned short *crc) {
  unsigned int offset;
  unsigned char header_size, checksum, name_length;
  if (BufferSize < 27) {
    fprintf(stderr,
            "Error: Packed Buffer is too small to contain an lha header.\n");
    return 0;
  }
  if (Buffer[19] != 0x20) {
    fprintf(stderr, "Error: Invalid lha header attribute byte.\n");
    return 0;
  }
  if (memcmp(Buffer + 2, "-lh5-", 5) != 0) {
    fprintf(stderr, "Error: Compression method is not LZHUFF5.\n");
    return 0;
  }
  if (Buffer[20] != 1) {
    fprintf(stderr, "Error: Header level %d is not supported\n", Buffer[20]);
    return 0;
  }
  header_size = Buffer[0];
  if (BufferSize < (header_size + 2)) {
    fprintf(stderr,
            "Error: Packed Buffer is too small to contain the full header.\n");
    return 0;
  }
  checksum = Buffer[1];
  if (calc_sum(Buffer + 2, header_size) != checksum) {
    fprintf(stderr, "Error: Invalid lha header checksum.\n");
    return 0;
  }
  *packed_size = (*(unsigned int *)(Buffer + 7));
  *original_size = (*(unsigned int *)(Buffer + 11));
  name_length = Buffer[21];
  *name = strndup((char *)Buffer + 22, name_length);
  *crc = (*(unsigned short *)(Buffer + 22 + name_length));
  offset = header_size + 2;
  while (1) {
    unsigned short extend_size = (*(unsigned short *)(Buffer + offset - 2));
    if (!extend_size)
      break;
    *packed_size -= extend_size;
    offset += extend_size;
    if (BufferSize < offset) {
      fprintf(stderr, "Error: Buffer to small to contain extended header.\n");
      return 0;
    }
  }
  return offset;
}


x86 assembly (clang, -O0):
<LH5HeaderParse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpl   $0x1b,-0x14(%rbp)
jge    118c <LH5HeaderParse+0x4c>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rax
movzbl 0x13(%rax),%eax
cmp    $0x20,%eax
je     11c0 <LH5HeaderParse+0x80>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
lea    0xe99(%rip),%rsi
mov    $0x5,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     1206 <LH5HeaderParse+0xc6>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rax
movzbl 0x14(%rax),%eax
cmp    $0x1,%eax
je     1242 <LH5HeaderParse+0x102>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movzbl 0x14(%rax),%edx
lea    0xe6a(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x3d(%rbp)
mov    -0x14(%rbp),%eax
movzbl -0x3d(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1280 <LH5HeaderParse+0x140>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0x3e(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
movzbl -0x3d(%rbp),%esi
call   1050 <calc_sum@plt>
movzbl %al,%eax
movzbl -0x3e(%rbp),%ecx
cmp    %ecx,%eax
je     12cd <LH5HeaderParse+0x18d>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
mov    -0x10(%rbp),%rax
mov    0x7(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0xb(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x15(%rax),%al
mov    %al,-0x3f(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x16,%rdi
movzbl -0x3f(%rbp),%esi
call   1030 <strndup@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
movzbl -0x3f(%rbp),%ecx
movslq %ecx,%rcx
mov    0x16(%rax,%rcx,1),%cx
mov    -0x38(%rbp),%rax
mov    %cx,(%rax)
movzbl -0x3d(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x3c(%rbp),%ecx
mov    -0x2(%rax,%rcx,1),%ax
mov    %ax,-0x42(%rbp)
cmpw   $0x0,-0x42(%rbp)
jne    134d <LH5HeaderParse+0x20d>
jmp    1399 <LH5HeaderParse+0x259>
movzwl -0x42(%rbp),%edx
mov    -0x28(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
movzwl -0x42(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jae    1394 <LH5HeaderParse+0x254>
mov    0x2c68(%rip),%rax
mov    (%rax),%edi
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <LH5HeaderParse+0x25f>
jmp    132d <LH5HeaderParse+0x1ed>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LH5HeaderParse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x1a,%esi
jg     1165 <LH5HeaderParse+0x25>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
jmp    11bd <LH5HeaderParse+0x7d>
mov    %rdi,%r15
cmpb   $0x20,0x13(%rdi)
jne    11ad <LH5HeaderParse+0x6d>
mov    %r9,%rbx
mov    %r8,%r13
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rcx,0x10(%rsp)
lea    0x2(%r15),%r14
lea    0xedf(%rip),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
call   1040 <memcmp@plt>
test   %rax,%rax
je     11d7 <LH5HeaderParse+0x97>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xec3(%rip),%rsi
jmp    11bd <LH5HeaderParse+0x7d>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movzbl 0x14(%r15),%edx
cmp    $0x1,%edx
jne    1203 <LH5HeaderParse+0xc3>
mov    %rbx,0x8(%rsp)
movzbl (%r15),%eax
lea    0x2(%rax),%ebx
cmp    %ebp,%ebx
jbe    121e <LH5HeaderParse+0xde>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
jmp    11bd <LH5HeaderParse+0x7d>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    11c6 <LH5HeaderParse+0x86>
mov    %r14,%rdi
mov    0x1(%r15),%r14b
movzbl %al,%esi
call   1050 <calc_sum@plt>
cmp    %r14b,%al
jne    1297 <LH5HeaderParse+0x157>
mov    0x7(%r15),%eax
mov    0x10(%rsp),%r14
mov    %eax,(%r14)
mov    0xb(%r15),%eax
mov    %eax,(%r12)
movzbl 0x15(%r15),%r12d
lea    0x16(%r15),%rdi
mov    %r12d,%esi
call   1030 <strndup@plt>
mov    %rax,0x0(%r13)
movzwl 0x16(%r15,%r12,1),%eax
mov    0x8(%rsp),%rcx
mov    %ax,(%rcx)
mov    %ebx,%eax
movzwl -0x2(%r15,%rax,1),%eax
test   %eax,%eax
je     11c6 <LH5HeaderParse+0x86>
sub    %eax,(%r14)
add    %eax,%ebx
cmp    %ebp,%ebx
jbe    1269 <LH5HeaderParse+0x129>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
jmp    11bd <LH5HeaderParse+0x7d>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
jmp    11bd <LH5HeaderParse+0x7d>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [61 x i8] c"Error: Packed Buffer is too small to contain an lha header.\0A\00"
@.str.1 = [43 x i8] c"Error: Invalid lha header attribute byte.\0A\00"
@.str.2 = [6 x i8] c"-lh5-\00"
@.str.3 = [43 x i8] c"Error: Compression method is not LZHUFF5.\0A\00"
@.str.4 = [41 x i8] c"Error: Header level %d is not supported\0A\00"
@.str.5 = [63 x i8] c"Error: Packed Buffer is too small to contain the full header.\0A\00"
@.str.6 = [37 x i8] c"Error: Invalid lha header checksum.\0A\00"
@.str.7 = [52 x i8] c"Error: Buffer to small to contain extended header.\0A\00"
define i32 @LH5HeaderParse(i8* %0, i32 %1, i32* %2, i32* %3, i8** %4, i16* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i8**
%13 = alloca i16*
%14 = alloca i32
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i16
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i8** %4, i8*** %12
store i16* %5, i16** %13
%19 = load i32, i32* %9
%20 = icmp slt i32 %19, 27
br i1 %20, label %21, label %24
21: ; preds = %6
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
br label %142
24: ; preds = %6
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 19
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = icmp ne i32 %28, 32
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %142
33: ; preds = %24
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = call i64 @memcmp(i8* %35, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %142
41: ; preds = %33
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 20
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = icmp ne i32 %45, 1
br i1 %46, label %47, label %54
47: ; preds = %41
%48 = load i32, i32* @stderr
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i64 20
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %52)
store i32 0, i32* %7
br label %142
54: ; preds = %41
%55 = load i8*, i8** %8
%56 = getelementptr inbounds i8, i8* %55, i64 0
%57 = load i8, i8* %56
store i8 %57, i8* %15
%58 = load i32, i32* %9
%59 = load i8, i8* %15
%60 = zext i8 %59 to i32
%61 = add nsw i32 %60, 2
%62 = icmp slt i32 %58, %61
br i1 %62, label %63, label %66
63: ; preds = %54
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %7
br label %142
66: ; preds = %54
%67 = load i8*, i8** %8
%68 = getelementptr inbounds i8, i8* %67, i64 1
%69 = load i8, i8* %68
store i8 %69, i8* %16
%70 = load i8*, i8** %8
%71 = getelementptr inbounds i8, i8* %70, i64 2
%72 = load i8, i8* %15
%73 = call zeroext i8 @calc_sum(i8* %71, i8 zeroext %72)
%74 = zext i8 %73 to i32
%75 = load i8, i8* %16
%76 = zext i8 %75 to i32
%77 = icmp ne i32 %74, %76
br i1 %77, label %78, label %81
78: ; preds = %66
%79 = load i32, i32* @stderr
%80 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %7
br label %142
81: ; preds = %66
%82 = load i8*, i8** %8
%83 = getelementptr inbounds i8, i8* %82, i64 7
%84 = bitcast i8* %83 to i32*
%85 = load i32, i32* %84
%86 = load i32*, i32** %11
store i32 %85, i32* %86
%87 = load i8*, i8** %8
%88 = getelementptr inbounds i8, i8* %87, i64 11
%89 = bitcast i8* %88 to i32*
%90 = load i32, i32* %89
%91 = load i32*, i32** %10
store i32 %90, i32* %91
%92 = load i8*, i8** %8
%93 = getelementptr inbounds i8, i8* %92, i64 21
%94 = load i8, i8* %93
store i8 %94, i8* %17
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i64 22
%97 = load i8, i8* %17
%98 = call i8* @strndup(i8* %96, i8 zeroext %97)
%99 = load i8**, i8*** %12
store i8* %98, i8** %99
%100 = load i8*, i8** %8
%101 = getelementptr inbounds i8, i8* %100, i64 22
%102 = load i8, i8* %17
%103 = zext i8 %102 to i32
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i8, i8* %101, i64 %104
%106 = bitcast i8* %105 to i16*
%107 = load i16, i16* %106
%108 = load i16*, i16** %13
store i16 %107, i16* %108
%109 = load i8, i8* %15
%110 = zext i8 %109 to i32
%111 = add nsw i32 %110, 2
store i32 %111, i32* %14
br label %112
112: ; preds = %81, %139
%113 = load i8*, i8** %8
%114 = load i32, i32* %14
%115 = zext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = getelementptr inbounds i8, i8* %116, i64 -2
%118 = bitcast i8* %117 to i16*
%119 = load i16, i16* %118
store i16 %119, i16* %18
%120 = load i16, i16* %18
%121 = icmp ne i16 %120, 0
br i1 %121, label %123, label %122
122: ; preds = %112
br label %140
123: ; preds = %112
%124 = load i16, i16* %18
%125 = zext i16 %124 to i32
%126 = load i32*, i32** %11
%127 = load i32, i32* %126
%128 = sub i32 %127, %125
store i32 %128, i32* %126
%129 = load i16, i16* %18
%130 = zext i16 %129 to i32
%131 = load i32, i32* %14
%132 = add i32 %131, %130
store i32 %132, i32* %14
%133 = load i32, i32* %9
%134 = load i32, i32* %14
%135 = icmp ult i32 %133, %134
br i1 %135, label %136, label %139
136: ; preds = %123
%137 = load i32, i32* @stderr
%138 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %7
br label %142
139: ; preds = %123
br label %112
140: ; preds = %122
%141 = load i32, i32* %14
store i32 %141, i32* %7
br label %142
142: ; preds = %140, %136, %78, %63, %47, %38, %30, %21
%143 = load i32, i32* %7
ret i32 %143
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [61 x i8] c"Error: Packed Buffer is too small to contain an lha header.\0A\00"
@.str.1 = [43 x i8] c"Error: Invalid lha header attribute byte.\0A\00"
@.str.2 = [6 x i8] c"-lh5-\00"
@.str.3 = [43 x i8] c"Error: Compression method is not LZHUFF5.\0A\00"
@.str.4 = [41 x i8] c"Error: Header level %d is not supported\0A\00"
@.str.5 = [63 x i8] c"Error: Packed Buffer is too small to contain the full header.\0A\00"
@.str.6 = [37 x i8] c"Error: Invalid lha header checksum.\0A\00"
@.str.7 = [52 x i8] c"Error: Buffer to small to contain extended header.\0A\00"
define i32 @LH5HeaderParse(i8* %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture %3, i8** nocapture writeonly %4, i16* nocapture writeonly %5) {
%7 = icmp slt i32 %1, 27
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
br label %81
11: ; preds = %6
%12 = getelementptr inbounds i8, i8* %0, i64 19
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %81
18: ; preds = %11
%19 = getelementptr inbounds i8, i8* %0, i64 2
%20 = tail call i64 @memcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0))
br label %81
25: ; preds = %18
%26 = getelementptr inbounds i8, i8* %0, i64 20
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 1
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = zext i8 %27 to i32
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %30)
br label %81
33: ; preds = %25
%34 = load i8, i8* %0
%35 = zext i8 %34 to i32
%36 = add nuw nsw i32 %35, 2
%37 = icmp ugt i32 %36, %1
br i1 %37, label %38, label %41
38: ; preds = %33
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
br label %81
41: ; preds = %33
%42 = getelementptr inbounds i8, i8* %0, i64 1
%43 = load i8, i8* %42
%44 = tail call zeroext i8 @calc_sum(i8* %19, i8 zeroext %34)
%45 = icmp eq i8 %44, %43
br i1 %45, label %49, label %46
46: ; preds = %41
%47 = load i32, i32* @stderr
%48 = tail call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %81
49: ; preds = %41
%50 = getelementptr inbounds i8, i8* %0, i64 7
%51 = bitcast i8* %50 to i32*
%52 = load i32, i32* %51
store i32 %52, i32* %3
%53 = getelementptr inbounds i8, i8* %0, i64 11
%54 = bitcast i8* %53 to i32*
%55 = load i32, i32* %54
store i32 %55, i32* %2
%56 = getelementptr inbounds i8, i8* %0, i64 21
%57 = load i8, i8* %56
%58 = getelementptr inbounds i8, i8* %0, i64 22
%59 = tail call i8* @strndup(i8* %58, i8 zeroext %57)
store i8* %59, i8** %4
%60 = zext i8 %57 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = bitcast i8* %61 to i16*
%63 = load i16, i16* %62
store i16 %63, i16* %5
%64 = getelementptr inbounds i8, i8* %0, i64 -2
br label %65
65: ; preds = %72, %49
%66 = phi i32 [ %36, %49 ], [ %76, %72 ]
%67 = zext i32 %66 to i64
%68 = getelementptr inbounds i8, i8* %64, i64 %67
%69 = bitcast i8* %68 to i16*
%70 = load i16, i16* %69
%71 = icmp eq i16 %70, 0
br i1 %71, label %81, label %72
72: ; preds = %65
%73 = zext i16 %70 to i32
%74 = load i32, i32* %3
%75 = sub i32 %74, %73
store i32 %75, i32* %3
%76 = add i32 %66, %73
%77 = icmp ugt i32 %76, %1
br i1 %77, label %78, label %65
78: ; preds = %72
%79 = load i32, i32* @stderr
%80 = tail call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
br label %81
81: ; preds = %65, %78, %46, %38, %29, %22, %15, %8
%82 = phi i32 [ 0, %8 ], [ 0, %15 ], [ 0, %22 ], [ 0, %29 ], [ 0, %38 ], [ 0, %46 ], [ 0, %78 ], [ %66, %65 ]
ret i32 %82
}