#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 */
struct AD {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ UDFLongAD(unsigned char *, struct AD *);
int /*<<< orphan*/ Unicodedecode(unsigned char *, unsigned char, char *);
int UDFFileIdentifier(unsigned char *data, unsigned char *FileCharacteristics,
                      char *FileName, struct AD *FileICB) {
  unsigned char L_FI;
  unsigned short L_IU;
  *FileCharacteristics = ((unsigned char)data[18]);
  L_FI = ((unsigned char)data[19]);
  UDFLongAD(&data[20], FileICB);
  L_IU = ((unsigned short)data[36] | ((unsigned short)data[(36) + 1] << 8));
  if (L_FI)
    Unicodedecode(&data[38 + L_IU], L_FI, FileName);
  else
    FileName[0] = '\0';
  return 4 * ((38 + L_FI + L_IU + 3) / 4);
}


x86 assembly (clang, -O0):
<UDFFileIdentifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x12(%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
mov    0x13(%rax),%al
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x14,%rdi
mov    -0x20(%rbp),%rsi
call   1030 <UDFLongAD@plt>
mov    -0x8(%rbp),%rax
movzbl 0x24(%rax),%eax
movzwl %ax,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x25(%rcx),%ecx
movzwl %cx,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x24(%rbp)
cmpb   $0x0,-0x21(%rbp)
je     11ad <UDFFileIdentifier+0x8d>
mov    -0x8(%rbp),%rdi
movzwl -0x24(%rbp),%eax
add    $0x26,%eax
cltq
add    %rax,%rdi
mov    -0x21(%rbp),%al
mov    -0x18(%rbp),%rdx
movzbl %al,%esi
call   1040 <Unicodedecode@plt>
jmp    11b4 <UDFFileIdentifier+0x94>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
movzbl -0x21(%rbp),%eax
add    $0x26,%eax
movzwl -0x24(%rbp),%ecx
add    %ecx,%eax
add    $0x3,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
shl    $0x2,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UDFFileIdentifier>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
mov    0x12(%rdi),%al
mov    %al,(%rsi)
movzbl 0x13(%rdi),%r15d
add    $0x14,%rdi
mov    %rcx,%rsi
call   1030 <UDFLongAD@plt>
movzwl 0x24(%rbx),%r12d
test   %r15d,%r15d
je     1163 <UDFFileIdentifier+0x43>
lea    (%r12,%rbx,1),%rdi
add    $0x26,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1040 <Unicodedecode@plt>
jmp    1167 <UDFFileIdentifier+0x47>
movb   $0x0,(%r14)
movzwl %r12w,%eax
add    %r15d,%eax
add    $0x29,%eax
and    $0x1fffc,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.AD = type { i32 }
define i32 @UDFFileIdentifier(i8* %0, i8* %1, i8* %2, %struct.AD* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.AD*
%9 = alloca i8
%10 = alloca i16
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store %struct.AD* %3, %struct.AD** %8
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 18
%13 = load i8, i8* %12
%14 = load i8*, i8** %6
store i8 %13, i8* %14
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 19
%17 = load i8, i8* %16
store i8 %17, i8* %9
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 20
%20 = load %struct.AD*, %struct.AD** %8
%21 = call i32 @UDFLongAD(i8* %19, %struct.AD* %20)
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 36
%24 = load i8, i8* %23
%25 = zext i8 %24 to i16
%26 = zext i16 %25 to i32
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 37
%29 = load i8, i8* %28
%30 = zext i8 %29 to i16
%31 = zext i16 %30 to i32
%32 = shl i32 %31, 8
%33 = or i32 %26, %32
%34 = trunc i32 %33 to i16
store i16 %34, i16* %10
%35 = load i8, i8* %9
%36 = icmp ne i8 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %4
%38 = load i8*, i8** %5
%39 = load i16, i16* %10
%40 = zext i16 %39 to i32
%41 = add nsw i32 38, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %38, i64 %42
%44 = load i8, i8* %9
%45 = load i8*, i8** %7
%46 = call i32 @Unicodedecode(i8* %43, i8 zeroext %44, i8* %45)
br label %50
47: ; preds = %4
%48 = load i8*, i8** %7
%49 = getelementptr inbounds i8, i8* %48, i64 0
store i8 0, i8* %49
br label %50
50: ; preds = %47, %37
%51 = load i8, i8* %9
%52 = zext i8 %51 to i32
%53 = add nsw i32 38, %52
%54 = load i16, i16* %10
%55 = zext i16 %54 to i32
%56 = add nsw i32 %53, %55
%57 = add nsw i32 %56, 3
%58 = sdiv i32 %57, 4
%59 = mul nsw i32 4, %58
ret i32 %59
}

LLVM IR (-O2):
%struct.AD = type { i32 }
define i32 @UDFFileIdentifier(i8* %0, i8* nocapture writeonly %1, i8* %2, %struct.AD* %3) {
%5 = getelementptr inbounds i8, i8* %0, i64 18
%6 = load i8, i8* %5
store i8 %6, i8* %1
%7 = getelementptr inbounds i8, i8* %0, i64 19
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 20
%10 = tail call i32 @UDFLongAD(i8* %9, %struct.AD* %3)
%11 = getelementptr inbounds i8, i8* %0, i64 36
%12 = load i8, i8* %11
%13 = zext i8 %12 to i16
%14 = getelementptr inbounds i8, i8* %0, i64 37
%15 = load i8, i8* %14
%16 = zext i8 %15 to i16
%17 = shl nuw i16 %16, 8
%18 = or i16 %17, %13
%19 = icmp eq i8 %8, 0
br i1 %19, label %25, label %20
20: ; preds = %4
%21 = zext i16 %18 to i64
%22 = add nuw nsw i64 %21, 38
%23 = getelementptr inbounds i8, i8* %0, i64 %22
%24 = tail call i32 @Unicodedecode(i8* %23, i8 zeroext %8, i8* %2)
br label %26
25: ; preds = %4
store i8 0, i8* %2
br label %26
26: ; preds = %25, %20
%27 = zext i8 %8 to i32
%28 = zext i16 %18 to i32
%29 = add nuw nsw i32 %27, 41
%30 = add nuw nsw i32 %29, %28
%31 = and i32 %30, 131068
ret i32 %31
}