#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 */
int /*<<< orphan*/ SEEK_SET;
scalar_t__ calloc(int, int);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ r_read(int, unsigned char *, int);
scalar_t__ strncmp(unsigned char *, char *, int);
int *da_get_current_tag_info(int file_fd) {
  unsigned char buffer[10];
  int *tag_info;
  tag_info = (int *)calloc(2, sizeof(int));
  r_read(file_fd, buffer, 10);
  if (strncmp(buffer, "ID3", 3) == 0) {
    tag_info[0] = buffer[3];
    tag_info[1] =
        (buffer[6] << 21) + (buffer[7] << 14) + (buffer[8] << 7) + buffer[9];
    return tag_info;
  } else {
    lseek(file_fd, 0, SEEK_SET);
    tag_info[0] = 2;
    tag_info[1] = 0;
    return tag_info;
  }
}


x86 assembly (clang, -O0):
<da_get_current_tag_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x16(%rbp),%rsi
mov    $0xa,%edx
call   1060 <r_read@plt>
lea    -0x16(%rbp),%rdi
lea    0xe86(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11cb <da_get_current_tag_info+0x8b>
movzbl -0x13(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movzbl -0x10(%rbp),%ecx
shl    $0x15,%ecx
movzbl -0xf(%rbp),%eax
shl    $0xe,%eax
add    %eax,%ecx
movzbl -0xe(%rbp),%eax
shl    $0x7,%eax
add    %eax,%ecx
movzbl -0xd(%rbp),%eax
add    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fb <da_get_current_tag_info+0xbb>
mov    -0xc(%rbp),%edi
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    -0x20(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<da_get_current_tag_info>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r15d
mov    $0x2,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
lea    0xe(%rsp),%r14
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1060 <r_read@plt>
lea    0xe85(%rip),%rsi
mov    %r14,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11aa <da_get_current_tag_info+0x6a>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %r15d,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
movl   $0x2,(%rbx)
jmp    11d4 <da_get_current_tag_info+0x94>
movzbl 0x11(%rsp),%eax
mov    %eax,(%rbx)
movzbl 0x14(%rsp),%eax
shl    $0x15,%eax
movzbl 0x15(%rsp),%ecx
shl    $0xe,%ecx
add    %eax,%ecx
movzbl 0x16(%rsp),%eax
shl    $0x7,%eax
add    %ecx,%eax
movzbl 0x17(%rsp),%ebp
add    %eax,%ebp
mov    %ebp,0x4(%rbx)
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"ID3\00"
@SEEK_SET = global i32 0
define i32* @da_get_current_tag_info(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [10 x i8]
%5 = alloca i32*
store i32 %0, i32* %3
%6 = call i64 @calloc(i32 2, i32 4)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %5
%8 = load i32, i32* %3
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%10 = call i32 @r_read(i32 %8, i8* %9, i32 10)
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %41
14: ; preds = %1
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 3
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = load i32*, i32** %5
%19 = getelementptr inbounds i32, i32* %18, i64 0
store i32 %17, i32* %19
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 6
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 21
%24 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 7
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = shl i32 %26, 14
%28 = add nsw i32 %23, %27
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 8
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = shl i32 %31, 7
%33 = add nsw i32 %28, %32
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 9
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = add nsw i32 %33, %36
%38 = load i32*, i32** %5
%39 = getelementptr inbounds i32, i32* %38, i64 1
store i32 %37, i32* %39
%40 = load i32*, i32** %5
store i32* %40, i32** %2
br label %50
41: ; preds = %1
%42 = load i32, i32* %3
%43 = load i32, i32* @SEEK_SET
%44 = call i32 @lseek(i32 %42, i32 0, i32 %43)
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 0
store i32 2, i32* %46
%47 = load i32*, i32** %5
%48 = getelementptr inbounds i32, i32* %47, i64 1
store i32 0, i32* %48
%49 = load i32*, i32** %5
store i32* %49, i32** %2
br label %50
50: ; preds = %41, %14
%51 = load i32*, i32** %2
ret i32* %51
}

LLVM IR (-O2):
@.str = [4 x i8] c"ID3\00"
@SEEK_SET = global i32 0
define i32* @da_get_current_tag_info(i32 %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @calloc(i32 2, i32 4)
%5 = inttoptr i64 %4 to i32*
%6 = call i32 @r_read(i32 %0, i8* %3, i32 10)
%7 = call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %1
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 3
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
store i32 %12, i32* %5
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 6
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = shl nuw nsw i32 %15, 21
%17 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 7
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, 14
%21 = add nuw nsw i32 %20, %16
%22 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 8
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl nuw nsw i32 %24, 7
%26 = add nuw nsw i32 %21, %25
%27 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 9
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = add nuw nsw i32 %26, %29
br label %34
31: ; preds = %1
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @lseek(i32 %0, i32 0, i32 %32)
store i32 2, i32* %5
br label %34
34: ; preds = %31, %9
%35 = phi i32 [ %30, %9 ], [ 0, %31 ]
%36 = getelementptr inbounds i32, i32* %5, i64 1
store i32 %35, i32* %36
ret i32* %5
}