#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*/ atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ voicefont(int /*<<< orphan*/ *, int /*<<< orphan*/, char *,
                             int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  FILE *ids, *output;
  if (argc < 2) {
    printf("Makes a Rockbox voicefont from a collection of mp3 clips.\n");
    printf("Usage: voicefont <string id list file> <target id> <mp3 path> "
           "<output file>\n");
    printf("\n");
    printf("Example: \n");
    printf("voicefont voicefontids.txt 2 voice\\ voicefont.bin\n");
    return -1;
  }
  ids = fopen(argv[1], "r");
  if (ids == NULL) {
    printf("Error opening language file %s\n", argv[1]);
    return -2;
  }
  output = fopen(argv[4], "wb");
  if (output == NULL) {
    printf("Error opening output file %s\n", argv[4]);
    return -2;
  }
  voicefont(ids, atoi(argv[2]), argv[3], output, 400);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b2 <main+0x72>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1275 <main+0x135>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf05(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f7 <main+0xb7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1275 <main+0x135>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xee2(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123c <main+0xfc>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rsi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1275 <main+0x135>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x190,%r8d
call   1060 <voicefont@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     11ab <main+0x4b>
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
lea    0xf00(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf36(%rip),%rdi
call   1040 <puts@plt>
lea    0xf34(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%eax
jmp    1226 <main+0xc6>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe47(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1202 <main+0xa2>
mov    %rax,%r14
mov    0x20(%rbx),%rdi
lea    0xe51(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     120f <main+0xaf>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    0x18(%rbx),%rdx
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15,%rcx
mov    $0x190,%r8d
call   1080 <voicefont@plt>
xor    %eax,%eax
jmp    1226 <main+0xc6>
mov    0x8(%rbx),%rsi
lea    0xdf5(%rip),%rdi
jmp    121a <main+0xba>
mov    0x20(%rbx),%rsi
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xfffffffe,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [59 x i8] c"Makes a Rockbox voicefont from a collection of mp3 clips.\0A\00"
@.str.1 = [77 x i8] c"Usage: voicefont <string id list file> <target id> <mp3 path> <output file>\0A\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [11 x i8] c"Example: \0A\00"
@.str.4 = [51 x i8] c"voicefont voicefontids.txt 2 voice\\ voicefont.bin\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [32 x i8] c"Error opening language file %s\0A\00"
@.str.7 = [3 x i8] c"wb\00"
@.str.8 = [30 x i8] c"Error opening output file %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %51
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %20, i32** %6
%21 = load i32*, i32** %6
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %26)
store i32 -2, i32* %3
br label %51
28: ; preds = %16
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 4
%31 = load i8*, i8** %30
%32 = call i32* @fopen(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %40
35: ; preds = %28
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 4
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %38)
store i32 -2, i32* %3
br label %51
40: ; preds = %28
%41 = load i32*, i32** %6
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @atoi(i8* %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = load i32*, i32** %7
%50 = call i32 @voicefont(i32* %41, i32 %45, i8* %48, i32* %49, i32 400)
store i32 0, i32* %3
br label %51
51: ; preds = %40, %35, %23, %10
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [32 x i8] c"Error opening language file %s\0A\00"
@.str.7 = [3 x i8] c"wb\00"
@.str.8 = [30 x i8] c"Error opening output file %s\0A\00"
@str = [58 x i8] c"Makes a Rockbox voicefont from a collection of mp3 clips.\00"
@str.9 = [76 x i8] c"Usage: voicefont <string id list file> <target id> <mp3 path> <output file>\00"
@str.10 = [10 x i8] c"Example: \00"
@str.11 = [50 x i8] c"voicefont voicefontids.txt 2 voice\\ voicefont.bin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @str.9, i64 0, i64 0))
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.10, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.11, i64 0, i64 0))
br label %33
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %11
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* %16)
br label %33
18: ; preds = %10
%19 = getelementptr inbounds i8*, i8** %1, i64 4
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %19
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i8* %24)
br label %33
26: ; preds = %18
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32 @atoi(i8* %28)
%30 = getelementptr inbounds i8*, i8** %1, i64 3
%31 = load i8*, i8** %30
%32 = tail call i32 @voicefont(i32* %13, i32 %29, i8* %31, i32* %21, i32 400)
br label %33
33: ; preds = %26, %23, %15, %4
%34 = phi i32 [ -1, %4 ], [ -2, %15 ], [ -2, %23 ], [ 0, %26 ]
ret i32 %34
}