#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 */

/* Variables and functions */
int atof(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ playWav(char *, int);
int /*<<< orphan*/ setupDMA(double);
int /*<<< orphan*/ setup_fm();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc > 1) {
    setup_fm();
    setupDMA(argc > 2 ? atof(argv[2]) : 103.3);
    playWav(argv[1], argc > 3 ? atof(argv[3]) : 22500);
  } else
    fprintf(stderr,
            "Usage:   program wavfile.wav [freq] [sample rate]\n\nWhere "
            "wavfile is 16 bit 22.5kHz Mono.  Set wavfile to '-' to use "
            "stdin.\nfreq is in Mhz (default 103.3)\nsample rate of wav file "
            "in Hz\n\nPlay an empty file to transmit silence\n");
  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   $0x1,-0x8(%rbp)
jle    1201 <main+0xb1>
mov    $0x0,%al
call   1030 <setup_fm@plt>
cmpl   $0x2,-0x8(%rbp)
jle    119c <main+0x4c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ae <main+0x5e>
movsd  0xe5c(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ae <main+0x5e>
movsd  -0x18(%rbp),%xmm0
call   1070 <setupDMA@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x3,-0x8(%rbp)
jle    11e3 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
mov    %eax,-0x24(%rbp)
jmp    11f0 <main+0xa0>
mov    $0x57e4,%eax
mov    %eax,-0x24(%rbp)
jmp    11f0 <main+0xa0>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1060 <playWav@plt>
jmp    1216 <main+0xc6>
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x2,%edi
jl     1182 <main+0x32>
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <setup_fm@plt>
cmp    $0x2,%ebp
jne    1199 <main+0x49>
movsd  0xe8e(%rip),%xmm0
call   1070 <setupDMA@plt>
mov    0x8(%rbx),%r14
mov    $0x57e4,%esi
jmp    11c4 <main+0x74>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11cc <main+0x7c>
mov    0x10(%rbx),%rdi
call   1040 <atof@plt>
cvtsi2sd %eax,%xmm0
call   1070 <setupDMA@plt>
mov    0x8(%rbx),%r14
mov    $0x57e4,%esi
cmp    $0x4,%ebp
jb     11c4 <main+0x74>
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
mov    %eax,%esi
mov    %r14,%rdi
call   1060 <playWav@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [225 x i8] c"Usage: program wavfile.wav [freq] [sample rate]\0A\0AWhere wavfile is 16 bit 22.5kHz Mono. Set wavfile to '-' to use stdin.\0Afreq is in Mhz (default 103.3)\0Asample rate of wav file in Hz\0A\0APlay an empty file to transmit silence\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %36
8: ; preds = %2
%9 = call i32 (...) @setup_fm()
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i32 @atof(i8* %15)
%17 = sitofp i32 %16 to double
br label %19
18: ; preds = %8
br label %19
19: ; preds = %18, %12
%20 = phi double [ %17, %12 ], [ 1.033000e+02, %18 ]
%21 = call i32 @setupDMA(double %20)
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 3
br i1 %26, label %27, label %32
27: ; preds = %19
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i32 @atof(i8* %30)
br label %33
32: ; preds = %19
br label %33
33: ; preds = %32, %27
%34 = phi i32 [ %31, %27 ], [ 22500, %32 ]
%35 = call i32 @playWav(i8* %24, i32 %34)
br label %39
36: ; preds = %2
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([225 x i8], [225 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %36, %33
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [225 x i8] c"Usage: program wavfile.wav [freq] [sample rate]\0A\0AWhere wavfile is 16 bit 22.5kHz Mono. Set wavfile to '-' to use stdin.\0Afreq is in Mhz (default 103.3)\0Asample rate of wav file in Hz\0A\0APlay an empty file to transmit silence\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %28
4: ; preds = %2
%5 = tail call i32 (...) @setup_fm()
%6 = icmp eq i32 %0, 2
br i1 %6, label %7, label %11
7: ; preds = %4
%8 = tail call i32 @setupDMA(double 1.033000e+02)
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
br label %24
11: ; preds = %4
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atof(i8* %13)
%15 = sitofp i32 %14 to double
%16 = tail call i32 @setupDMA(double %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = icmp ugt i32 %0, 3
br i1 %19, label %20, label %24
20: ; preds = %11
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call i32 @atof(i8* %22)
br label %24
24: ; preds = %7, %11, %20
%25 = phi i8* [ %18, %20 ], [ %18, %11 ], [ %10, %7 ]
%26 = phi i32 [ %23, %20 ], [ 22500, %11 ], [ 22500, %7 ]
%27 = tail call i32 @playWav(i8* %25, i32 %26)
br label %31
28: ; preds = %2
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([225 x i8], [225 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %28, %24
ret i32 0
}