#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int wavtrim(char *, int, char *, int);
int main(int argc, char **argv) {
  int max_silence = 0;
  char errbuffer[255];
  int ret = 0;
  if (argc < 2) {
    printf("wavtrim removes silence at the begin and end of a WAV file.\n");
    printf("usage: wavtrim <filename.wav> [<max_silence>]\n");
    return 0;
  }
  if (argc == 3) {
    max_silence = atoi(argv[2]);
  }
  ret = wavtrim(argv[1], max_silence, errbuffer, 255);
  if (ret < 0) {
    printf("%s", errbuffer);
  }
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x124(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118c <main+0x5c>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f3 <main+0xc3>
cmpl   $0x3,-0x8(%rbp)
jne    11a6 <main+0x76>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x14(%rbp),%esi
lea    -0x120(%rbp),%rdx
mov    $0xff,%ecx
call   1040 <wavtrim@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
jge    11ea <main+0xba>
lea    -0x120(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x124(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
cmp    $0x1,%edi
jg     1169 <main+0x29>
lea    0xeaf(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    11a6 <main+0x66>
mov    %rsi,%rbx
xor    %esi,%esi
cmp    $0x3,%edi
jne    117e <main+0x3e>
mov    0x10(%rbx),%rdi
call   1060 <atoi@plt>
mov    %eax,%esi
mov    0x8(%rbx),%rdi
mov    %rsp,%rdx
mov    $0xff,%ecx
call   1050 <wavtrim@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11a6 <main+0x66>
lea    0xe64(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x100,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [61 x i8] c"wavtrim removes silence at the begin and end of a WAV file.\0A\00"
@.str.1 = [47 x i8] c"usage: wavtrim <filename.wav> [<max_silence>]\0A\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [255 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %36
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %6
br label %22
22: ; preds = %17, %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* %6
%27 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%28 = call i32 @wavtrim(i8* %25, i32 %26, i8* %27, i32 255)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = getelementptr inbounds [255 x i8], [255 x i8]* %7, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %22
%35 = load i32, i32* %8
store i32 %35, i32* %3
br label %36
36: ; preds = %34, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str.2 = [3 x i8] c"%s\00"
@str = [60 x i8] c"wavtrim removes silence at the begin and end of a WAV file.\00"
@str.3 = [46 x i8] c"usage: wavtrim <filename.wav> [<max_silence>]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.3, i64 0, i64 0))
br label %23
9: ; preds = %2
%10 = icmp eq i32 %0, 3
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
br label %15
15: ; preds = %11, %9
%16 = phi i32 [ %14, %11 ], [ 0, %9 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @wavtrim(i8* %18, i32 %16, i8* %4, i32 255)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %23
23: ; preds = %15, %21, %6
%24 = phi i32 [ 0, %6 ], [ %19, %21 ], [ %19, %15 ]
ret i32 %24
}