#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 *, 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");
  rename(destfilename, 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>
lea    -0x410(%rbp),%rsi
lea    0xdc1(%rip),%rdi
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   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%r12
lea    0x400(%rsp),%r14
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0x3fc,%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0xfffffffffffffffc,%rdi
lea    0xe19(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe12(%rip),%rsi
mov    %r14,%rdi
call   1080 <fopen@plt>
mov    %rax,%rbx
lea    0xe02(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xe00(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
lea    0xdfb(%rip),%rdi
mov    $0x11,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   10a0 <fwrite@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <rename@plt>
lea    0xde9(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x808,%rsp
pop    %rbx
pop    %r12
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 = [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 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %38)
%40 = load i32*, i32** %5
%41 = call i32 @fclose(i32* %40)
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 = [23 x i8] c"Create Cuesheets : %s\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 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %4)
%24 = call i32 @fclose(i32* %18)
ret void
}