#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*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ be16toh(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void dump_get_file_name(char *buf, int bsize, char *dfile,
                        uint16_t *prefix_size) {
  if (bsize >= 0x16 + sizeof(uint16_t))
    *prefix_size = be16toh(*(uint16_t *)(buf + 0x16));
  if (bsize >= 0x18 + 48)
    strncpy(dfile, buf + 0x18, 48);
  else
    strcpy(dfile, "platform.dumpid.PARTIAL");
  dfile[48 - 1] = '\0';
}


x86 assembly (clang, -O0):
<dump_get_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x1a,%rax
jb     1169 <dump_get_file_name+0x39>
mov    -0x8(%rbp),%rax
mov    0x16(%rax),%edi
call   1050 <be16toh@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x48,-0xc(%rbp)
jl     118e <dump_get_file_name+0x5e>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x18,%rsi
mov    $0x30,%edx
call   1030 <strncpy@plt>
jmp    119e <dump_get_file_name+0x6e>
mov    -0x18(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
movb   $0x0,0x2f(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_get_file_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
cmp    $0x1a,%esi
jb     116d <dump_get_file_name+0x3d>
mov    %rcx,%r15
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x16(%rdi),%edi
call   1050 <be16toh@plt>
mov    %eax,(%r15)
cmp    $0x48,%ebp
jl     116d <dump_get_file_name+0x3d>
add    $0x18,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x30,%edx
call   1030 <strncpy@plt>
jmp    117c <dump_get_file_name+0x4c>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
movb   $0x0,0x2f(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"platform.dumpid.PARTIAL\00"
define void @dump_get_file_name(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = icmp uge i64 %10, 26
br i1 %11, label %12, label %19
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 22
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
%17 = call i32 @be16toh(i32 %16)
%18 = load i32*, i32** %8
store i32 %17, i32* %18
br label %19
19: ; preds = %12, %4
%20 = load i32, i32* %6
%21 = icmp sge i32 %20, 72
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %7
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i64 24
%26 = call i32 @strncpy(i8* %23, i8* %25, i32 48)
br label %30
27: ; preds = %19
%28 = load i8*, i8** %7
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %30
30: ; preds = %27, %22
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i64 47
store i8 0, i8* %32
ret void
}

LLVM IR (-O2):
@.str = [24 x i8] c"platform.dumpid.PARTIAL\00"
define void @dump_get_file_name(i8* %0, i32 %1, i8* %2, i32* nocapture writeonly %3) {
%5 = icmp ugt i32 %1, 25
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = getelementptr inbounds i8, i8* %0, i64 22
%8 = bitcast i8* %7 to i32*
%9 = load i32, i32* %8
%10 = tail call i32 @be16toh(i32 %9)
store i32 %10, i32* %3
%11 = icmp sgt i32 %1, 71
br i1 %11, label %12, label %15
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %0, i64 24
%14 = tail call i32 @strncpy(i8* %2, i8* %13, i32 48)
br label %17
15: ; preds = %4, %6
%16 = tail call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
%18 = getelementptr inbounds i8, i8* %2, i64 47
store i8 0, i8* %18
ret void
}