#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int checkExt(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
void *malloc(int);
char *removeExt(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int main(int argc, char **argv) {
  if (argc < 3) {
    fprintf(stderr, "Usage: ./[programName] [files]\n");
    fprintf(stderr, "Examples: ./orcsco2csd *.orc *.sco || ./orcsco2csd "
                    "file.orc file.sco\n");
    return 1;
  }
  char **files = malloc(sizeof(char *) * (argc + 1));
  char **sco = malloc(sizeof(char *) * (argc + 1));
  char **orc = malloc(sizeof(char *) * (argc + 1));
  char *fileNoExt;
  char **pureNames = malloc(sizeof(char *) * (argc + 1));
  char *csdHeader =
      "<CsoundSynthesizer>\n<CsOptions>\n</CsOptions>\n<CsInstruments>\n\n";
  char *csdMiddle = "\n\n</CsInstruments>\n<CsScore>\n\n";
  char *csdFooter = "\n\n</CsScore>\n</CsoundSynthesizer>\n";
  int i;
  int orci = 1, scoi = 1;
  for (i = 0; i < argc - 1; i++) {
    files[i] = argv[i + 1];
    int type = checkExt(files[i]);
    switch (type) {
    case 0:
      orc[orci] = files[i];
      orci++;
      break;
    case 1:
      sco[scoi] = files[i];
      scoi++;
      break;
    default:
      break;
    }
    fileNoExt = removeExt(sco[scoi - 1]);
    pureNames[i] = fileNoExt;
  }
  for (i = 1; i <= scoi - 1; i++) {
    FILE *scoPointer = fopen(sco[i], "rb");
    char *scoContents = 0;
    long scoLength;
    if (scoPointer) {
      fseek(scoPointer, 0, SEEK_END);
      scoLength = ftell(scoPointer);
      fseek(scoPointer, 0, SEEK_SET);
      scoContents = malloc(scoLength);
      if (scoContents) {
        fread(scoContents, 1, scoLength, scoPointer);
      }
      fclose(scoPointer);
    }
    FILE *orcPointer = fopen(orc[i], "rb");
    char *orcContents = 0;
    long orcLength;
    if (orcPointer) {
      fseek(orcPointer, 0, SEEK_END);
      orcLength = ftell(orcPointer);
      fseek(orcPointer, 0, SEEK_SET);
      orcContents = malloc(orcLength);
      if (orcContents) {
        fread(orcContents, 1, orcLength, orcPointer);
      }
      fclose(orcPointer);
    }
    char *csdContents = malloc(4294967296);
    strcat(csdContents, csdHeader);
    strcat(csdContents, orcContents);
    strcat(csdContents, csdMiddle);
    strcat(csdContents, scoContents);
    strcat(csdContents, csdFooter);
    char *csdFileName = malloc(512);
    sprintf(csdFileName, "%s.csd", pureNames[i]);
    FILE *csdOutput = fopen(csdFileName, "w");
    fprintf(csdOutput, "%s", csdContents);
    fclose(csdOutput);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    120f <main+0x5f>
mov    0x2dfe(%rip),%rax
movslq (%rax),%rdi
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2de6(%rip),%rax
movslq (%rax),%rdi
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    15dd <main+0x42d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xdf4(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe28(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe3c(%rip),%rax
mov    %rax,-0x50(%rbp)
movl   $0x1,-0x58(%rbp)
movl   $0x1,-0x5c(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    138e <main+0x1de>
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    0x8(%rax,%rcx,8),%rdx
mov    -0x18(%rbp),%rax
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   10d0 <checkExt@plt>
mov    %eax,-0x60(%rbp)
mov    -0x60(%rbp),%eax
mov    %eax,-0xac(%rbp)
test   %eax,%eax
je     1305 <main+0x155>
jmp    12f1 <main+0x141>
mov    -0xac(%rbp),%eax
sub    $0x1,%eax
je     132b <main+0x17b>
jmp    1351 <main+0x1a1>
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x28(%rbp),%rax
movslq -0x58(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1356 <main+0x1a6>
mov    -0x18(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
mov    -0x20(%rbp),%rax
movslq -0x5c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1356 <main+0x1a6>
jmp    1356 <main+0x1a6>
mov    -0x20(%rbp),%rax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <removeExt@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    12a1 <main+0xf1>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x5c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     15d6 <main+0x426>
mov    -0x20(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xd2e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     1443 <main+0x293>
mov    -0x68(%rbp),%rdi
mov    0x2c08(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x68(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rdi
mov    0x2bcf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x78(%rbp),%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
je     143a <main+0x28a>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rdx
mov    -0x68(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x68(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc91(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x88(%rbp)
cmpq   $0x0,-0x80(%rbp)
je     14f5 <main+0x345>
mov    -0x80(%rbp),%rdi
mov    0x2b68(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x80(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x90(%rbp)
mov    -0x80(%rbp),%rdi
mov    0x2b2c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x90(%rbp),%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     14ec <main+0x33c>
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    -0x80(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    -0x80(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1080 <malloc@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x98(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x98(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x98(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x98(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   10b0 <strcat@plt>
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,-0xa0(%rbp)
mov    -0xa0(%rbp),%rdi
mov    -0x38(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xb69(%rip),%rsi
call   10c0 <sprintf@plt>
mov    -0xa0(%rbp),%rdi
lea    0xb5d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0x98(%rbp),%rdx
lea    0xb3e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0xa8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1395 <main+0x1e5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,(%rsp)
cmp    $0x2,%edi
jg     121b <main+0x5b>
mov    0x2dfa(%rip),%rbx
movslq (%rbx),%rcx
lea    0xe18(%rip),%rdi
mov    $0x1f,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
movslq (%rbx),%rcx
lea    0xe1f(%rip),%rdi
mov    $0x45,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
mov    $0x1,%r15d
jmp    14a3 <main+0x2e3>
mov    %edi,%r15d
lea    0x8(,%r15,8),%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,0x10(%rsp)
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,0x18(%rsp)
add    $0xffffffff,%r15d
mov    $0x1,%r12d
xor    %r14d,%r14d
mov    $0x1,%r13d
jmp    128b <main+0xcb>
nop
movslq %r13d,%r13
mov    0x8(%rsp),%rcx
mov    %rbp,(%rcx,%r13,8)
add    $0x1,%r13d
movslq %r13d,%rax
mov    -0x8(%rcx,%rax,8),%rdi
call   1050 <removeExt@plt>
mov    0x18(%rsp),%rcx
mov    %rax,(%rcx,%rbx,8)
cmp    %r14,%r15
je     12c3 <main+0x103>
mov    %r14,%rbx
add    $0x1,%r14
mov    (%rsp),%rax
mov    0x8(%rax,%rbx,8),%rbp
mov    %rbp,%rdi
call   10e0 <checkExt@plt>
cmp    $0x1,%eax
je     1260 <main+0xa0>
test   %eax,%eax
mov    0x8(%rsp),%rcx
jne    1270 <main+0xb0>
movslq %r12d,%r12
mov    0x10(%rsp),%rax
mov    %rbp,(%rax,%r12,8)
add    $0x1,%r12d
jmp    1270 <main+0xb0>
xor    %r15d,%r15d
cmp    $0x2,%r13d
jl     14a3 <main+0x2e3>
mov    %r13d,%eax
mov    %rax,0x20(%rsp)
mov    $0x1,%r13d
lea    0xe02(%rip),%r12
xor    %r15d,%r15d
jmp    13a1 <main+0x1e1>
nopl   (%rax)
xor    %r14d,%r14d
xor    %edi,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
lea    0xd5f(%rip),%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
lea    0xd84(%rip),%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
mov    (%rsp),%rsi
call   10b0 <strcat@plt>
mov    %r12,%rdi
lea    0xd88(%rip),%rsi
call   10b0 <strcat@plt>
mov    $0x200,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
mov    0x18(%rsp),%rax
mov    (%rax,%r13,8),%rdx
mov    %rbp,%rdi
lea    0xd89(%rip),%rsi
call   10c0 <sprintf@plt>
mov    %rbp,%rdi
lea    0xd81(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
mov    %rax,%rsi
call   1060 <fputs@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
add    $0x1,%r13
cmp    %r13,0x20(%rsp)
lea    0xd4c(%rip),%r12
je     14a3 <main+0x2e3>
mov    0x8(%rsp),%rax
mov    (%rax,%r13,8),%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1420 <main+0x260>
mov    %rax,%rbx
mov    0x2c27(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,%r14
mov    0x2bf1(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r14d,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
test   %rax,%rax
je     140e <main+0x24e>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    1422 <main+0x262>
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
mov    0x10(%rsp),%rax
mov    (%rax,%r13,8),%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
mov    %rbp,(%rsp)
je     12f0 <main+0x130>
mov    %rax,%rbx
mov    0x2b9e(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %rax,%rbp
mov    0x2b68(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%r14
test   %rax,%rax
je     1496 <main+0x2d6>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
jmp    12f3 <main+0x133>
mov    %r15d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Usage: ./[programName] [files]\0A\00"
@.str.1 = [70 x i8] c"Examples: ./orcsco2csd *.orc *.sco || ./orcsco2csd file.orc file.sco\0A\00"
@.str.2 = [63 x i8] c"<CsoundSynthesizer>\0A<CsOptions>\0A</CsOptions>\0A<CsInstruments>\0A\0A\00"
@.str.3 = [31 x i8] c"\0A\0A</CsInstruments>\0A<CsScore>\0A\0A\00"
@.str.4 = [35 x i8] c"\0A\0A</CsScore>\0A</CsoundSynthesizer>\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [7 x i8] c"%s.csd\00"
@.str.7 = [2 x i8] c"w\00"
@.str.8 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca i8**
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i8*
%20 = alloca i64
%21 = alloca i32*
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%27 = load i32, i32* %4
%28 = icmp slt i32 %27, 3
br i1 %28, label %29, label %38
29: ; preds = %2
%30 = load i32, i32* @stderr
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i32*
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = sext i32 %34 to i64
%36 = inttoptr i64 %35 to i32*
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %235
38: ; preds = %2
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = mul i64 8, %41
%43 = trunc i64 %42 to i32
%44 = call i8* @malloc(i32 %43)
%45 = bitcast i8* %44 to i8**
store i8** %45, i8*** %6
%46 = load i32, i32* %4
%47 = add nsw i32 %46, 1
%48 = sext i32 %47 to i64
%49 = mul i64 8, %48
%50 = trunc i64 %49 to i32
%51 = call i8* @malloc(i32 %50)
%52 = bitcast i8* %51 to i8**
store i8** %52, i8*** %7
%53 = load i32, i32* %4
%54 = add nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = mul i64 8, %55
%57 = trunc i64 %56 to i32
%58 = call i8* @malloc(i32 %57)
%59 = bitcast i8* %58 to i8**
store i8** %59, i8*** %8
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
%62 = sext i32 %61 to i64
%63 = mul i64 8, %62
%64 = trunc i64 %63 to i32
%65 = call i8* @malloc(i32 %64)
%66 = bitcast i8* %65 to i8**
store i8** %66, i8*** %10
store i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8** %13
store i32 1, i32* %15
store i32 1, i32* %16
store i32 0, i32* %14
br label %67
67: ; preds = %128, %38
%68 = load i32, i32* %14
%69 = load i32, i32* %4
%70 = sub nsw i32 %69, 1
%71 = icmp slt i32 %68, %70
br i1 %71, label %72, label %131
72: ; preds = %67
%73 = load i8**, i8*** %5
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %73, i64 %76
%78 = load i8*, i8** %77
%79 = load i8**, i8*** %6
%80 = load i32, i32* %14
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
store i8* %78, i8** %82
%83 = load i8**, i8*** %6
%84 = load i32, i32* %14
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
%88 = call i32 @checkExt(i8* %87)
store i32 %88, i32* %17
%89 = load i32, i32* %17
switch i32 %89, label %114 [
i32 0, label %90
i32 1, label %102
]
90: ; preds = %72
%91 = load i8**, i8*** %6
%92 = load i32, i32* %14
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i8*, i8** %91, i64 %93
%95 = load i8*, i8** %94
%96 = load i8**, i8*** %8
%97 = load i32, i32* %15
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i8*, i8** %96, i64 %98
store i8* %95, i8** %99
%100 = load i32, i32* %15
%101 = add nsw i32 %100, 1
store i32 %101, i32* %15
br label %115
102: ; preds = %72
%103 = load i8**, i8*** %6
%104 = load i32, i32* %14
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8*, i8** %103, i64 %105
%107 = load i8*, i8** %106
%108 = load i8**, i8*** %7
%109 = load i32, i32* %16
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8*, i8** %108, i64 %110
store i8* %107, i8** %111
%112 = load i32, i32* %16
%113 = add nsw i32 %112, 1
store i32 %113, i32* %16
br label %115
114: ; preds = %72
br label %115
115: ; preds = %114, %102, %90
%116 = load i8**, i8*** %7
%117 = load i32, i32* %16
%118 = sub nsw i32 %117, 1
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8*, i8** %116, i64 %119
%121 = load i8*, i8** %120
%122 = call i8* @removeExt(i8* %121)
store i8* %122, i8** %9
%123 = load i8*, i8** %9
%124 = load i8**, i8*** %10
%125 = load i32, i32* %14
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i8*, i8** %124, i64 %126
store i8* %123, i8** %127
br label %128
128: ; preds = %115
%129 = load i32, i32* %14
%130 = add nsw i32 %129, 1
store i32 %130, i32* %14
br label %67
131: ; preds = %67
store i32 1, i32* %14
br label %132
132: ; preds = %231, %131
%133 = load i32, i32* %14
%134 = load i32, i32* %16
%135 = sub nsw i32 %134, 1
%136 = icmp sle i32 %133, %135
br i1 %136, label %137, label %234
137: ; preds = %132
%138 = load i8**, i8*** %7
%139 = load i32, i32* %14
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8*, i8** %138, i64 %140
%142 = load i8*, i8** %141
%143 = call i32* @fopen(i8* %142, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %143, i32** %18
store i8* null, i8** %19
%144 = load i32*, i32** %18
%145 = icmp ne i32* %144, null
br i1 %145, label %146, label %168
146: ; preds = %137
%147 = load i32*, i32** %18
%148 = load i32, i32* @SEEK_END
%149 = call i32 @fseek(i32* %147, i32 0, i32 %148)
%150 = load i32*, i32** %18
%151 = call i64 @ftell(i32* %150)
store i64 %151, i64* %20
%152 = load i32*, i32** %18
%153 = load i32, i32* @SEEK_SET
%154 = call i32 @fseek(i32* %152, i32 0, i32 %153)
%155 = load i64, i64* %20
%156 = trunc i64 %155 to i32
%157 = call i8* @malloc(i32 %156)
store i8* %157, i8** %19
%158 = load i8*, i8** %19
%159 = icmp ne i8* %158, null
br i1 %159, label %160, label %165
160: ; preds = %146
%161 = load i8*, i8** %19
%162 = load i64, i64* %20
%163 = load i32*, i32** %18
%164 = call i32 @fread(i8* %161, i32 1, i64 %162, i32* %163)
br label %165
165: ; preds = %160, %146
%166 = load i32*, i32** %18
%167 = call i32 @fclose(i32* %166)
br label %168
168: ; preds = %165, %137
%169 = load i8**, i8*** %8
%170 = load i32, i32* %14
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8*, i8** %169, i64 %171
%173 = load i8*, i8** %172
%174 = call i32* @fopen(i8* %173, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %174, i32** %21
store i8* null, i8** %22
%175 = load i32*, i32** %21
%176 = icmp ne i32* %175, null
br i1 %176, label %177, label %199
177: ; preds = %168
%178 = load i32*, i32** %21
%179 = load i32, i32* @SEEK_END
%180 = call i32 @fseek(i32* %178, i32 0, i32 %179)
%181 = load i32*, i32** %21
%182 = call i64 @ftell(i32* %181)
store i64 %182, i64* %23
%183 = load i32*, i32** %21
%184 = load i32, i32* @SEEK_SET
%185 = call i32 @fseek(i32* %183, i32 0, i32 %184)
%186 = load i64, i64* %23
%187 = trunc i64 %186 to i32
%188 = call i8* @malloc(i32 %187)
store i8* %188, i8** %22
%189 = load i8*, i8** %22
%190 = icmp ne i8* %189, null
br i1 %190, label %191, label %196
191: ; preds = %177
%192 = load i8*, i8** %22
%193 = load i64, i64* %23
%194 = load i32*, i32** %21
%195 = call i32 @fread(i8* %192, i32 1, i64 %193, i32* %194)
br label %196
196: ; preds = %191, %177
%197 = load i32*, i32** %21
%198 = call i32 @fclose(i32* %197)
br label %199
199: ; preds = %196, %168
%200 = call i8* @malloc(i32 0)
store i8* %200, i8** %24
%201 = load i8*, i8** %24
%202 = load i8*, i8** %11
%203 = call i32 @strcat(i8* %201, i8* %202)
%204 = load i8*, i8** %24
%205 = load i8*, i8** %22
%206 = call i32 @strcat(i8* %204, i8* %205)
%207 = load i8*, i8** %24
%208 = load i8*, i8** %12
%209 = call i32 @strcat(i8* %207, i8* %208)
%210 = load i8*, i8** %24
%211 = load i8*, i8** %19
%212 = call i32 @strcat(i8* %210, i8* %211)
%213 = load i8*, i8** %24
%214 = load i8*, i8** %13
%215 = call i32 @strcat(i8* %213, i8* %214)
%216 = call i8* @malloc(i32 512)
store i8* %216, i8** %25
%217 = load i8*, i8** %25
%218 = load i8**, i8*** %10
%219 = load i32, i32* %14
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i8*, i8** %218, i64 %220
%222 = load i8*, i8** %221
%223 = call i32 @sprintf(i8* %217, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %222)
%224 = load i8*, i8** %25
%225 = call i32* @fopen(i8* %224, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %225, i32** %26
%226 = load i32*, i32** %26
%227 = load i8*, i8** %24
%228 = call i32 (i32*, i8*, ...) @fprintf(i32* %226, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %227)
%229 = load i32*, i32** %26
%230 = call i32 @fclose(i32* %229)
br label %231
231: ; preds = %199
%232 = load i32, i32* %14
%233 = add nsw i32 %232, 1
store i32 %233, i32* %14
br label %132
234: ; preds = %132
store i32 0, i32* %3
br label %235
235: ; preds = %234, %29
%236 = load i32, i32* %3
ret i32 %236
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Usage: ./[programName] [files]\0A\00"
@.str.1 = [70 x i8] c"Examples: ./orcsco2csd *.orc *.sco || ./orcsco2csd file.orc file.sco\0A\00"
@.str.2 = [63 x i8] c"<CsoundSynthesizer>\0A<CsOptions>\0A</CsOptions>\0A<CsInstruments>\0A\0A\00"
@.str.3 = [31 x i8] c"\0A\0A</CsInstruments>\0A<CsScore>\0A\0A\00"
@.str.4 = [35 x i8] c"\0A\0A</CsScore>\0A</CsoundSynthesizer>\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.6 = [7 x i8] c"%s.csd\00"
@.str.7 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 31, i64 1, i32* %7)
%9 = load i32, i32* @stderr
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.1, i64 0, i64 0), i64 69, i64 1, i32* %11)
br label %109
13: ; preds = %2
%14 = shl i32 %0, 3
%15 = add i32 %14, 8
%16 = tail call i8* @malloc(i32 %15)
%17 = bitcast i8* %16 to i8**
%18 = tail call i8* @malloc(i32 %15)
%19 = bitcast i8* %18 to i8**
%20 = tail call i8* @malloc(i32 %15)
%21 = bitcast i8* %20 to i8**
%22 = add nsw i32 %0, -1
%23 = zext i32 %22 to i64
br label %28
24: ; preds = %44
%25 = icmp sgt i32 %45, 1
br i1 %25, label %26, label %109
26: ; preds = %24
%27 = zext i32 %45 to i64
br label %54
28: ; preds = %13, %44
%29 = phi i64 [ 0, %13 ], [ %32, %44 ]
%30 = phi i32 [ 1, %13 ], [ %46, %44 ]
%31 = phi i32 [ 1, %13 ], [ %45, %44 ]
%32 = add nuw nsw i64 %29, 1
%33 = getelementptr inbounds i8*, i8** %1, i64 %32
%34 = load i8*, i8** %33
%35 = tail call i32 @checkExt(i8* %34)
switch i32 %35, label %44 [
i32 0, label %36
i32 1, label %40
]
36: ; preds = %28
%37 = sext i32 %30 to i64
%38 = getelementptr inbounds i8*, i8** %19, i64 %37
store i8* %34, i8** %38
%39 = add nsw i32 %30, 1
br label %44
40: ; preds = %28
%41 = sext i32 %31 to i64
%42 = getelementptr inbounds i8*, i8** %17, i64 %41
store i8* %34, i8** %42
%43 = add nsw i32 %31, 1
br label %44
44: ; preds = %28, %40, %36
%45 = phi i32 [ %31, %28 ], [ %43, %40 ], [ %31, %36 ]
%46 = phi i32 [ %30, %28 ], [ %30, %40 ], [ %39, %36 ]
%47 = add nsw i32 %45, -1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %17, i64 %48
%50 = load i8*, i8** %49
%51 = tail call i8* @removeExt(i8* %50)
%52 = getelementptr inbounds i8*, i8** %21, i64 %29
store i8* %51, i8** %52
%53 = icmp eq i64 %32, %23
br i1 %53, label %24, label %28
54: ; preds = %26, %92
%55 = phi i64 [ 1, %26 ], [ %107, %92 ]
%56 = getelementptr inbounds i8*, i8** %17, i64 %55
%57 = load i8*, i8** %56
%58 = tail call i32* @fopen(i8* %57, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%59 = icmp eq i32* %58, null
br i1 %59, label %73, label %60
60: ; preds = %54
%61 = load i32, i32* @SEEK_END
%62 = tail call i32 @fseek(i32* %58, i32 0, i32 %61)
%63 = tail call i64 @ftell(i32* %58)
%64 = load i32, i32* @SEEK_SET
%65 = tail call i32 @fseek(i32* %58, i32 0, i32 %64)
%66 = trunc i64 %63 to i32
%67 = tail call i8* @malloc(i32 %66)
%68 = icmp eq i8* %67, null
br i1 %68, label %71, label %69
69: ; preds = %60
%70 = tail call i32 @fread(i8* %67, i32 1, i64 %63, i32* %58)
br label %71
71: ; preds = %69, %60
%72 = tail call i32 @fclose(i32* %58)
br label %73
73: ; preds = %71, %54
%74 = phi i8* [ %67, %71 ], [ null, %54 ]
%75 = getelementptr inbounds i8*, i8** %19, i64 %55
%76 = load i8*, i8** %75
%77 = tail call i32* @fopen(i8* %76, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%78 = icmp eq i32* %77, null
br i1 %78, label %92, label %79
79: ; preds = %73
%80 = load i32, i32* @SEEK_END
%81 = tail call i32 @fseek(i32* %77, i32 0, i32 %80)
%82 = tail call i64 @ftell(i32* %77)
%83 = load i32, i32* @SEEK_SET
%84 = tail call i32 @fseek(i32* %77, i32 0, i32 %83)
%85 = trunc i64 %82 to i32
%86 = tail call i8* @malloc(i32 %85)
%87 = icmp eq i8* %86, null
br i1 %87, label %90, label %88
88: ; preds = %79
%89 = tail call i32 @fread(i8* %86, i32 1, i64 %82, i32* %77)
br label %90
90: ; preds = %88, %79
%91 = tail call i32 @fclose(i32* %77)
br label %92
92: ; preds = %90, %73
%93 = phi i8* [ %86, %90 ], [ null, %73 ]
%94 = tail call i8* @malloc(i32 0)
%95 = tail call i32 @strcat(i8* %94, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0))
%96 = tail call i32 @strcat(i8* %94, i8* %93)
%97 = tail call i32 @strcat(i8* %94, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%98 = tail call i32 @strcat(i8* %94, i8* %74)
%99 = tail call i32 @strcat(i8* %94, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%100 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%101 = getelementptr inbounds i8*, i8** %21, i64 %55
%102 = load i8*, i8** %101
%103 = tail call i32 @sprintf(i8* dereferenceable(1) %100, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i8* %102)
%104 = tail call i32* @fopen(i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%105 = tail call i32 @fputs(i8* %94, i32* %104)
%106 = tail call i32 @fclose(i32* %104)
%107 = add nuw nsw i64 %55, 1
%108 = icmp eq i64 %107, %27
br i1 %108, label %109, label %54
109: ; preds = %92, %24, %4
%110 = phi i32 [ 1, %4 ], [ 0, %24 ], [ 0, %92 ]
ret i32 %110
}