#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 */
char *PHYSFS_getRealDir(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int cmd_getrealdir(char *args) {
  const char *rc;
  if (*args == '\"') {
    args++;
    args[strlen(args) - 1] = '\0';
  }
  rc = PHYSFS_getRealDir(args);
  if (rc)
    printf("Found at [%s].\n", rc);
  else
    printf("Not found.\n");
  return (1);
}


x86 assembly (clang, -O0):
<cmd_getrealdir>:
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_getrealdir+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_getRealDir@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a8 <cmd_getrealdir+0x78>
mov    -0x10(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11b6 <cmd_getrealdir+0x86>
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_getrealdir>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmpb   $0x22,(%rdi)
jne    1161 <cmd_getrealdir+0x21>
lea    0x1(%rbx),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
cltq
movb   $0x0,(%rax,%rbx,1)
mov    %r14,%rbx
mov    %rbx,%rdi
call   1040 <PHYSFS_getRealDir@plt>
test   %rax,%rax
je     1181 <cmd_getrealdir+0x41>
lea    0xe8b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    118d <cmd_getrealdir+0x4d>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Found at [%s].\0A\00"
@.str.1 = [12 x i8] c"Not found.\0A\00"
define i32 @cmd_getrealdir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
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 i8* @PHYSFS_getRealDir(i8* %18)
store i8* %19, i8** %3
%20 = load i8*, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %23)
br label %27
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
ret i32 1
}

LLVM IR (-O2):
@.str = [16 x i8] c"Found at [%s].\0A\00"
@str = [11 x i8] c"Not found.\00"
define i32 @cmd_getrealdir(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 i8* @PHYSFS_getRealDir(i8* %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %18
16: ; preds = %10
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
ret i32 1
}