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

/* Variables and functions */
char *calloc(scalar_t__, int);
int errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ interface_dependent_path(char *, char const *const, char *,
                                            char **, int *const);
char *mu_linux_debugfs_mount_point(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
char *batman_adv_originators_file_path(const char *const interface_name,
                                       int *const error) {
  char *debugfs_root = mu_linux_debugfs_mount_point(NULL);
  char *batman_debugfs_dir = NULL;
  char *bat_interface_originators_file = NULL;
  if (!debugfs_root) {
    if (error) {
      *error = errno;
    };
    return 0;
  }
  batman_debugfs_dir =
      calloc(strlen(debugfs_root) + strlen("/batman_adv/") + 1, sizeof(char));
  if (!batman_debugfs_dir) {
    if (error) {
      *error = errno;
    };
    free(debugfs_root);
    return 0;
  }
  strcat(batman_debugfs_dir, debugfs_root);
  strcat(batman_debugfs_dir, "/batman_adv/");
  free(debugfs_root);
  if (!interface_dependent_path(batman_debugfs_dir, interface_name,
                                "/originators", &bat_interface_originators_file,
                                error)) {
    free(batman_debugfs_dir);
    return NULL;
  }
  free(batman_debugfs_dir);
  return bat_interface_originators_file;
}


x86 assembly (clang, -O0):
<batman_adv_originators_file_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <mu_linux_debugfs_mount_point@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11bf <batman_adv_originators_file_path+0x5f>
cmpq   $0x0,-0x18(%rbp)
je     11b2 <batman_adv_originators_file_path+0x52>
mov    0x2e36(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    129e <batman_adv_originators_file_path+0x13e>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x38(%rbp)
lea    0xe2d(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122c <batman_adv_originators_file_path+0xcc>
cmpq   $0x0,-0x18(%rbp)
je     1216 <batman_adv_originators_file_path+0xb6>
mov    0x2dd2(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    129e <batman_adv_originators_file_path+0x13e>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xdbc(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%r8
lea    0xda8(%rip),%rdx
lea    -0x30(%rbp),%rcx
call   1070 <interface_dependent_path@plt>
cmp    $0x0,%eax
jne    128d <batman_adv_originators_file_path+0x12d>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    129e <batman_adv_originators_file_path+0x13e>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<batman_adv_originators_file_path>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %edi,%edi
call   1050 <mu_linux_debugfs_mount_point@plt>
movq   $0x0,(%rsp)
test   %rax,%rax
je     11f1 <batman_adv_originators_file_path+0x91>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
lea    0xd(%rax),%rdi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     1204 <batman_adv_originators_file_path+0xa4>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
call   1080 <strcat@plt>
lea    0xe4b(%rip),%rsi
mov    %r12,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe41(%rip),%rdx
mov    %rsp,%rcx
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%r8
call   1070 <interface_dependent_path@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     121d <batman_adv_originators_file_path+0xbd>
mov    (%rsp),%rax
jmp    121f <batman_adv_originators_file_path+0xbf>
test   %r15,%r15
je     121d <batman_adv_originators_file_path+0xbd>
mov    0x2de3(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
jmp    121d <batman_adv_originators_file_path+0xbd>
test   %r15,%r15
je     1215 <batman_adv_originators_file_path+0xb5>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%r15)
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [13 x i8] c"/batman_adv/\00"
@.str.1 = [13 x i8] c"/originators\00"
define i8* @batman_adv_originators_file_path(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %4
store i32* %1, i32** %5
%9 = call i8* @mu_linux_debugfs_mount_point(i32* null)
store i8* %9, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = load i32*, i32** %5
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @errno
%17 = load i32*, i32** %5
store i32 %16, i32* %17
br label %18
18: ; preds = %15, %12
store i8* null, i8** %3
br label %57
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = call i64 @strlen(i8* %20)
%22 = call i64 @strlen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%23 = add nsw i64 %21, %22
%24 = add nsw i64 %23, 1
%25 = call i8* @calloc(i64 %24, i32 1)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %37, label %28
28: ; preds = %19
%29 = load i32*, i32** %5
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load i32, i32* @errno
%33 = load i32*, i32** %5
store i32 %32, i32* %33
br label %34
34: ; preds = %31, %28
%35 = load i8*, i8** %6
%36 = call i32 @free(i8* %35)
store i8* null, i8** %3
br label %57
37: ; preds = %19
%38 = load i8*, i8** %7
%39 = load i8*, i8** %6
%40 = call i32 @strcat(i8* %38, i8* %39)
%41 = load i8*, i8** %7
%42 = call i32 @strcat(i8* %41, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%43 = load i8*, i8** %6
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %7
%46 = load i8*, i8** %4
%47 = load i32*, i32** %5
%48 = call i32 @interface_dependent_path(i8* %45, i8* %46, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %8, i32* %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %37
%51 = load i8*, i8** %7
%52 = call i32 @free(i8* %51)
store i8* null, i8** %3
br label %57
53: ; preds = %37
%54 = load i8*, i8** %7
%55 = call i32 @free(i8* %54)
%56 = load i8*, i8** %8
store i8* %56, i8** %3
br label %57
57: ; preds = %53, %50, %34, %18
%58 = load i8*, i8** %3
ret i8* %58
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [13 x i8] c"/batman_adv/\00"
@.str.1 = [13 x i8] c"/originators\00"
define i8* @batman_adv_originators_file_path(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = tail call i8* @mu_linux_debugfs_mount_point(i32* null)
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = icmp eq i8* %4, null
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = icmp eq i32* %1, null
br i1 %8, label %31, label %9
9: ; preds = %7
%10 = load i32, i32* @errno
store i32 %10, i32* %1
br label %31
11: ; preds = %2
%12 = tail call i64 @strlen(i8* %4)
%13 = add nsw i64 %12, 13
%14 = tail call i8* @calloc(i64 %13, i32 1)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %22
16: ; preds = %11
%17 = icmp eq i32* %1, null
br i1 %17, label %20, label %18
18: ; preds = %16
%19 = load i32, i32* @errno
store i32 %19, i32* %1
br label %20
20: ; preds = %18, %16
%21 = tail call i32 @free(i8* %4)
br label %31
22: ; preds = %11
%23 = tail call i32 @strcat(i8* %14, i8* %4)
%24 = tail call i32 @strcat(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 @free(i8* %4)
%26 = call i32 @interface_dependent_path(i8* %14, i8* %0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8** %3, i32* %1)
%27 = icmp eq i32 %26, 0
%28 = call i32 @free(i8* %14)
%29 = load i8*, i8** %3
%30 = select i1 %27, i8* null, i8* %29
br label %31
31: ; preds = %22, %7, %9, %20
%32 = phi i8* [ null, %20 ], [ null, %9 ], [ null, %7 ], [ %30, %22 ]
ret i8* %32
}