#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*/ snprintf(char *, int, char *, char const *, char *, int,
                            char *);
scalar_t__ strlen(char *);
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';
  snprintf(name_ptr, (int)(end - name_ptr), "%s %s (%d bytes) (ext %s)\n", tag,
           path, bytes, ext);
  return (int)strlen(start);
}


x86 assembly (clang, -O0):
<print_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    0x10(%rbp),%rax
lea    0xe30(%rip),%rdx
mov    %rax,(%rsp)
call   1040 <snprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_entry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%ebp
mov    %rdx,%r8
mov    %rsi,%rax
mov    %rdi,%r13
mov    0x50(%rsp),%r14
mov    %rdi,%rbx
test   %ecx,%ecx
je     11b6 <print_entry+0x86>
test   %ebp,%ebp
jle    11b6 <print_entry+0x86>
mov    %rax,0x10(%rsp)
movslq %ebp,%rax
add    $0xffffffff,%ecx
add    %r13,%rax
lea    0x1(%r13),%rdx
cmp    %rdx,%rax
cmovbe %rdx,%rax
mov    %r13,%rdx
not    %rdx
add    %rax,%rdx
cmp    %rcx,%rdx
cmovae %rcx,%rdx
add    $0x1,%rdx
test   %ecx,%ecx
mov    $0x1,%ebx
cmovne %rdx,%rbx
mov    %r13,%rdi
mov    $0x9,%esi
mov    %rbx,%rdx
mov    %r9d,%r15d
mov    %r8,%r12
call   1050 <memset@plt>
mov    0x10(%rsp),%rax
mov    %r12,%r8
mov    %r15d,%r9d
add    %r13,%rbx
add    %r13d,%ebp
sub    %ebx,%ebp
mov    %r14,(%rsp)
lea    0xe3a(%rip),%rdx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rcx
call   1040 <snprintf@plt>
mov    %r13,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strlen@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"%s %s (%d bytes) (ext %s)\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** %8
%39 = ptrtoint i8* %37 to i64
%40 = ptrtoint i8* %38 to i64
%41 = sub i64 %39, %40
%42 = trunc i64 %41 to i32
%43 = load i8*, i8** %9
%44 = load i8*, i8** %10
%45 = load i32, i32* %13
%46 = load i8*, i8** %14
%47 = call i32 @snprintf(i8* %36, i32 %42, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %43, i8* %44, i32 %45, i8* %46)
%48 = load i8*, i8** %16
%49 = call i64 @strlen(i8* %48)
%50 = trunc i64 %49 to i32
ret i32 %50
}

LLVM IR (-O2):
@.str = [27 x i8] c"%s %s (%d bytes) (ext %s)\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 = icmp ne i32 %3, 0
%11 = icmp sgt i32 %4, 0
%12 = and i1 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %7
%14 = add i32 %3, -1
%15 = zext i32 %14 to i64
%16 = add i64 %8, %9
%17 = add i64 %8, 1
%18 = call i64 @llvm.umax.i64(i64 %16, i64 %17)
%19 = xor i64 %8, -1
%20 = add i64 %18, %19
%21 = icmp eq i32 %14, 0
%22 = call i64 @llvm.umin.i64(i64 %20, i64 %15)
%23 = add nuw nsw i64 %22, 1
%24 = select i1 %21, i64 1, i64 %23
%25 = getelementptr i8, i8* %0, i64 %24
%26 = ptrtoint i8* %25 to i64
br label %27
27: ; preds = %13, %7
%28 = phi i64 [ %26, %13 ], [ %8, %7 ]
%29 = phi i8* [ %25, %13 ], [ %0, %7 ]
%30 = getelementptr inbounds i8, i8* %0, i64 %9
%31 = ptrtoint i8* %30 to i64
%32 = sub i64 %31, %28
%33 = trunc i64 %32 to i32
%34 = tail call i32 @snprintf(i8* %29, i32 %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32 %5, i8* %6)
%35 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%36 = trunc i64 %35 to i32
ret i32 %36
}