#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 /*<<< orphan*/ close_files();
short do_aec(short, short);
int /*<<< orphan*/ open_files();
int /*<<< orphan*/ process_args(int, char **);
int read_input();
int /*<<< orphan*/ read_samples(short *, short *);
int /*<<< orphan*/ write_samples(short, short, short);
int main(int argc, char *argv[]) {
  int count;
  process_args(argc, argv);
  open_files();
  while (0 <= (count = read_input())) {
    short mic, spk, tmp;
    read_samples(&mic, &spk);
    tmp = do_aec(mic, spk);
    write_samples(mic, spk, tmp);
  }
  close_files();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <process_args@plt>
mov    $0x0,%al
call   1030 <open_files@plt>
mov    $0x0,%al
call   1090 <read_input@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
xor    %eax,%eax
cmp    %ecx,%eax
jg     11ec <main+0x7c>
lea    -0x16(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <read_samples@plt>
mov    -0x16(%rbp),%ax
movswl %ax,%edi
movswl -0x18(%rbp),%esi
call   1050 <do_aec@plt>
mov    %ax,-0x1a(%rbp)
mov    -0x16(%rbp),%cx
mov    -0x18(%rbp),%ax
movswl %cx,%edi
movswl %ax,%esi
movswl -0x1a(%rbp),%edx
call   1060 <write_samples@plt>
jmp    1199 <main+0x29>
mov    $0x0,%al
call   1070 <close_files@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
call   1080 <process_args@plt>
xor    %eax,%eax
call   1030 <open_files@plt>
xor    %eax,%eax
call   1090 <read_input@plt>
test   %eax,%eax
js     11d7 <main+0x67>
lea    0x6(%rsp),%r14
lea    0x4(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <read_samples@plt>
movswl 0x6(%rsp),%edi
movswl 0x4(%rsp),%esi
call   1050 <do_aec@plt>
movswl 0x6(%rsp),%edi
movswl 0x4(%rsp),%esi
movswl %ax,%edx
call   1060 <write_samples@plt>
xor    %eax,%eax
call   1090 <read_input@plt>
test   %eax,%eax
jns    11a0 <main+0x30>
xor    %eax,%eax
call   1070 <close_files@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i16
%8 = alloca i16
%9 = alloca i16
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @process_args(i32 %10, i8** %11)
%13 = call i32 (...) @open_files()
br label %14
14: ; preds = %17, %2
%15 = call i32 (...) @read_input()
store i32 %15, i32* %6
%16 = icmp sle i32 0, %15
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = call i32 @read_samples(i16* %7, i16* %8)
%19 = load i16, i16* %7
%20 = load i16, i16* %8
%21 = call signext i16 @do_aec(i16 signext %19, i16 signext %20)
store i16 %21, i16* %9
%22 = load i16, i16* %7
%23 = load i16, i16* %8
%24 = load i16, i16* %9
%25 = call i32 @write_samples(i16 signext %22, i16 signext %23, i16 signext %24)
br label %14
26: ; preds = %14
%27 = call i32 (...) @close_files()
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i16
%4 = alloca i16
%5 = tail call i32 @process_args(i32 %0, i8** %1)
%6 = tail call i32 (...) @open_files()
%7 = call i32 (...) @read_input()
%8 = icmp sgt i32 %7, -1
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = bitcast i16* %3 to i8*
%11 = bitcast i16* %4 to i8*
br label %12
12: ; preds = %9, %12
%13 = call i32 @read_samples(i16* %3, i16* %4)
%14 = load i16, i16* %3
%15 = load i16, i16* %4
%16 = call signext i16 @do_aec(i16 signext %14, i16 signext %15)
%17 = load i16, i16* %3
%18 = load i16, i16* %4
%19 = call i32 @write_samples(i16 signext %17, i16 signext %18, i16 signext %16)
%20 = call i32 (...) @read_input()
%21 = icmp sgt i32 %20, -1
br i1 %21, label %12, label %22
22: ; preds = %12, %2
%23 = call i32 (...) @close_files()
ret i32 0
}