#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 scalar_t__ len;

/* Variables and functions */
scalar_t__ __PHYSFS_initSmallAlloc(int /*<<< orphan*/ *, size_t);
int /*<<< orphan*/ __PHYSFS_setError(char *);
int /*<<< orphan*/ __PHYSFS_smallFree(char *);
int /*<<< orphan*/ *alloca(size_t);
int doDelete(char const *, char *);
int strlen(char const *);
int PHYSFS_delete(const char *_fname) {
  int retval;
  char *fname;
  size_t len;
  if (_fname == NULL) {
    __PHYSFS_setError("Invalid argument");
    return 0;
  };
  len = strlen(_fname) + 1;
  fname = (char *)(__PHYSFS_initSmallAlloc(
      (((len) < 128) ? alloca((size_t)((len) + 1)) : NULL), (len)));
  if (fname == NULL) {
    __PHYSFS_setError("Out of memory");
    return 0;
  };
  retval = doDelete(_fname, fname);
  __PHYSFS_smallFree(fname);
  return (retval);
}


x86 assembly (clang, -O0):
<PHYSFS_delete>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118f <PHYSFS_delete+0x2f>
lea    0xe82(%rip),%rdi
call   1080 <__PHYSFS_setError@plt>
movl   $0x0,-0x4(%rbp)
jmp    1223 <PHYSFS_delete+0xc3>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
cmpq   $0x80,-0x28(%rbp)
jae    11c5 <PHYSFS_delete+0x65>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1060 <alloca@plt>
mov    %rax,-0x30(%rbp)
jmp    11d0 <PHYSFS_delete+0x70>
xor    %eax,%eax
mov    %rax,-0x30(%rbp)
jmp    11d0 <PHYSFS_delete+0x70>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <__PHYSFS_initSmallAlloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1204 <PHYSFS_delete+0xa4>
lea    0xe1e(%rip),%rdi
call   1080 <__PHYSFS_setError@plt>
movl   $0x0,-0x4(%rbp)
jmp    1223 <PHYSFS_delete+0xc3>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <doDelete@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <__PHYSFS_smallFree@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PHYSFS_delete>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     118a <PHYSFS_delete+0x2a>
mov    %rdi,%r14
call   1030 <strlen@plt>
add    $0x1,%eax
movslq %eax,%rbx
cmp    $0x7f,%ebx
ja     1193 <PHYSFS_delete+0x33>
lea    0x1(%rbx),%rdi
call   1060 <alloca@plt>
mov    %rax,%rdi
jmp    1195 <PHYSFS_delete+0x35>
lea    0xe6f(%rip),%rdi
jmp    11c5 <PHYSFS_delete+0x65>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <__PHYSFS_initSmallAlloc@plt>
test   %rax,%rax
je     11be <PHYSFS_delete+0x5e>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <doDelete@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <__PHYSFS_smallFree@plt>
mov    %ebp,%eax
jmp    11cc <PHYSFS_delete+0x6c>
lea    0xe4c(%rip),%rdi
call   1080 <__PHYSFS_setError@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Invalid argument\00"
@.str.1 = [14 x i8] c"Out of memory\00"
define i32 @PHYSFS_delete(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @__PHYSFS_setError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %39
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
store i64 %15, i64* %6
%16 = load i64, i64* %6
%17 = icmp ult i64 %16, 128
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load i64, i64* %6
%20 = add i64 %19, 1
%21 = call i32* @alloca(i64 %20)
br label %23
22: ; preds = %11
br label %23
23: ; preds = %22, %18
%24 = phi i32* [ %21, %18 ], [ null, %22 ]
%25 = load i64, i64* %6
%26 = call i64 @__PHYSFS_initSmallAlloc(i32* %24, i64 %25)
%27 = inttoptr i64 %26 to i8*
store i8* %27, i8** %5
%28 = load i8*, i8** %5
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 @__PHYSFS_setError(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %39
32: ; preds = %23
%33 = load i8*, i8** %3
%34 = load i8*, i8** %5
%35 = call i32 @doDelete(i8* %33, i8* %34)
store i32 %35, i32* %4
%36 = load i8*, i8** %5
%37 = call i32 @__PHYSFS_smallFree(i8* %36)
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %39
39: ; preds = %32, %30, %9
%40 = load i32, i32* %2
ret i32 %40
}

LLVM IR (-O2):
@.str = [17 x i8] c"Invalid argument\00"
@.str.1 = [14 x i8] c"Out of memory\00"
define i32 @PHYSFS_delete(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @__PHYSFS_setError(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %23
5: ; preds = %1
%6 = tail call i32 @strlen(i8* %0)
%7 = add nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = icmp ult i32 %7, 128
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = add nsw i64 %8, 1
%12 = tail call i32* @alloca(i64 %11)
br label %13
13: ; preds = %5, %10
%14 = phi i32* [ %12, %10 ], [ null, %5 ]
%15 = tail call i64 @__PHYSFS_initSmallAlloc(i32* %14, i64 %8)
%16 = inttoptr i64 %15 to i8*
%17 = icmp eq i64 %15, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @__PHYSFS_setError(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %23
20: ; preds = %13
%21 = tail call i32 @doDelete(i8* %0, i8* %16)
%22 = tail call i32 @__PHYSFS_smallFree(i8* %16)
br label %23
23: ; preds = %20, %18, %3
%24 = phi i32 [ 0, %3 ], [ 0, %18 ], [ %21, %20 ]
ret i32 %24
}