#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*/ IsTextInfoID3FrameID(char *);
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int fread(char *, size_t, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(size_t);
char *ReadTextInfoFrame(FILE *inf) {
  long originalpos = 0;
  char buffer[5] = {0};
  char buffer2[7] = {0};
  char *string = NULL;
  unsigned long framesize = 0;
  if (inf == NULL)
    return NULL;
  originalpos = ftell(inf);
  if (originalpos < 0)
    return NULL;
  if (fread(buffer, 4, 1, inf) != 1)
    return NULL;
  if (fread(buffer2, 7, 1, inf) != 1)
    return NULL;
  if (!IsTextInfoID3FrameID(buffer) || ((buffer2[5] & 192) != 0) ||
      (buffer2[6] != 0)) {
    (void)fseek(inf, originalpos, SEEK_SET);
    return NULL;
  }
  framesize = ((unsigned long)buffer2[0] << 24) |
              ((unsigned long)buffer2[1] << 16) |
              ((unsigned long)buffer2[2] << 8) | ((unsigned long)buffer2[3]);
  assert(framesize <= 10000);
  if (framesize < 2) {
    (void)fseek(inf, originalpos, SEEK_SET);
    return NULL;
  }
  string = malloc((size_t)framesize);
  if (!string) {
    (void)fseek(inf, originalpos, SEEK_SET);
    return NULL;
  }
  if (fread(string, (size_t)framesize - 1, 1, inf) != 1) {
    (void)fseek(inf, originalpos, SEEK_SET);
    free(string);
    return NULL;
  }
  string[framesize - 1] = '\0';
  return string;
}


x86 assembly (clang, -O0):
<ReadTextInfoFrame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x1d(%rbp),%rdi
xor    %esi,%esi
mov    $0x5,%edx
call   1050 <memset@plt>
lea    -0x24(%rbp),%rdi
xor    %esi,%esi
mov    $0x7,%edx
call   1050 <memset@plt>
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11dc <ReadTextInfoFrame+0x5c>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
mov    -0x10(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jge    1201 <ReadTextInfoFrame+0x81>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
lea    -0x1d(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     122e <ReadTextInfoFrame+0xae>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
lea    -0x24(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x7,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     125b <ReadTextInfoFrame+0xdb>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
lea    -0x1d(%rbp),%rdi
call   10a0 <IsTextInfoID3FrameID@plt>
cmp    $0x0,%eax
je     128c <ReadTextInfoFrame+0x10c>
movsbl -0x1f(%rbp),%eax
and    $0xc0,%eax
cmp    $0x0,%eax
jne    128c <ReadTextInfoFrame+0x10c>
movsbl -0x1e(%rbp),%eax
cmp    $0x0,%eax
je     12af <ReadTextInfoFrame+0x12f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2d45(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
movsbq -0x24(%rbp),%rax
shl    $0x18,%rax
movsbq -0x23(%rbp),%rcx
shl    $0x10,%rcx
or     %rcx,%rax
movsbq -0x22(%rbp),%rcx
shl    $0x8,%rcx
or     %rcx,%rax
movsbq -0x21(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x2710,-0x38(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x2,-0x38(%rbp)
jae    131f <ReadTextInfoFrame+0x19f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2cd5(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
mov    -0x38(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    135a <ReadTextInfoFrame+0x1da>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2c9a(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x10(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
je     13a9 <ReadTextInfoFrame+0x229>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2c54(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    13c1 <ReadTextInfoFrame+0x241>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadTextInfoFrame>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movb   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xb(%rsp)
movl   $0x0,0x8(%rsp)
test   %rdi,%rdi
je     12a1 <ReadTextInfoFrame+0x131>
mov    %rdi,%r15
call   1060 <ftell@plt>
test   %rax,%rax
js     12a1 <ReadTextInfoFrame+0x131>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    12a1 <ReadTextInfoFrame+0x131>
lea    0x8(%rsp),%rdi
mov    $0x7,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    12a1 <ReadTextInfoFrame+0x131>
lea    0x10(%rsp),%rdi
call   1090 <IsTextInfoID3FrameID@plt>
test   %eax,%eax
je     128d <ReadTextInfoFrame+0x11d>
cmpb   $0x3f,0xd(%rsp)
ja     128d <ReadTextInfoFrame+0x11d>
cmpb   $0x0,0xe(%rsp)
jne    128d <ReadTextInfoFrame+0x11d>
movsbq 0x8(%rsp),%rax
shl    $0x18,%rax
movsbq 0x9(%rsp),%rcx
shl    $0x10,%rcx
or     %rax,%rcx
movsbq 0xa(%rsp),%rax
shl    $0x8,%rax
movsbq 0xb(%rsp),%r12
or     %rax,%r12
or     %rcx,%r12
xor    %edi,%edi
cmp    $0x2711,%r12
setb   %dil
call   1050 <assert@plt>
cmp    $0x1,%r12
jbe    128d <ReadTextInfoFrame+0x11d>
mov    %r12,%rdi
call   1070 <malloc@plt>
test   %rax,%rax
je     128d <ReadTextInfoFrame+0x11d>
mov    %rax,%rbx
add    $0xffffffffffffffff,%r12
mov    %rax,%rdi
mov    %r12,%rsi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    12b2 <ReadTextInfoFrame+0x142>
movb   $0x0,(%rbx,%r12,1)
jmp    12a3 <ReadTextInfoFrame+0x133>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <fseek@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d27(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <fseek@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    12a1 <ReadTextInfoFrame+0x131>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i8* @ReadTextInfoFrame(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i64
%5 = alloca [5 x i8]
%6 = alloca [7 x i8]
%7 = alloca i8*
%8 = alloca i64
store i32* %0, i32** %3
store i64 0, i64* %4
%9 = bitcast [5 x i8]* %5 to i8*
%10 = bitcast [7 x i8]* %6 to i8*
store i8* null, i8** %7
store i64 0, i64* %8
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
store i8* null, i8** %2
br label %112
14: ; preds = %1
%15 = load i32*, i32** %3
%16 = call i64 @ftell(i32* %15)
store i64 %16, i64* %4
%17 = load i64, i64* %4
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i8* null, i8** %2
br label %112
20: ; preds = %14
%21 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%22 = load i32*, i32** %3
%23 = call i32 @fread(i8* %21, i64 4, i32 1, i32* %22)
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %26
25: ; preds = %20
store i8* null, i8** %2
br label %112
26: ; preds = %20
%27 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%28 = load i32*, i32** %3
%29 = call i32 @fread(i8* %27, i64 7, i32 1, i32* %28)
%30 = icmp ne i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %26
store i8* null, i8** %2
br label %112
32: ; preds = %26
%33 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%34 = call i32 @IsTextInfoID3FrameID(i8* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 5
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = and i32 %39, 192
%41 = icmp ne i32 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %36
%43 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 6
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %42, %36, %32
%48 = load i32*, i32** %3
%49 = load i64, i64* %4
%50 = load i32, i32* @SEEK_SET
%51 = call i32 @fseek(i32* %48, i64 %49, i32 %50)
store i8* null, i8** %2
br label %112
52: ; preds = %42
%53 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%54 = load i8, i8* %53
%55 = sext i8 %54 to i64
%56 = shl i64 %55, 24
%57 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 1
%58 = load i8, i8* %57
%59 = sext i8 %58 to i64
%60 = shl i64 %59, 16
%61 = or i64 %56, %60
%62 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 2
%63 = load i8, i8* %62
%64 = sext i8 %63 to i64
%65 = shl i64 %64, 8
%66 = or i64 %61, %65
%67 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 3
%68 = load i8, i8* %67
%69 = sext i8 %68 to i64
%70 = or i64 %66, %69
store i64 %70, i64* %8
%71 = load i64, i64* %8
%72 = icmp ule i64 %71, 10000
%73 = zext i1 %72 to i32
%74 = call i32 @assert(i32 %73)
%75 = load i64, i64* %8
%76 = icmp ult i64 %75, 2
br i1 %76, label %77, label %82
77: ; preds = %52
%78 = load i32*, i32** %3
%79 = load i64, i64* %4
%80 = load i32, i32* @SEEK_SET
%81 = call i32 @fseek(i32* %78, i64 %79, i32 %80)
store i8* null, i8** %2
br label %112
82: ; preds = %52
%83 = load i64, i64* %8
%84 = call i8* @malloc(i64 %83)
store i8* %84, i8** %7
%85 = load i8*, i8** %7
%86 = icmp ne i8* %85, null
br i1 %86, label %92, label %87
87: ; preds = %82
%88 = load i32*, i32** %3
%89 = load i64, i64* %4
%90 = load i32, i32* @SEEK_SET
%91 = call i32 @fseek(i32* %88, i64 %89, i32 %90)
store i8* null, i8** %2
br label %112
92: ; preds = %82
%93 = load i8*, i8** %7
%94 = load i64, i64* %8
%95 = sub i64 %94, 1
%96 = load i32*, i32** %3
%97 = call i32 @fread(i8* %93, i64 %95, i32 1, i32* %96)
%98 = icmp ne i32 %97, 1
br i1 %98, label %99, label %106
99: ; preds = %92
%100 = load i32*, i32** %3
%101 = load i64, i64* %4
%102 = load i32, i32* @SEEK_SET
%103 = call i32 @fseek(i32* %100, i64 %101, i32 %102)
%104 = load i8*, i8** %7
%105 = call i32 @free(i8* %104)
store i8* null, i8** %2
br label %112
106: ; preds = %92
%107 = load i8*, i8** %7
%108 = load i64, i64* %8
%109 = sub i64 %108, 1
%110 = getelementptr inbounds i8, i8* %107, i64 %109
store i8 0, i8* %110
%111 = load i8*, i8** %7
store i8* %111, i8** %2
br label %112
112: ; preds = %106, %99, %87, %77, %47, %31, %25, %19, %13
%113 = load i8*, i8** %2
ret i8* %113
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define noalias i8* @ReadTextInfoFrame(i32* %0) {
%2 = alloca [5 x i8]
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32* %0, null
br i1 %6, label %71, label %7
7: ; preds = %1
%8 = tail call i64 @ftell(i32* %0)
%9 = icmp slt i64 %8, 0
br i1 %9, label %71, label %10
10: ; preds = %7
%11 = call i32 @fread(i8* %4, i64 4, i32 1, i32* %0)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %71
13: ; preds = %10
%14 = call i32 @fread(i8* %5, i64 7, i32 1, i32* %0)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %71
16: ; preds = %13
%17 = call i32 @IsTextInfoID3FrameID(i8* %4)
%18 = icmp eq i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
%21 = load i8, i8* %20
%22 = icmp ugt i8 %21, 63
%23 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 0
%26 = select i1 %22, i1 true, i1 %25
br i1 %26, label %27, label %30
27: ; preds = %19, %16
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %0, i64 %8, i32 %28)
br label %71
30: ; preds = %19
%31 = load i8, i8* %5
%32 = sext i8 %31 to i64
%33 = shl nsw i64 %32, 24
%34 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i64
%37 = shl nsw i64 %36, 16
%38 = or i64 %37, %33
%39 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
%40 = load i8, i8* %39
%41 = sext i8 %40 to i64
%42 = shl nsw i64 %41, 8
%43 = or i64 %38, %42
%44 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
%45 = load i8, i8* %44
%46 = sext i8 %45 to i64
%47 = or i64 %43, %46
%48 = icmp ult i64 %47, 10001
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
%51 = icmp ult i64 %47, 2
br i1 %51, label %52, label %55
52: ; preds = %30
%53 = load i32, i32* @SEEK_SET
%54 = call i32 @fseek(i32* %0, i64 %8, i32 %53)
br label %71
55: ; preds = %30
%56 = call i8* @malloc(i64 %47)
%57 = icmp eq i8* %56, null
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* @SEEK_SET
%60 = call i32 @fseek(i32* %0, i64 %8, i32 %59)
br label %71
61: ; preds = %55
%62 = add nsw i64 %47, -1
%63 = call i32 @fread(i8* %56, i64 %62, i32 1, i32* %0)
%64 = icmp eq i32 %63, 1
br i1 %64, label %69, label %65
65: ; preds = %61
%66 = load i32, i32* @SEEK_SET
%67 = call i32 @fseek(i32* %0, i64 %8, i32 %66)
%68 = call i32 @free(i8* %56)
br label %71
69: ; preds = %61
%70 = getelementptr inbounds i8, i8* %56, i64 %62
store i8 0, i8* %70
br label %71
71: ; preds = %13, %10, %7, %1, %69, %65, %58, %52, %27
%72 = phi i8* [ null, %27 ], [ null, %52 ], [ null, %65 ], [ %56, %69 ], [ null, %58 ], [ null, %1 ], [ null, %7 ], [ null, %10 ], [ null, %13 ]
ret i8* %72
}