#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) {
    if (!Unicodedecode(&data[38 + L_IU], L_FI, FileName))
      FileName[0] = 0;
  } 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   1030 <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     11ba <UDFFileIdentifier+0x9a>
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   1040 <Unicodedecode@plt>
cmp    $0x0,%eax
jne    11b5 <UDFFileIdentifier+0x95>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11c1 <UDFFileIdentifier+0xa1>
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,%rbx
mov    0x48(%rdi),%eax
mov    %eax,(%rsi)
mov    0x4c(%rdi),%r15d
add    $0x50,%rdi
mov    %rcx,%rsi
call   1030 <UDFLongAD@plt>
mov    0x94(%rbx),%r12d
shl    $0x8,%r12d
or     0x90(%rbx),%r12d
test   %r15d,%r15d
je     1177 <UDFFileIdentifier+0x57>
movslq %r12d,%rax
lea    (%rbx,%rax,4),%rdi
add    $0x98,%rdi
mov    %r15d,%esi
mov    %r14,%rdx
call   1040 <Unicodedecode@plt>
test   %eax,%eax
jne    117b <UDFFileIdentifier+0x5b>
movb   $0x0,(%r14)
lea    (%r15,%r12,1),%ecx
add    $0x29,%ecx
lea    (%r15,%r12,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 %46
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)
%41 = icmp ne i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %32
%43 = load i8*, i8** %7
%44 = getelementptr inbounds i8, i8* %43, i64 0
store i8 0, i8* %44
br label %45
45: ; preds = %42, %32
br label %49
46: ; preds = %4
%47 = load i8*, i8** %7
%48 = getelementptr inbounds i8, i8* %47, i64 0
store i8 0, i8* %48
br label %49
49: ; preds = %46, %45
%50 = load i32, i32* %9
%51 = add nsw i32 38, %50
%52 = load i32, i32* %10
%53 = add nsw i32 %51, %52
%54 = add nsw i32 %53, 3
%55 = sdiv i32 %54, 4
%56 = mul nsw i32 4, %55
ret i32 %56
}

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 %24, 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)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %4, %18
store i8 0, i8* %2
br label %25
25: ; preds = %24, %18
%26 = add i32 %8, 41
%27 = add i32 %26, %16
%28 = sdiv i32 %27, 4
%29 = shl nsw i32 %28, 2
ret i32 %29
}