#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strtod(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ write_tone(int /*<<< orphan*/ *, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/, int /*<<< orphan*/,
                              unsigned char);
int /*<<< orphan*/ write_wav(int /*<<< orphan*/ *, char *, unsigned char);
int main(int argc, char *argv[]) {
  FILE *fp;
  if (argc <= 1) {
  usage:
    printf("Usage:\n");
    printf("%s wave2alaw <wav file> <alaw file>\n", argv[0]);
    printf("%s wave2ulaw <wav file> <ulaw file>\n", argv[0]);
    printf("%s tone2alaw <frq1> <frq2> <length> <fade in> <fade out> <alaw "
           "file>\n",
           argv[0]);
    printf("%s tone2ulaw <frq1> <frq2> <length> <fade in> <fade out> <ulaw "
           "file>\n",
           argv[0]);
    printf("Length and fade lengths must be given in samples (8000 samples are "
           "one second).\n");
    printf("Tones will append to existing files, wav files don't.\n");
    printf("Frequencies may be given as floating point values.\n");
    return (0);
  }
  if (!strcmp(argv[1], "wave2alaw")) {
    if (argc <= 3)
      goto usage;
    if ((fp = fopen(argv[3], "w"))) {
      write_wav(fp, argv[2], 'a');
      fclose(fp);
    } else {
      printf("Cannot open isdn file %s\n", argv[3]);
    }
  } else if (!strcmp(argv[1], "wave2ulaw")) {
    if (argc <= 3)
      goto usage;
    if ((fp = fopen(argv[3], "w"))) {
      write_wav(fp, argv[2], 'u');
      fclose(fp);
    } else {
      printf("Cannot open isdn file %s\n", argv[3]);
    }
  } else if (!strcmp(argv[1], "tone2alaw")) {
    if (argc <= 7)
      goto usage;
    if ((fp = fopen(argv[7], "a"))) {
      write_tone(fp, strtod(argv[2], NULL), strtod(argv[3], NULL),
                 atoi(argv[4]), atoi(argv[5]), atoi(argv[6]), 'a');
      fclose(fp);
    } else {
      printf("Cannot open isdn file %s\n", argv[7]);
    }
  } else if (!strcmp(argv[1], "tone2ulaw")) {
    if (argc <= 7)
      goto usage;
    if ((fp = fopen(argv[7], "a"))) {
      write_tone(fp, atoi(argv[2]), atoi(argv[3]), atoi(argv[4]), atoi(argv[5]),
                 atoi(argv[6]), 'u');
      fclose(fp);
    } else {
      printf("Cannot open isdn file %s\n", argv[7]);
    }
  } else
    goto usage;
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jg     123d <main+0xbd>
jmp    11a5 <main+0x25>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xf3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1552 <main+0x3d2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf4e(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    12ca <main+0x14a>
cmpl   $0x3,-0x8(%rbp)
jg     1269 <main+0xe9>
jmp    11a5 <main+0x25>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xf58(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12af <main+0x12f>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x61,%edx
call   1080 <write_wav@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
jmp    12c5 <main+0x145>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xee6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    154b <main+0x3cb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xee5(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1357 <main+0x1d7>
cmpl   $0x3,-0x8(%rbp)
jg     12f6 <main+0x176>
jmp    11a5 <main+0x25>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xecb(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     133c <main+0x1bc>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x75,%edx
call   1080 <write_wav@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1352 <main+0x1d2>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1546 <main+0x3c6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe62(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    144b <main+0x2cb>
cmpl   $0x7,-0x8(%rbp)
jg     1383 <main+0x203>
jmp    11a5 <main+0x25>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1430 <main+0x2b0>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <strtod@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   10a0 <atoi@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
mov    %eax,%r9d
movl   $0x61,(%rsp)
call   1040 <write_tone@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1446 <main+0x2c6>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rsi
lea    0xd65(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1541 <main+0x3c1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd7a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1537 <main+0x3b7>
cmpl   $0x7,-0x8(%rbp)
jg     1477 <main+0x2f7>
jmp    11a5 <main+0x25>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
lea    0xd4c(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     151c <main+0x39c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   10a0 <atoi@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x34(%rbp),%r8d
mov    %eax,%r9d
movl   $0x75,(%rsp)
call   1040 <write_tone@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1532 <main+0x3b2>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rsi
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    153c <main+0x3bc>
jmp    11a5 <main+0x25>
jmp    1541 <main+0x3c1>
jmp    1546 <main+0x3c6>
jmp    154b <main+0x3cb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
cmp    $0x1,%edi
jg     122c <main+0x9c>
lea    0xf6c(%rip),%rdi
call   1030 <puts@plt>
mov    (%r15),%rsi
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%rsi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%rsi
lea    0xe6b(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%rsi
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xf23(%rip),%rdi
call   1030 <puts@plt>
lea    0xf67(%rip),%rdi
call   1030 <puts@plt>
lea    0xf91(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%ebp
mov    0x8(%r15),%rbx
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1316 <main+0x186>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1349 <main+0x1b9>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     138c <main+0x1fc>
lea    0xe92(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
cmp    $0x8,%ebp
jb     11a7 <main+0x17>
test   %eax,%eax
jne    11a7 <main+0x17>
mov    0x38(%r15),%rdi
lea    0xe6c(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1418 <main+0x288>
mov    %rax,%rbp
mov    0x10(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r14d
mov    0x18(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r12d
mov    0x20(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%r13d
mov    0x28(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
mov    0x30(%r15),%rdi
call   10b0 <atoi@plt>
movl   $0x75,(%rsp)
mov    %rbp,%rdi
mov    %r14d,%esi
mov    %r12d,%edx
mov    %r13d,%ecx
mov    %ebx,%r8d
mov    %eax,%r9d
call   1050 <write_tone@plt>
mov    %rbp,%rdi
call   1060 <fclose@plt>
jmp    121b <main+0x8b>
cmp    $0x4,%ebp
jb     11a7 <main+0x17>
mov    0x18(%r15),%rdi
lea    0xde2(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1412 <main+0x282>
mov    %rax,%rbx
mov    0x10(%r15),%rsi
mov    %rax,%rdi
mov    $0x61,%edx
jmp    137a <main+0x1ea>
cmp    $0x4,%ebp
jb     11a7 <main+0x17>
mov    0x18(%r15),%rdi
lea    0xdaf(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1412 <main+0x282>
mov    %rax,%rbx
mov    0x10(%r15),%rsi
mov    %rax,%rdi
mov    $0x75,%edx
call   1090 <write_wav@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
jmp    121b <main+0x8b>
cmp    $0x8,%ebp
jb     11a7 <main+0x17>
mov    0x38(%r15),%rdi
lea    0xd6e(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1418 <main+0x288>
mov    %rax,%r14
mov    0x10(%r15),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
mov    %eax,%r12d
mov    0x18(%r15),%rdi
xor    %esi,%esi
call   1040 <strtod@plt>
mov    %eax,%r13d
mov    0x20(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebx
mov    0x28(%r15),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
mov    0x30(%r15),%rdi
call   10b0 <atoi@plt>
movl   $0x61,(%rsp)
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1050 <write_tone@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
jmp    121b <main+0x8b>
mov    0x18(%r15),%rsi
jmp    141c <main+0x28c>
mov    0x38(%r15),%rsi
lea    0xcbd(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    121b <main+0x8b>

LLVM IR (-O0):
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [37 x i8] c"%s wave2alaw <wav file> <alaw file>\0A\00"
@.str.2 = [37 x i8] c"%s wave2ulaw <wav file> <ulaw file>\0A\00"
@.str.3 = [70 x i8] c"%s tone2alaw <frq1> <frq2> <length> <fade in> <fade out> <alaw file>\0A\00"
@.str.4 = [70 x i8] c"%s tone2ulaw <frq1> <frq2> <length> <fade in> <fade out> <ulaw file>\0A\00"
@.str.5 = [81 x i8] c"Length and fade lengths must be given in samples (8000 samples are one second).\0A\00"
@.str.6 = [55 x i8] c"Tones will append to existing files, wav files don't.\0A\00"
@.str.7 = [52 x i8] c"Frequencies may be given as floating point values.\0A\00"
@.str.8 = [10 x i8] c"wave2alaw\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [26 x i8] c"Cannot open isdn file %s\0A\00"
@.str.11 = [10 x i8] c"wave2ulaw\00"
@.str.12 = [10 x i8] c"tone2alaw\00"
@.str.13 = [2 x i8] c"a\00"
@.str.14 = [10 x i8] c"tone2ulaw\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 1
br i1 %8, label %9, label %31
9: ; preds = %2
br label %10
10: ; preds = %185, %147, %100, %70, %40, %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %190
31: ; preds = %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %61, label %37
37: ; preds = %31
%38 = load i32, i32* %4
%39 = icmp sle i32 %38, 3
br i1 %39, label %40, label %41
40: ; preds = %37
br label %10
41: ; preds = %37
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %45, i32** %6
%46 = icmp ne i32* %45, null
br i1 %46, label %47, label %55
47: ; preds = %41
%48 = load i32*, i32** %6
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32 @write_wav(i32* %48, i8* %51, i8 zeroext 97)
%53 = load i32*, i32** %6
%54 = call i32 @fclose(i32* %53)
br label %60
55: ; preds = %41
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 3
%58 = load i8*, i8** %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %55, %47
br label %189
61: ; preds = %31
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @strcmp(i8* %64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%66 = icmp ne i32 %65, 0
br i1 %66, label %91, label %67
67: ; preds = %61
%68 = load i32, i32* %4
%69 = icmp sle i32 %68, 3
br i1 %69, label %70, label %71
70: ; preds = %67
br label %10
71: ; preds = %67
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 3
%74 = load i8*, i8** %73
%75 = call i32* @fopen(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %75, i32** %6
%76 = icmp ne i32* %75, null
br i1 %76, label %77, label %85
77: ; preds = %71
%78 = load i32*, i32** %6
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 2
%81 = load i8*, i8** %80
%82 = call i32 @write_wav(i32* %78, i8* %81, i8 zeroext 117)
%83 = load i32*, i32** %6
%84 = call i32 @fclose(i32* %83)
br label %90
85: ; preds = %71
%86 = load i8**, i8*** %5
%87 = getelementptr inbounds i8*, i8** %86, i64 3
%88 = load i8*, i8** %87
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %85, %77
br label %188
91: ; preds = %61
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 1
%94 = load i8*, i8** %93
%95 = call i32 @strcmp(i8* %94, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0))
%96 = icmp ne i32 %95, 0
br i1 %96, label %138, label %97
97: ; preds = %91
%98 = load i32, i32* %4
%99 = icmp sle i32 %98, 7
br i1 %99, label %100, label %101
100: ; preds = %97
br label %10
101: ; preds = %97
%102 = load i8**, i8*** %5
%103 = getelementptr inbounds i8*, i8** %102, i64 7
%104 = load i8*, i8** %103
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32* %105, i32** %6
%106 = icmp ne i32* %105, null
br i1 %106, label %107, label %132
107: ; preds = %101
%108 = load i32*, i32** %6
%109 = load i8**, i8*** %5
%110 = getelementptr inbounds i8*, i8** %109, i64 2
%111 = load i8*, i8** %110
%112 = call i32 @strtod(i8* %111, i32* null)
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 3
%115 = load i8*, i8** %114
%116 = call i32 @strtod(i8* %115, i32* null)
%117 = load i8**, i8*** %5
%118 = getelementptr inbounds i8*, i8** %117, i64 4
%119 = load i8*, i8** %118
%120 = call i32 @atoi(i8* %119)
%121 = load i8**, i8*** %5
%122 = getelementptr inbounds i8*, i8** %121, i64 5
%123 = load i8*, i8** %122
%124 = call i32 @atoi(i8* %123)
%125 = load i8**, i8*** %5
%126 = getelementptr inbounds i8*, i8** %125, i64 6
%127 = load i8*, i8** %126
%128 = call i32 @atoi(i8* %127)
%129 = call i32 @write_tone(i32* %108, i32 %112, i32 %116, i32 %120, i32 %124, i32 %128, i8 zeroext 97)
%130 = load i32*, i32** %6
%131 = call i32 @fclose(i32* %130)
br label %137
132: ; preds = %101
%133 = load i8**, i8*** %5
%134 = getelementptr inbounds i8*, i8** %133, i64 7
%135 = load i8*, i8** %134
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %135)
br label %137
137: ; preds = %132, %107
br label %187
138: ; preds = %91
%139 = load i8**, i8*** %5
%140 = getelementptr inbounds i8*, i8** %139, i64 1
%141 = load i8*, i8** %140
%142 = call i32 @strcmp(i8* %141, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%143 = icmp ne i32 %142, 0
br i1 %143, label %185, label %144
144: ; preds = %138
%145 = load i32, i32* %4
%146 = icmp sle i32 %145, 7
br i1 %146, label %147, label %148
147: ; preds = %144
br label %10
148: ; preds = %144
%149 = load i8**, i8*** %5
%150 = getelementptr inbounds i8*, i8** %149, i64 7
%151 = load i8*, i8** %150
%152 = call i32* @fopen(i8* %151, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
store i32* %152, i32** %6
%153 = icmp ne i32* %152, null
br i1 %153, label %154, label %179
154: ; preds = %148
%155 = load i32*, i32** %6
%156 = load i8**, i8*** %5
%157 = getelementptr inbounds i8*, i8** %156, i64 2
%158 = load i8*, i8** %157
%159 = call i32 @atoi(i8* %158)
%160 = load i8**, i8*** %5
%161 = getelementptr inbounds i8*, i8** %160, i64 3
%162 = load i8*, i8** %161
%163 = call i32 @atoi(i8* %162)
%164 = load i8**, i8*** %5
%165 = getelementptr inbounds i8*, i8** %164, i64 4
%166 = load i8*, i8** %165
%167 = call i32 @atoi(i8* %166)
%168 = load i8**, i8*** %5
%169 = getelementptr inbounds i8*, i8** %168, i64 5
%170 = load i8*, i8** %169
%171 = call i32 @atoi(i8* %170)
%172 = load i8**, i8*** %5
%173 = getelementptr inbounds i8*, i8** %172, i64 6
%174 = load i8*, i8** %173
%175 = call i32 @atoi(i8* %174)
%176 = call i32 @write_tone(i32* %155, i32 %159, i32 %163, i32 %167, i32 %171, i32 %175, i8 zeroext 117)
%177 = load i32*, i32** %6
%178 = call i32 @fclose(i32* %177)
br label %184
179: ; preds = %148
%180 = load i8**, i8*** %5
%181 = getelementptr inbounds i8*, i8** %180, i64 7
%182 = load i8*, i8** %181
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %182)
br label %184
184: ; preds = %179, %154
br label %186
185: ; preds = %138
br label %10
186: ; preds = %184
br label %187
187: ; preds = %186, %137
br label %188
188: ; preds = %187, %90
br label %189
189: ; preds = %188, %60
store i32 0, i32* %3
br label %190
190: ; preds = %189, %10
%191 = load i32, i32* %3
ret i32 %191
}

LLVM IR (-O2):
@.str.1 = [37 x i8] c"%s wave2alaw <wav file> <alaw file>\0A\00"
@.str.2 = [37 x i8] c"%s wave2ulaw <wav file> <ulaw file>\0A\00"
@.str.3 = [70 x i8] c"%s tone2alaw <frq1> <frq2> <length> <fade in> <fade out> <alaw file>\0A\00"
@.str.4 = [70 x i8] c"%s tone2ulaw <frq1> <frq2> <length> <fade in> <fade out> <ulaw file>\0A\00"
@.str.8 = [10 x i8] c"wave2alaw\00"
@.str.9 = [2 x i8] c"w\00"
@.str.10 = [26 x i8] c"Cannot open isdn file %s\0A\00"
@.str.11 = [10 x i8] c"wave2ulaw\00"
@.str.12 = [10 x i8] c"tone2alaw\00"
@.str.13 = [2 x i8] c"a\00"
@.str.14 = [10 x i8] c"tone2ulaw\00"
@str = [7 x i8] c"Usage:\00"
@str.15 = [80 x i8] c"Length and fade lengths must be given in samples (8000 samples are one second).\00"
@str.16 = [54 x i8] c"Tones will append to existing files, wav files don't.\00"
@str.17 = [51 x i8] c"Frequencies may be given as floating point values.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %17
4: ; preds = %86, %58, %40, %22, %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.3, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0), i8* %12)
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.15, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.16, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.17, i64 0, i64 0))
br label %117
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = icmp ult i32 %0, 4
br i1 %23, label %4, label %24
24: ; preds = %22
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %34, label %29
29: ; preds = %24
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = tail call i32 @write_wav(i32* %27, i8* %31, i8 zeroext 97)
%33 = tail call i32 @fclose(i32* %27)
br label %117
34: ; preds = %24
%35 = load i8*, i8** %25
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %35)
br label %117
37: ; preds = %17
%38 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %55
40: ; preds = %37
%41 = icmp ult i32 %0, 4
br i1 %41, label %4, label %42
42: ; preds = %40
%43 = getelementptr inbounds i8*, i8** %1, i64 3
%44 = load i8*, i8** %43
%45 = tail call i32* @fopen(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %52, label %47
47: ; preds = %42
%48 = getelementptr inbounds i8*, i8** %1, i64 2
%49 = load i8*, i8** %48
%50 = tail call i32 @write_wav(i32* %45, i8* %49, i8 zeroext 117)
%51 = tail call i32 @fclose(i32* %45)
br label %117
52: ; preds = %42
%53 = load i8*, i8** %43
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %53)
br label %117
55: ; preds = %37
%56 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.12, i64 0, i64 0))
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %86
58: ; preds = %55
%59 = icmp ult i32 %0, 8
br i1 %59, label %4, label %60
60: ; preds = %58
%61 = getelementptr inbounds i8*, i8** %1, i64 7
%62 = load i8*, i8** %61
%63 = tail call i32* @fopen(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%64 = icmp eq i32* %63, null
br i1 %64, label %83, label %65
65: ; preds = %60
%66 = getelementptr inbounds i8*, i8** %1, i64 2
%67 = load i8*, i8** %66
%68 = tail call i32 @strtod(i8* nocapture %67, i32* null)
%69 = getelementptr inbounds i8*, i8** %1, i64 3
%70 = load i8*, i8** %69
%71 = tail call i32 @strtod(i8* nocapture %70, i32* null)
%72 = getelementptr inbounds i8*, i8** %1, i64 4
%73 = load i8*, i8** %72
%74 = tail call i32 @atoi(i8* %73)
%75 = getelementptr inbounds i8*, i8** %1, i64 5
%76 = load i8*, i8** %75
%77 = tail call i32 @atoi(i8* %76)
%78 = getelementptr inbounds i8*, i8** %1, i64 6
%79 = load i8*, i8** %78
%80 = tail call i32 @atoi(i8* %79)
%81 = tail call i32 @write_tone(i32* %63, i32 %68, i32 %71, i32 %74, i32 %77, i32 %80, i8 zeroext 97)
%82 = tail call i32 @fclose(i32* %63)
br label %117
83: ; preds = %60
%84 = load i8*, i8** %61
%85 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %84)
br label %117
86: ; preds = %55
%87 = tail call i32 @strcmp(i8* dereferenceable(1) %19, i8* dereferenceable(10) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0))
%88 = icmp ne i32 %87, 0
%89 = icmp ult i32 %0, 8
%90 = or i1 %89, %88
br i1 %90, label %4, label %91
91: ; preds = %86
%92 = getelementptr inbounds i8*, i8** %1, i64 7
%93 = load i8*, i8** %92
%94 = tail call i32* @fopen(i8* %93, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%95 = icmp eq i32* %94, null
br i1 %95, label %114, label %96
96: ; preds = %91
%97 = getelementptr inbounds i8*, i8** %1, i64 2
%98 = load i8*, i8** %97
%99 = tail call i32 @atoi(i8* %98)
%100 = getelementptr inbounds i8*, i8** %1, i64 3
%101 = load i8*, i8** %100
%102 = tail call i32 @atoi(i8* %101)
%103 = getelementptr inbounds i8*, i8** %1, i64 4
%104 = load i8*, i8** %103
%105 = tail call i32 @atoi(i8* %104)
%106 = getelementptr inbounds i8*, i8** %1, i64 5
%107 = load i8*, i8** %106
%108 = tail call i32 @atoi(i8* %107)
%109 = getelementptr inbounds i8*, i8** %1, i64 6
%110 = load i8*, i8** %109
%111 = tail call i32 @atoi(i8* %110)
%112 = tail call i32 @write_tone(i32* %94, i32 %99, i32 %102, i32 %105, i32 %108, i32 %111, i8 zeroext 117)
%113 = tail call i32 @fclose(i32* %94)
br label %117
114: ; preds = %91
%115 = load i8*, i8** %92
%116 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %115)
br label %117
117: ; preds = %34, %29, %83, %65, %96, %114, %47, %52, %4
ret i32 0
}