#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
void Iso2Raw_generateCue(char *binFileName) {
  int x, y;
  char binBaseName[256];
  char cueFileName[256];
  FILE *cue_file;
  for (x = (strlen(binFileName) - 1); x >= 0; x--) {
    if (binFileName[x] == '/' || binFileName[x] == '\\' ||
        binFileName[x] == ':')
      break;
  }
  x++;
  y = 0;
  for (; x < strlen(binFileName); x++)
    binBaseName[y++] = binFileName[x];
  binBaseName[y] = 0;
  y = 0;
  for (x = 0; x < strlen(binFileName); x++) {
    if (binFileName[x] == '.')
      break;
    else
      cueFileName[y++] = binFileName[x];
  }
  cueFileName[y] = 0;
  strcat(cueFileName, ".cue");
  cue_file = fopen(cueFileName, "wb");
  fprintf(cue_file, "FILE \"%s\" BINARY\n", binBaseName);
  fprintf(cue_file, "TRACK 01 MODE2/2352\n");
  fprintf(cue_file, "    INDEX 01 00:00:00\n");
  fclose(cue_file);
}


x86 assembly (clang, -O0):
<Iso2Raw_generateCue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jl     11cf <Iso2Raw_generateCue+0x7f>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
je     11b7 <Iso2Raw_generateCue+0x67>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5c,%eax
je     11b7 <Iso2Raw_generateCue+0x67>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
jne    11bc <Iso2Raw_generateCue+0x6c>
jmp    11cf <Iso2Raw_generateCue+0x7f>
jmp    11c1 <Iso2Raw_generateCue+0x71>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    116e <Iso2Raw_generateCue+0x1e>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x21c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x21c(%rbp),%eax
cmp    %ecx,%eax
jge    122e <Iso2Raw_generateCue+0xde>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11df <Iso2Raw_generateCue+0x8f>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x110(%rbp,%rax,1)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x220(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x220(%rbp),%eax
cmp    %ecx,%eax
jge    12b6 <Iso2Raw_generateCue+0x166>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    1284 <Iso2Raw_generateCue+0x134>
jmp    12b6 <Iso2Raw_generateCue+0x166>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0x210(%rbp,%rax,1)
jmp    12a8 <Iso2Raw_generateCue+0x158>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1248 <Iso2Raw_generateCue+0xf8>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x210(%rbp,%rax,1)
lea    -0x210(%rbp),%rdi
lea    0xd30(%rip),%rsi
call   1070 <strcat@plt>
lea    -0x210(%rbp),%rdi
lea    0xd22(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
lea    -0x110(%rbp),%rdx
lea    0xd04(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x218(%rbp),%rdi
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x218(%rbp),%rdi
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x218(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Iso2Raw_generateCue>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rdi,%r14
call   1040 <strlen@plt>
mov    %eax,%ecx
xor    %ebp,%ebp
test   %eax,%eax
cmovs  %eax,%ebp
movabs $0x200000000801,%rax
nopw   0x0(%rax,%rax,1)
test   %ecx,%ecx
jle    11b4 <Iso2Raw_generateCue+0x54>
movzbl -0x1(%r14,%rcx,1),%edx
add    $0xffffffffffffffff,%rcx
add    $0xd1,%dl
cmp    $0x2d,%dl
ja     1190 <Iso2Raw_generateCue+0x30>
movzbl %dl,%edx
bt     %rdx,%rax
jae    1190 <Iso2Raw_generateCue+0x30>
add    $0x1,%ecx
mov    %ecx,%ebp
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jge    11fc <Iso2Raw_generateCue+0x9c>
movslq %ebp,%r12
lea    (%r14,%r12,1),%r15
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%eax
lea    0x1(%rbx),%rbp
mov    %al,0x100(%rsp,%rbx,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
lea    (%r12,%rbx,1),%rcx
add    $0x1,%rcx
mov    %rbp,%rbx
cmp    %rax,%rcx
jl     11d0 <Iso2Raw_generateCue+0x70>
jmp    11fe <Iso2Raw_generateCue+0x9e>
xor    %ebp,%ebp
movb   $0x0,0x100(%rsp,%rbp,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %ebp,%ebp
test   %eax,%eax
jle    123f <Iso2Raw_generateCue+0xdf>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%r14,%rbp,1),%eax
cmp    $0x2e,%al
je     123f <Iso2Raw_generateCue+0xdf>
mov    %al,(%rsp,%rbp,1)
add    $0x1,%rbp
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1220 <Iso2Raw_generateCue+0xc0>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xdb4(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <strcat@plt>
lea    0xda7(%rip),%rsi
mov    %rbx,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xd98(%rip),%rsi
lea    0x100(%rsp),%rdx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xd91(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
lea    0xd8d(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c".cue\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [18 x i8] c"FILE \22%s\22 BINARY\0A\00"
@.str.3 = [21 x i8] c"TRACK 01 MODE2/2352\0A\00"
@.str.4 = [23 x i8] c" INDEX 01 00:00:00\0A\00"
define void @Iso2Raw_generateCue(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca i32*
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %3
br label %11
11: ; preds = %40, %1
%12 = load i32, i32* %3
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %43
14: ; preds = %11
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %38, label %22
22: ; preds = %14
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 92
br i1 %29, label %38, label %30
30: ; preds = %22
%31 = load i8*, i8** %2
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 58
br i1 %37, label %38, label %39
38: ; preds = %30, %22, %14
br label %43
39: ; preds = %30
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, -1
store i32 %42, i32* %3
br label %11
43: ; preds = %38, %11
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
store i32 0, i32* %4
br label %46
46: ; preds = %61, %43
%47 = load i32, i32* %3
%48 = load i8*, i8** %2
%49 = call i32 @strlen(i8* %48)
%50 = icmp slt i32 %47, %49
br i1 %50, label %51, label %64
51: ; preds = %46
%52 = load i8*, i8** %2
%53 = load i32, i32* %3
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %52, i64 %54
%56 = load i8, i8* %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %59
store i8 %56, i8* %60
br label %61
61: ; preds = %51
%62 = load i32, i32* %3
%63 = add nsw i32 %62, 1
store i32 %63, i32* %3
br label %46
64: ; preds = %46
%65 = load i32, i32* %4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %66
store i8 0, i8* %67
store i32 0, i32* %4
store i32 0, i32* %3
br label %68
68: ; preds = %93, %64
%69 = load i32, i32* %3
%70 = load i8*, i8** %2
%71 = call i32 @strlen(i8* %70)
%72 = icmp slt i32 %69, %71
br i1 %72, label %73, label %96
73: ; preds = %68
%74 = load i8*, i8** %2
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %74, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 46
br i1 %80, label %81, label %82
81: ; preds = %73
br label %96
82: ; preds = %73
%83 = load i8*, i8** %2
%84 = load i32, i32* %3
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = load i8, i8* %86
%88 = load i32, i32* %4
%89 = add nsw i32 %88, 1
store i32 %89, i32* %4
%90 = sext i32 %88 to i64
%91 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %90
store i8 %87, i8* %91
br label %92
92: ; preds = %82
br label %93
93: ; preds = %92
%94 = load i32, i32* %3
%95 = add nsw i32 %94, 1
store i32 %95, i32* %3
br label %68
96: ; preds = %81, %68
%97 = load i32, i32* %4
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %98
store i8 0, i8* %99
%100 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%101 = call i32 @strcat(i8* %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%103 = call i32* @fopen(i8* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %103, i32** %7
%104 = load i32*, i32** %7
%105 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %104, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %105)
%107 = load i32*, i32** %7
%108 = call i32 (i32*, i8*, ...) @fprintf(i32* %107, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%109 = load i32*, i32** %7
%110 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%111 = load i32*, i32** %7
%112 = call i32 @fclose(i32* %111)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".cue\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [18 x i8] c"FILE \22%s\22 BINARY\0A\00"
@.str.3 = [21 x i8] c"TRACK 01 MODE2/2352\0A\00"
@.str.4 = [23 x i8] c" INDEX 01 00:00:00\0A\00"
define void @Iso2Raw_generateCue(i8* %0) {
%2 = alloca [256 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @strlen(i8* %0)
%7 = zext i32 %6 to i64
%8 = call i32 @llvm.smin.i32(i32 %6, i32 0)
br label %9
9: ; preds = %14, %1
%10 = phi i64 [ %11, %14 ], [ %7, %1 ]
%11 = add nsw i64 %10, -1
%12 = trunc i64 %10 to i32
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %0, i64 %11
%16 = load i8, i8* %15
switch i8 %16, label %9 [
i8 47, label %17
i8 92, label %17
i8 58, label %17
]
17: ; preds = %14, %14, %14
%18 = trunc i64 %10 to i32
br label %19
19: ; preds = %9, %17
%20 = phi i32 [ %18, %17 ], [ %8, %9 ]
%21 = tail call i32 @strlen(i8* %0)
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = sext i32 %20 to i64
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ 0, %23 ], [ %30, %25 ]
%27 = phi i64 [ %24, %23 ], [ %32, %25 ]
%28 = getelementptr inbounds i8, i8* %0, i64 %27
%29 = load i8, i8* %28
%30 = add nuw nsw i64 %26, 1
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %26
store i8 %29, i8* %31
%32 = add nsw i64 %27, 1
%33 = tail call i32 @strlen(i8* %0)
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %25, label %36
36: ; preds = %25
%37 = and i64 %30, 4294967295
br label %38
38: ; preds = %36, %19
%39 = phi i64 [ 0, %19 ], [ %37, %36 ]
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %39
store i8 0, i8* %40
%41 = tail call i32 @strlen(i8* %0)
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %38, %48
%44 = phi i64 [ %49, %48 ], [ 0, %38 ]
%45 = getelementptr inbounds i8, i8* %0, i64 %44
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 46
br i1 %47, label %54, label %48
48: ; preds = %43
%49 = add nuw nsw i64 %44, 1
%50 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %44
store i8 %46, i8* %50
%51 = tail call i32 @strlen(i8* %0)
%52 = sext i32 %51 to i64
%53 = icmp slt i64 %49, %52
br i1 %53, label %43, label %54
54: ; preds = %48, %43, %38
%55 = phi i64 [ 0, %38 ], [ %44, %43 ], [ %49, %48 ]
%56 = and i64 %55, 4294967295
%57 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
%58 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%59 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%61 = call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 20, i64 1, i32* %59)
%62 = call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i64 22, i64 1, i32* %59)
%63 = call i32 @fclose(i32* %59)
ret void
}