#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*/ strncpy(char *, char *, int);
void dump_get_file_name(char *buf, int bsize, char *dfile, int dfile_size,
                        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, dfile_size);
  else
    strncpy(dfile, "platform.dumpid.PARTIAL", dfile_size);
  dfile[dfile_size - 1] = '\0';
}


x86 assembly (clang, -O0):
<dump_get_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x1a,%rax
jb     115c <dump_get_file_name+0x3c>
mov    -0x8(%rbp),%rax
mov    0x16(%rax),%edi
call   1040 <be16toh@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x48,-0xc(%rbp)
jl     117f <dump_get_file_name+0x5f>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
add    $0x18,%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncpy@plt>
jmp    1192 <dump_get_file_name+0x72>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe73(%rip),%rsi
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_get_file_name>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r12d
mov    %rdx,%r14
cmp    $0x1a,%esi
jb     1157 <dump_get_file_name+0x37>
mov    %r8,%r15
mov    %esi,%ebp
mov    %rdi,%rbx
mov    0x16(%rdi),%edi
call   1040 <be16toh@plt>
mov    %eax,(%r15)
cmp    $0x48,%ebp
jl     1157 <dump_get_file_name+0x37>
add    $0x18,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
jmp    1161 <dump_get_file_name+0x41>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
mov    %r12d,%edx
call   1030 <strncpy@plt>
movslq %r12d,%rax
movb   $0x0,-0x1(%rax,%r14,1)
pop    %rbx
pop    %r12
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, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = icmp uge i64 %12, 26
br i1 %13, label %14, label %21
14: ; preds = %5
%15 = load i8*, i8** %6
%16 = getelementptr inbounds i8, i8* %15, i64 22
%17 = bitcast i8* %16 to i32*
%18 = load i32, i32* %17
%19 = call i32 @be16toh(i32 %18)
%20 = load i32*, i32** %10
store i32 %19, i32* %20
br label %21
21: ; preds = %14, %5
%22 = load i32, i32* %7
%23 = icmp sge i32 %22, 72
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load i8*, i8** %8
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 24
%28 = load i32, i32* %9
%29 = call i32 @strncpy(i8* %25, i8* %27, i32 %28)
br label %34
30: ; preds = %21
%31 = load i8*, i8** %8
%32 = load i32, i32* %9
%33 = call i32 @strncpy(i8* %31, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %30, %24
%35 = load i8*, i8** %8
%36 = load i32, i32* %9
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %35, i64 %38
store i8 0, i8* %39
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 %3, i32* nocapture writeonly %4) {
%6 = icmp ugt i32 %1, 25
br i1 %6, label %7, label %16
7: ; preds = %5
%8 = getelementptr inbounds i8, i8* %0, i64 22
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = tail call i32 @be16toh(i32 %10)
store i32 %11, i32* %4
%12 = icmp sgt i32 %1, 71
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %0, i64 24
%15 = tail call i32 @strncpy(i8* %2, i8* %14, i32 %3)
br label %18
16: ; preds = %5, %7
%17 = tail call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %18
18: ; preds = %16, %13
%19 = add nsw i32 %3, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %2, i64 %20
store i8 0, i8* %21
ret void
}