#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 PHYSFS_exists(char *);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
int cmd_exists(char *args) {
  int rc;
  if (*args == '\"') {
    args++;
    args[strlen(args) - 1] = '\0';
  }
  rc = PHYSFS_exists(args);
  printf("File %sexists.\n", rc ? "" : "does not ");
  return (1);
}


x86 assembly (clang, -O0):
<cmd_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x22,%eax
jne    1179 <cmd_exists+0x49>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rdi
call   1030 <PHYSFS_exists@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
lea    0xe81(%rip),%rsi
lea    0xe79(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe5c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_exists>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x22,(%rdi)
jne    1151 <cmd_exists+0x21>
lea    0x1(%rbx),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,(%rax,%rbx,1)
mov    %r14,%rbx
mov    %rbx,%rdi
call   1030 <PHYSFS_exists@plt>
test   %eax,%eax
lea    0xeae(%rip),%rax
lea    0xea6(%rip),%rsi
cmove  %rax,%rsi
lea    0xe8c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"File %sexists.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"does not \00"
define i32 @cmd_exists(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = icmp eq i32 %6, 34
br i1 %7, label %8, label %17
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %2
%11 = load i8*, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
%14 = sub nsw i32 %13, 1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %11, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %8, %1
%18 = load i8*, i8** %2
%19 = call i32 @PHYSFS_exists(i8* %18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp ne i32 %20, 0
%22 = zext i1 %21 to i64
%23 = select i1 %21, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0)
%24 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %23)
ret i32 1
}

LLVM IR (-O2):
@.str = [16 x i8] c"File %sexists.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [10 x i8] c"does not \00"
define i32 @cmd_exists(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 34
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = tail call i32 @strlen(i8* %5)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %5, i64 %8
store i8 0, i8* %9
br label %10
10: ; preds = %4, %1
%11 = phi i8* [ %5, %4 ], [ %0, %1 ]
%12 = tail call i32 @PHYSFS_exists(i8* %11)
%13 = icmp eq i32 %12, 0
%14 = select i1 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %14)
ret i32 1
}