#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 */
struct XorrisO {
  int dummy;
};

/* Variables and functions */
int Xorriso_make_abs_adr(struct XorrisO *, char *, char *, char *, int);
int /*<<< orphan*/ Xorriso_no_malloc_memory(struct XorrisO *,
                                            int /*<<< orphan*/ *,
                                            int /*<<< orphan*/);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int Xorriso_pfx_disk_path(struct XorrisO *xorriso, char *iso_path,
                          char *iso_prefix, char *disk_prefix,
                          char disk_path[4096], int flag) {
  int ret;
  char *adrc = NULL;
  {
    adrc = (char *)calloc(1, (4096) * sizeof(char));
    if (adrc == NULL) {
      Xorriso_no_malloc_memory(xorriso, NULL, 0);
      ret = -1;
      goto ex;
    }
  };
  if (strncmp(iso_path, iso_prefix, strlen(iso_prefix)) != 0) {
    ret = -1;
    goto ex;
  }
  if (strlen(disk_prefix) + strlen(iso_path) - strlen(iso_prefix) + 1 >= 4096) {
    ret = -1;
    goto ex;
  }
  if (iso_path[strlen(iso_prefix)] == '/')
    strcpy(adrc, iso_path + strlen(iso_prefix) + 1);
  else
    strcpy(adrc, iso_path + strlen(iso_prefix));
  ret = Xorriso_make_abs_adr(xorriso, disk_prefix, adrc, disk_path, 4 | 8);
  if (ret <= 0)
    goto ex;
  ret = 1;
ex:;
  {
    if (adrc != NULL)
      free((char *)adrc);
  };
  return (ret);
}


x86 assembly (clang, -O0):
<Xorriso_pfx_disk_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x1,%edi
mov    $0x1000,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11d4 <Xorriso_pfx_disk_path+0x64>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <Xorriso_no_malloc_memory@plt>
movl   $0xffffffff,-0x30(%rbp)
jmp    1315 <Xorriso_pfx_disk_path+0x1a5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
je     1212 <Xorriso_pfx_disk_path+0xa2>
movl   $0xffffffff,-0x30(%rbp)
jmp    1315 <Xorriso_pfx_disk_path+0x1a5>
mov    -0x20(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
add    $0x1,%eax
cmp    $0x1000,%eax
jl     125b <Xorriso_pfx_disk_path+0xeb>
movl   $0xffffffff,-0x30(%rbp)
jmp    1315 <Xorriso_pfx_disk_path+0x1a5>
mov    -0x10(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    12b6 <Xorriso_pfx_disk_path+0x146>
mov    -0x38(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x68(%rbp),%rsi
mov    -0x60(%rbp),%rdi
cltq
add    %rax,%rsi
add    $0x1,%rsi
call   1050 <strcpy@plt>
jmp    12e1 <Xorriso_pfx_disk_path+0x171>
mov    -0x38(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    -0x70(%rbp),%rdi
cltq
add    %rax,%rsi
call   1050 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0xc,%r8d
call   1090 <Xorriso_make_abs_adr@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jg     130e <Xorriso_pfx_disk_path+0x19e>
jmp    1315 <Xorriso_pfx_disk_path+0x1a5>
movl   $0x1,-0x30(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1329 <Xorriso_pfx_disk_path+0x1b9>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Xorriso_pfx_disk_path>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%rbp
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r15
mov    $0x1,%edi
mov    $0x1000,%esi
call   1070 <calloc@plt>
test   %rax,%rax
je     127c <Xorriso_pfx_disk_path+0x10c>
mov    %rax,%r12
mov    %r14,0x8(%rsp)
mov    %r13,%rdi
call   1060 <strlen@plt>
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %eax,%edx
call   1040 <strncmp@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
jne    1272 <Xorriso_pfx_disk_path+0x102>
mov    %r15,0x18(%rsp)
mov    %rbp,0x20(%rsp)
mov    0x8(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebx
mov    0x10(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
add    %ebx,%r15d
mov    %r13,%rdi
call   1060 <strlen@plt>
sub    %eax,%r15d
cmp    $0xffe,%r15d
jg     1272 <Xorriso_pfx_disk_path+0x102>
mov    %r13,%rdi
call   1060 <strlen@plt>
cltq
mov    0x10(%rsp),%rbx
mov    (%rbx,%rax,1),%r14b
mov    %r13,%rdi
call   1060 <strlen@plt>
movslq %eax,%rsi
add    %rbx,%rsi
cmp    $0x2f,%r14b
mov    0x20(%rsp),%rbp
mov    0x18(%rsp),%rbx
jne    1245 <Xorriso_pfx_disk_path+0xd5>
add    $0x1,%rsi
mov    %r12,%rdi
call   1050 <strcpy@plt>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %rbp,%rcx
mov    $0xc,%r8d
call   1090 <Xorriso_make_abs_adr@plt>
test   %eax,%eax
mov    $0x1,%r14d
cmovle %eax,%r14d
mov    %r12,%rdi
call   1030 <free@plt>
jmp    128e <Xorriso_pfx_disk_path+0x11e>
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <Xorriso_no_malloc_memory@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.XorrisO = type { i32 }
define i32 @Xorriso_pfx_disk_path(%struct.XorrisO* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca %struct.XorrisO*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store %struct.XorrisO* %0, %struct.XorrisO** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i8* null, i8** %14
%15 = call i64 @calloc(i32 1, i32 4096)
%16 = inttoptr i64 %15 to i8*
store i8* %16, i8** %14
%17 = load i8*, i8** %14
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %6
%20 = load %struct.XorrisO*, %struct.XorrisO** %7
%21 = call i32 @Xorriso_no_malloc_memory(%struct.XorrisO* %20, i32* null, i32 0)
store i32 -1, i32* %13
br label %78
22: ; preds = %6
%23 = load i8*, i8** %8
%24 = load i8*, i8** %9
%25 = load i8*, i8** %9
%26 = call i32 @strlen(i8* %25)
%27 = call i64 @strncmp(i8* %23, i8* %24, i32 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %22
store i32 -1, i32* %13
br label %78
30: ; preds = %22
%31 = load i8*, i8** %10
%32 = call i32 @strlen(i8* %31)
%33 = load i8*, i8** %8
%34 = call i32 @strlen(i8* %33)
%35 = add nsw i32 %32, %34
%36 = load i8*, i8** %9
%37 = call i32 @strlen(i8* %36)
%38 = sub nsw i32 %35, %37
%39 = add nsw i32 %38, 1
%40 = icmp sge i32 %39, 4096
br i1 %40, label %41, label %42
41: ; preds = %30
store i32 -1, i32* %13
br label %78
42: ; preds = %30
%43 = load i8*, i8** %8
%44 = load i8*, i8** %9
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 47
br i1 %50, label %51, label %60
51: ; preds = %42
%52 = load i8*, i8** %14
%53 = load i8*, i8** %8
%54 = load i8*, i8** %9
%55 = call i32 @strlen(i8* %54)
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = getelementptr inbounds i8, i8* %57, i64 1
%59 = call i32 @strcpy(i8* %52, i8* %58)
br label %68
60: ; preds = %42
%61 = load i8*, i8** %14
%62 = load i8*, i8** %8
%63 = load i8*, i8** %9
%64 = call i32 @strlen(i8* %63)
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %62, i64 %65
%67 = call i32 @strcpy(i8* %61, i8* %66)
br label %68
68: ; preds = %60, %51
%69 = load %struct.XorrisO*, %struct.XorrisO** %7
%70 = load i8*, i8** %10
%71 = load i8*, i8** %14
%72 = load i8*, i8** %11
%73 = call i32 @Xorriso_make_abs_adr(%struct.XorrisO* %69, i8* %70, i8* %71, i8* %72, i32 12)
store i32 %73, i32* %13
%74 = load i32, i32* %13
%75 = icmp sle i32 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %68
br label %78
77: ; preds = %68
store i32 1, i32* %13
br label %78
78: ; preds = %77, %76, %41, %29, %19
%79 = load i8*, i8** %14
%80 = icmp ne i8* %79, null
br i1 %80, label %81, label %84
81: ; preds = %78
%82 = load i8*, i8** %14
%83 = call i32 @free(i8* %82)
br label %84
84: ; preds = %81, %78
%85 = load i32, i32* %13
ret i32 %85
}

LLVM IR (-O2):
%struct.XorrisO = type { i32 }
define i32 @Xorriso_pfx_disk_path(%struct.XorrisO* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = tail call i64 @calloc(i32 1, i32 4096)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %39, label %10
10: ; preds = %6
%11 = tail call i32 @strlen(i8* %2)
%12 = tail call i64 @strncmp(i8* %1, i8* %2, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = tail call i32 @strlen(i8* %3)
%16 = tail call i32 @strlen(i8* %1)
%17 = add nsw i32 %16, %15
%18 = tail call i32 @strlen(i8* %2)
%19 = sub i32 %17, %18
%20 = icmp sgt i32 %19, 4094
br i1 %20, label %41, label %21
21: ; preds = %14
%22 = tail call i32 @strlen(i8* %2)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %1, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 47
%27 = tail call i32 @strlen(i8* %2)
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %1, i64 %28
br i1 %26, label %30, label %33
30: ; preds = %21
%31 = getelementptr inbounds i8, i8* %29, i64 1
%32 = tail call i32 @strcpy(i8* %8, i8* %31)
br label %35
33: ; preds = %21
%34 = tail call i32 @strcpy(i8* %8, i8* %29)
br label %35
35: ; preds = %33, %30
%36 = tail call i32 @Xorriso_make_abs_adr(%struct.XorrisO* %0, i8* %3, i8* %8, i8* %4, i32 12)
%37 = icmp slt i32 %36, 1
%38 = select i1 %37, i32 %36, i32 1
br label %41
39: ; preds = %6
%40 = tail call i32 @Xorriso_no_malloc_memory(%struct.XorrisO* %0, i32* null, i32 0)
br label %44
41: ; preds = %14, %10, %35
%42 = phi i32 [ -1, %14 ], [ -1, %10 ], [ %38, %35 ]
%43 = tail call i32 @free(i8* %8)
br label %44
44: ; preds = %39, %41
%45 = phi i32 [ %42, %41 ], [ -1, %39 ]
ret i32 %45
}