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

/* Variables and functions */
scalar_t__ c0x_getdirname(char *, int, char const *);
scalar_t__ c0x_getfilename(char *, int, char const *);
int /*<<< orphan*/ printf(char *, char const *);
void print_pfx(const char *path) {
  char name[4 * 1024 + 1];
  if (c0x_getdirname(name, sizeof(name), path) > 0)
    print_pfx(name);
  else
    printf("[%s]", path);
  if (c0x_getfilename(name, sizeof(name), path) > 0)
    printf("[%s]", name);
}


x86 assembly (clang, -O0):
<print_pfx>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1010,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1001,%esi
call   1060 <c0x_getdirname@plt>
cmp    $0x0,%rax
jle    117f <print_pfx+0x3f>
lea    -0x1010(%rbp),%rdi
call   1030 <print_pfx@plt>
jmp    118f <print_pfx+0x4f>
mov    -0x8(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x1001,%esi
call   1050 <c0x_getfilename@plt>
cmp    $0x0,%rax
jle    11c1 <print_pfx+0x81>
lea    -0x1010(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
add    $0x1010,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pfx>:
push   %rbx
sub    $0x1010,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    $0x1001,%esi
mov    %rbx,%rdx
call   1060 <c0x_getdirname@plt>
test   %rax,%rax
jle    116a <print_pfx+0x2a>
mov    %rsp,%rdi
call   1030 <print_pfx@plt>
jmp    1179 <print_pfx+0x39>
lea    0xe8f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x1001,%esi
mov    %rbx,%rdx
call   1050 <c0x_getfilename@plt>
test   %rax,%rax
jle    119d <print_pfx+0x5d>
lea    0xe6b(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0x1010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"[%s]\00"
define void @print_pfx(i8* %0) {
%2 = alloca i8*
%3 = alloca [4097 x i8]
store i8* %0, i8** %2
%4 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %2
%6 = call i64 @c0x_getdirname(i8* %4, i32 4097, i8* %5)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
br label %13
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %8
%14 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%15 = load i8*, i8** %2
%16 = call i64 @c0x_getfilename(i8* %14, i32 4097, i8* %15)
%17 = icmp sgt i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %18, %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"[%s]\00"
define void @print_pfx(i8* %0) {
%2 = alloca [4097 x i8]
%3 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
%4 = call i64 @c0x_getdirname(i8* %3, i32 4097, i8* %0)
%5 = icmp sgt i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
br label %9
7: ; preds = %1
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %9
9: ; preds = %7, %6
%10 = call i64 @c0x_getfilename(i8* %3, i32 4097, i8* %0)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %14
14: ; preds = %12, %9
ret void
}