#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 */
int /*<<< orphan*/ print_integer(unsigned char *, int, int);
char *print_tag(char *, char *, char const *);
int print_entry(char *name_ptr, const char *tag, char *path, int level, int max,
                int bytes, char *ext) {
  char *end = name_ptr + max;
  char *start = name_ptr;
  while (level-- && name_ptr < end)
    *name_ptr++ = '\t';
  name_ptr = print_tag(name_ptr, end, tag);
  name_ptr = print_tag(name_ptr, end, path);
  name_ptr = print_tag(name_ptr, end, " (");
  name_ptr += print_integer((unsigned char *)name_ptr, bytes, 10);
  name_ptr = print_tag(name_ptr, end, " bytes)");
  name_ptr = print_tag(name_ptr, end, " (ext ");
  name_ptr = print_tag(name_ptr, end, ext);
  name_ptr = print_tag(name_ptr, end, ")\n");
  *name_ptr++ = '\0';
  return (int)(name_ptr - start);
}


x86 assembly (clang, -O0):
<print_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x39(%rbp)
je     1181 <print_entry+0x61>
mov    -0x8(%rbp),%rax
cmp    -0x30(%rbp),%rax
setb   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1191 <print_entry+0x71>
jmp    11a8 <print_entry+0x88>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x9,(%rax)
jmp    115a <print_entry+0x3a>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    0xe1f(%rip),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0xa,%edx
call   1040 <print_integer@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    0xde9(%rip),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    0xdd9(%rip),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x10(%rbp),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
lea    0xdb3(%rip),%rdx
call   1030 <print_tag@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    -0x38(%rbp),%rcx
sub    %rcx,%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_entry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %rdx,%r13
mov    %rsi,%rbp
mov    %rdi,%r15
movslq %r8d,%rbx
add    %rdi,%rbx
mov    %rdi,%r14
test   %ecx,%ecx
je     119d <print_entry+0x6d>
mov    %r15,%r14
test   %r8d,%r8d
jle    119d <print_entry+0x6d>
add    $0xffffffff,%ecx
lea    0x1(%r15),%rax
cmp    %rax,%rbx
cmova  %rbx,%rax
mov    %r15,%rdx
not    %rdx
add    %rax,%rdx
cmp    %rcx,%rdx
cmovae %rcx,%rdx
add    $0x1,%rdx
test   %ecx,%ecx
mov    $0x1,%r14d
cmovne %rdx,%r14
mov    %r15,%rdi
mov    $0x9,%esi
mov    %r14,%rdx
call   1030 <memset@plt>
add    %r15,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1040 <print_tag@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1040 <print_tag@plt>
lea    0xe40(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <print_tag@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12d,%esi
mov    $0xa,%edx
call   1050 <print_integer@plt>
movslq %eax,%rdi
add    %rbp,%rdi
lea    0xe18(%rip),%rdx
mov    %rbx,%rsi
call   1040 <print_tag@plt>
lea    0xe11(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <print_tag@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    0x40(%rsp),%rdx
call   1040 <print_tag@plt>
lea    0xdf6(%rip),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <print_tag@plt>
movb   $0x0,(%rax)
sub    %r15d,%eax
add    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c" (\00"
@.str.1 = [8 x i8] c" bytes)\00"
@.str.2 = [7 x i8] c" (ext \00"
@.str.3 = [3 x i8] c")\0A\00"
define i32 @print_entry(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i8* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i8* %6, i8** %14
%17 = load i8*, i8** %8
%18 = load i32, i32* %12
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
store i8* %20, i8** %15
%21 = load i8*, i8** %8
store i8* %21, i8** %16
br label %22
22: ; preds = %32, %7
%23 = load i32, i32* %11
%24 = add nsw i32 %23, -1
store i32 %24, i32* %11
%25 = icmp ne i32 %23, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i8*, i8** %8
%28 = load i8*, i8** %15
%29 = icmp ult i8* %27, %28
br label %30
30: ; preds = %26, %22
%31 = phi i1 [ false, %22 ], [ %29, %26 ]
br i1 %31, label %32, label %35
32: ; preds = %30
%33 = load i8*, i8** %8
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %8
store i8 9, i8* %33
br label %22
35: ; preds = %30
%36 = load i8*, i8** %8
%37 = load i8*, i8** %15
%38 = load i8*, i8** %9
%39 = call i8* @print_tag(i8* %36, i8* %37, i8* %38)
store i8* %39, i8** %8
%40 = load i8*, i8** %8
%41 = load i8*, i8** %15
%42 = load i8*, i8** %10
%43 = call i8* @print_tag(i8* %40, i8* %41, i8* %42)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = load i8*, i8** %15
%46 = call i8* @print_tag(i8* %44, i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %46, i8** %8
%47 = load i8*, i8** %8
%48 = load i32, i32* %13
%49 = call i32 @print_integer(i8* %47, i32 %48, i32 10)
%50 = load i8*, i8** %8
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8, i8* %50, i64 %51
store i8* %52, i8** %8
%53 = load i8*, i8** %8
%54 = load i8*, i8** %15
%55 = call i8* @print_tag(i8* %53, i8* %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
store i8* %55, i8** %8
%56 = load i8*, i8** %8
%57 = load i8*, i8** %15
%58 = call i8* @print_tag(i8* %56, i8* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i8* %58, i8** %8
%59 = load i8*, i8** %8
%60 = load i8*, i8** %15
%61 = load i8*, i8** %14
%62 = call i8* @print_tag(i8* %59, i8* %60, i8* %61)
store i8* %62, i8** %8
%63 = load i8*, i8** %8
%64 = load i8*, i8** %15
%65 = call i8* @print_tag(i8* %63, i8* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i8* %65, i8** %8
%66 = load i8*, i8** %8
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %8
store i8 0, i8* %66
%68 = load i8*, i8** %8
%69 = load i8*, i8** %16
%70 = ptrtoint i8* %68 to i64
%71 = ptrtoint i8* %69 to i64
%72 = sub i64 %70, %71
%73 = trunc i64 %72 to i32
ret i32 %73
}

LLVM IR (-O2):
@.str = [3 x i8] c" (\00"
@.str.1 = [8 x i8] c" bytes)\00"
@.str.2 = [7 x i8] c" (ext \00"
@.str.3 = [3 x i8] c")\0A\00"
define i32 @print_entry(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i32 %5, i8* %6) {
%8 = ptrtoint i8* %0 to i64
%9 = sext i32 %4 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = icmp ne i32 %3, 0
%12 = icmp sgt i32 %4, 0
%13 = and i1 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %7
%15 = add i32 %3, -1
%16 = zext i32 %15 to i64
%17 = add i64 %8, %9
%18 = add i64 %8, 1
%19 = call i64 @llvm.umax.i64(i64 %17, i64 %18)
%20 = xor i64 %8, -1
%21 = add i64 %19, %20
%22 = icmp eq i32 %15, 0
%23 = call i64 @llvm.umin.i64(i64 %21, i64 %16)
%24 = add nuw nsw i64 %23, 1
%25 = select i1 %22, i64 1, i64 %24
%26 = getelementptr i8, i8* %0, i64 %25
br label %27
27: ; preds = %14, %7
%28 = phi i8* [ %0, %7 ], [ %26, %14 ]
%29 = tail call i8* @print_tag(i8* %28, i8* %10, i8* %1)
%30 = tail call i8* @print_tag(i8* %29, i8* %10, i8* %2)
%31 = tail call i8* @print_tag(i8* %30, i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%32 = tail call i32 @print_integer(i8* %31, i32 %5, i32 10)
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = tail call i8* @print_tag(i8* %34, i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%36 = tail call i8* @print_tag(i8* %35, i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%37 = tail call i8* @print_tag(i8* %36, i8* %10, i8* %6)
%38 = tail call i8* @print_tag(i8* %37, i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%39 = getelementptr inbounds i8, i8* %38, i64 1
store i8 0, i8* %38
%40 = ptrtoint i8* %39 to i64
%41 = sub i64 %40, %8
%42 = trunc i64 %41 to i32
ret i32 %42
}