#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 uint8_t;
typedef int uint16_t;
struct AD {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ___UDFLongAD(int *, struct AD *);
int /*<<< orphan*/ ___Unicodedecode(int *, int, char *);
int ___UDFFileIdentifier(uint8_t *data, uint8_t *FileCharacteristics,
                         char *FileName, struct AD *FileICB) {
  uint8_t L_FI;
  uint16_t L_IU;
  *FileCharacteristics = ((uint8_t)data[18]);
  L_FI = ((uint8_t)data[19]);
  ___UDFLongAD(&data[20], FileICB);
  L_IU = ((uint16_t)data[36] | ((uint16_t)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    0x48(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x4c(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x50,%rdi
mov    -0x20(%rbp),%rsi
call   1040 <___UDFLongAD@plt>
mov    -0x8(%rbp),%rax
mov    0x90(%rax),%eax
mov    -0x8(%rbp),%rcx
mov    0x94(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11aa <___UDFFileIdentifier+0x8a>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%eax
add    $0x26,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x24(%rbp),%esi
mov    -0x18(%rbp),%rdx
call   1030 <___Unicodedecode@plt>
jmp    11b1 <___UDFFileIdentifier+0x91>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x24(%rbp),%eax
add    $0x26,%eax
add    -0x28(%rbp),%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,%r12
mov    0x48(%rdi),%eax
mov    %eax,(%rsi)
mov    0x4c(%rdi),%r15d
add    $0x50,%rdi
mov    %rcx,%rsi
call   1040 <___UDFLongAD@plt>
mov    0x94(%r12),%ebx
shl    $0x8,%ebx
or     0x90(%r12),%ebx
test   %r15d,%r15d
je     1176 <___UDFFileIdentifier+0x56>
movslq %ebx,%rax
lea    (%r12,%rax,4),%rdi
add    $0x98,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1030 <___Unicodedecode@plt>
jmp    117a <___UDFFileIdentifier+0x5a>
movb   $0x0,(%r14)
lea    (%r15,%rbx,1),%ecx
add    $0x29,%ecx
lea    (%r15,%rbx,1),%eax
add    $0x2c,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
and    $0xfffffffc,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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