#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;
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned long getid3v2(FILE *in, unsigned long start) {
  char c1, c2, c3, c4;
  fseek(in, start, SEEK_SET);
  if (fgetc(in) == 'I')
    if (fgetc(in) == 'D')
      if (fgetc(in) == '3') {
        fseek(in, 3, SEEK_CUR);
        c1 = fgetc(in);
        c2 = fgetc(in);
        c3 = fgetc(in);
        c4 = fgetc(in);
        return c1 * 2097151 + c2 * 16384 + c3 * 128 + c4;
      }
  return 0;
}


x86 assembly (clang, -O0):
<getid3v2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %eax,%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x49,%eax
jne    1205 <getid3v2+0xe5>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x44,%eax
jne    1200 <getid3v2+0xe0>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
movsbl %al,%eax
cmp    $0x33,%eax
jne    11fb <getid3v2+0xdb>
mov    -0x10(%rbp),%rdi
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x19(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1a(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1b(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x1c(%rbp)
movsbl -0x19(%rbp),%eax
imul   $0x1fffff,%eax,%eax
movsbl -0x1a(%rbp),%ecx
shl    $0xe,%ecx
add    %ecx,%eax
movsbl -0x1b(%rbp),%ecx
shl    $0x7,%ecx
add    %ecx,%eax
movsbl -0x1c(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x8(%rbp)
jmp    120d <getid3v2+0xed>
jmp    1200 <getid3v2+0xe0>
jmp    1205 <getid3v2+0xe5>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getid3v2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
call   1040 <fseek@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x49,%al
jne    11c0 <getid3v2+0xa0>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x44,%al
jne    11c0 <getid3v2+0xa0>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
cmp    $0x33,%al
jne    11c0 <getid3v2+0xa0>
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <fseek@plt>
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <fgetc@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <fgetc@plt>
movsbl %bpl,%ecx
mov    %ecx,%edx
shl    $0x15,%edx
sub    %ecx,%edx
movsbl %r14b,%ecx
shl    $0xe,%ecx
add    %edx,%ecx
movsbl %r15b,%edx
shl    $0x7,%edx
add    %ecx,%edx
movsbl %al,%eax
add    %edx,%eax
cltq
jmp    11c2 <getid3v2+0xa2>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i64 @getid3v2(i32* %0, i64 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
store i32* %0, i32** %4
store i64 %1, i64* %5
%10 = load i32*, i32** %4
%11 = load i64, i64* %5
%12 = trunc i64 %11 to i32
%13 = load i32, i32* @SEEK_SET
%14 = call i32 @fseek(i32* %10, i32 %12, i32 %13)
%15 = load i32*, i32** %4
%16 = call signext i8 @fgetc(i32* %15)
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 73
br i1 %18, label %19, label %58
19: ; preds = %2
%20 = load i32*, i32** %4
%21 = call signext i8 @fgetc(i32* %20)
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 68
br i1 %23, label %24, label %57
24: ; preds = %19
%25 = load i32*, i32** %4
%26 = call signext i8 @fgetc(i32* %25)
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 51
br i1 %28, label %29, label %56
29: ; preds = %24
%30 = load i32*, i32** %4
%31 = load i32, i32* @SEEK_CUR
%32 = call i32 @fseek(i32* %30, i32 3, i32 %31)
%33 = load i32*, i32** %4
%34 = call signext i8 @fgetc(i32* %33)
store i8 %34, i8* %6
%35 = load i32*, i32** %4
%36 = call signext i8 @fgetc(i32* %35)
store i8 %36, i8* %7
%37 = load i32*, i32** %4
%38 = call signext i8 @fgetc(i32* %37)
store i8 %38, i8* %8
%39 = load i32*, i32** %4
%40 = call signext i8 @fgetc(i32* %39)
store i8 %40, i8* %9
%41 = load i8, i8* %6
%42 = sext i8 %41 to i32
%43 = mul nsw i32 %42, 2097151
%44 = load i8, i8* %7
%45 = sext i8 %44 to i32
%46 = mul nsw i32 %45, 16384
%47 = add nsw i32 %43, %46
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = mul nsw i32 %49, 128
%51 = add nsw i32 %47, %50
%52 = load i8, i8* %9
%53 = sext i8 %52 to i32
%54 = add nsw i32 %51, %53
%55 = sext i32 %54 to i64
store i64 %55, i64* %3
br label %59
56: ; preds = %24
br label %57
57: ; preds = %56, %19
br label %58
58: ; preds = %57, %2
store i64 0, i64* %3
br label %59
59: ; preds = %58, %29
%60 = load i64, i64* %3
ret i64 %60
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@SEEK_CUR = global i32 0
define i64 @getid3v2(i32* nocapture %0, i64 %1) {
%3 = trunc i64 %1 to i32
%4 = load i32, i32* @SEEK_SET
%5 = tail call i32 @fseek(i32* %0, i32 %3, i32 %4)
%6 = tail call signext i8 @fgetc(i32* %0)
%7 = icmp eq i8 %6, 73
br i1 %7, label %8, label %32
8: ; preds = %2
%9 = tail call signext i8 @fgetc(i32* %0)
%10 = icmp eq i8 %9, 68
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = tail call signext i8 @fgetc(i32* %0)
%13 = icmp eq i8 %12, 51
br i1 %13, label %14, label %32
14: ; preds = %11
%15 = load i32, i32* @SEEK_CUR
%16 = tail call i32 @fseek(i32* %0, i32 3, i32 %15)
%17 = tail call signext i8 @fgetc(i32* %0)
%18 = tail call signext i8 @fgetc(i32* %0)
%19 = tail call signext i8 @fgetc(i32* %0)
%20 = tail call signext i8 @fgetc(i32* %0)
%21 = sext i8 %17 to i32
%22 = mul nsw i32 %21, 2097151
%23 = sext i8 %18 to i32
%24 = shl nsw i32 %23, 14
%25 = add nsw i32 %24, %22
%26 = sext i8 %19 to i32
%27 = shl nsw i32 %26, 7
%28 = add nsw i32 %25, %27
%29 = sext i8 %20 to i32
%30 = add nsw i32 %28, %29
%31 = sext i32 %30 to i64
br label %32
32: ; preds = %2, %11, %8, %14
%33 = phi i64 [ %31, %14 ], [ 0, %8 ], [ 0, %11 ], [ 0, %2 ]
ret i64 %33
}