#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*/ printf(char *, ...);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void cuesheets(char *destfilename) {
  char destfilecue[1024], destfilebin[1024];
  FILE *fcue;
  strcpy(destfilecue, destfilename);
  strcpy(destfilebin, destfilename);
  strcpy(destfilecue + strlen(destfilename) - 4, ".cue");
  strcpy(destfilebin + strlen(destfilename) - 4, ".bin");
  fcue = fopen(destfilecue, "w");
  fprintf(fcue, "FILE \"%s\" BINARY\n", destfilebin);
  fprintf(fcue, "TRACK 1 MODE1/2352\n");
  fprintf(fcue, "INDEX 1 00:00:00\n");
  if (!rename(destfilename, destfilebin) == 0) {
    printf("\nSorry, I don't create %s,\nbecause is in use", destfilebin);
    printf(" or this file exists\n\n");
  } else {
    printf("Create Bin       : %s\n", destfilebin);
  }
  printf("Create Cuesheets : %s\n", destfilecue);
  fclose(fcue);
}


x86 assembly (clang, -O0):
<cuesheets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x828(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe33(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x810(%rbp),%rax
mov    %rax,-0x820(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x820(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe05(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x818(%rbp)
mov    -0x818(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x818(%rbp),%rdi
lea    0xdd5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x818(%rbp),%rdi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   1090 <rename@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jne    12b3 <cuesheets+0x143>
lea    -0x810(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12c8 <cuesheets+0x158>
lea    -0x810(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x818(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cuesheets>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rdi,%rbx
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0x3fc,%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe0b(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe04(%rip),%rsi
mov    %r14,%rdi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0xdf4(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
lea    0xdf2(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
lea    0xded(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10b0 <fwrite@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <rename@plt>
test   %eax,%eax
je     1285 <cuesheets+0xf5>
lea    0xdd7(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe21(%rip),%rdi
call   1040 <puts@plt>
jmp    1296 <cuesheets+0x106>
lea    0xde5(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdeb(%rip),%rdi
lea    0x400(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c".cue\00"
@.str.1 = [5 x i8] c".bin\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [18 x i8] c"FILE \22%s\22 BINARY\0A\00"
@.str.4 = [20 x i8] c"TRACK 1 MODE1/2352\0A\00"
@.str.5 = [18 x i8] c"INDEX 1 00:00:00\0A\00"
@.str.6 = [45 x i8] c"\0ASorry, I don't create %s,\0Abecause is in use\00"
@.str.7 = [23 x i8] c" or this file exists\0A\0A\00"
@.str.8 = [23 x i8] c"Create Bin : %s\0A\00"
@.str.9 = [23 x i8] c"Create Cuesheets : %s\0A\00"
define void @cuesheets(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca i32*
store i8* %0, i8** %2
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = call i32 @strcpy(i8* %6, i8* %7)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %12, i64 %15
%17 = getelementptr inbounds i8, i8* %16, i64 -4
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%20 = load i8*, i8** %2
%21 = call i32 @strlen(i8* %20)
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = getelementptr inbounds i8, i8* %23, i64 -4
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %27, i32** %5
%28 = load i32*, i32** %5
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = load i32*, i32** %5
%32 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%33 = load i32*, i32** %5
%34 = call i32 (i32*, i8*, ...) @fprintf(i32* %33, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%35 = load i8*, i8** %2
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%37 = call i32 @rename(i8* %35, i8* %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %1
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %49
46: ; preds = %1
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %46, %42
%50 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %50)
%52 = load i32*, i32** %5
%53 = call i32 @fclose(i32* %52)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c".cue\00"
@.str.1 = [5 x i8] c".bin\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [18 x i8] c"FILE \22%s\22 BINARY\0A\00"
@.str.4 = [20 x i8] c"TRACK 1 MODE1/2352\0A\00"
@.str.5 = [18 x i8] c"INDEX 1 00:00:00\0A\00"
@.str.6 = [45 x i8] c"\0ASorry, I don't create %s,\0Abecause is in use\00"
@.str.8 = [23 x i8] c"Create Bin : %s\0A\00"
@.str.9 = [23 x i8] c"Create Cuesheets : %s\0A\00"
@str = [22 x i8] c" or this file exists\0A\00"
define void @cuesheets(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %4, i8* %0)
%7 = call i32 @strcpy(i8* %5, i8* %0)
%8 = call i32 @strlen(i8* %0)
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -4
%12 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @strlen(i8* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 -4
%17 = call i32 @strcpy(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %18, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %5)
%20 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i64 19, i64 1, i32* %18)
%21 = call i64 @fwrite(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i64 17, i64 1, i32* %18)
%22 = call i32 @rename(i8* %0, i8* %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %1
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %29
27: ; preds = %1
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %5)
br label %29
29: ; preds = %27, %24
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i8* %4)
%31 = call i32 @fclose(i32* %18)
ret void
}