#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 AFMT_S16_LE;
int AFMT_U8;
int O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SNDCTL_DSP_SETFMT;
int /*<<< orphan*/ SNDCTL_DSP_SPEED;
int /*<<< orphan*/ SNDCTL_DSP_STEREO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ftruncate(int, int /*<<< orphan*/);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int *);
int /*<<< orphan*/ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ strcpy(unsigned char *, char *);
int /*<<< orphan*/ write(int, unsigned char *, int);
int RecWavDesc(char *sFilename, int hAudio, unsigned dSeconds,
               unsigned short dChannels, unsigned ldSamplesPerSec,
               unsigned short dBitsPerSample, unsigned dOptions) {
  int hFilename = 0;
  int dRequest;
  unsigned char cBuffer[8192];
  unsigned dBytesPerSec, dBytesPerSample = 0;
  unsigned dBufferWrites;
  unsigned dTotalSampleBytes;
  unsigned dTotalWavSize;
  unsigned i;
  unsigned short dFormatTag = 0x0001;
  unsigned short dBlockAlign;
  if (dFormatTag != 0x0001) {
    return -1;
  }
  switch (dBitsPerSample) {
  case 8:
    dRequest = AFMT_U8;
    ioctl(hAudio, SNDCTL_DSP_SETFMT, &dRequest);
    if (dRequest != AFMT_U8) {
      close(hFilename);
      return -1;
    }
    break;
  case 16:
    dRequest = AFMT_S16_LE;
    ioctl(hAudio, SNDCTL_DSP_SETFMT, &dRequest);
    if (dRequest != AFMT_S16_LE) {
      close(hFilename);
      return -1;
    }
    break;
  default:
    close(hFilename);
    return -1;
    break;
  }
  if (dChannels > 0 && dChannels < 3) {
    dRequest = dChannels - 1;
    ioctl(hAudio, SNDCTL_DSP_STEREO, &dRequest);
    if (dRequest != dChannels - 1) {
      close(hFilename);
      return -1;
    }
  } else {
    close(hFilename);
    return -1;
  }
  dRequest = (int)ldSamplesPerSec;
  ioctl(hAudio, SNDCTL_DSP_SPEED, &dRequest);
  if ((dOptions & 0x40000000) != 0) {
    return 0;
  }
  if (dBitsPerSample <= 8) {
    dBytesPerSample = 1;
  }
  if (dBitsPerSample > 8 && dBitsPerSample <= 16) {
    dBytesPerSample = 2;
  }
  if (dBitsPerSample > 16) {
    dBytesPerSample = 3;
  }
  dBlockAlign = dBytesPerSample * dChannels;
  dBytesPerSec = ldSamplesPerSec * dBytesPerSample * dChannels;
  dTotalSampleBytes = dBytesPerSec * dSeconds;
  dBufferWrites = dTotalSampleBytes / 8192 + 1;
  dTotalSampleBytes = dBufferWrites * 8192;
  dTotalWavSize = dTotalSampleBytes + 36;
  hFilename = open(sFilename, O_WRONLY | O_CREAT, 0644);
  if (hFilename < 0) {
    perror("open");
    return -1;
  }
  strcpy(cBuffer, "RIFF");
  write(hFilename, cBuffer, 4);
  cBuffer[0] = dTotalWavSize & 0x000000FF;
  cBuffer[1] = (dTotalWavSize & 0x0000FF00) >> 8;
  cBuffer[2] = (dTotalWavSize & 0x00FF0000) >> 16;
  cBuffer[3] = (dTotalWavSize & 0xFF000000) >> 24;
  write(hFilename, cBuffer, 4);
  strcpy(cBuffer, "WAVE");
  write(hFilename, cBuffer, 4);
  strcpy(cBuffer, "fmt ");
  write(hFilename, cBuffer, 4);
  cBuffer[0] = 0x10;
  cBuffer[1] = 0;
  cBuffer[2] = 0;
  cBuffer[3] = 0;
  write(hFilename, cBuffer, 4);
  cBuffer[0] = dFormatTag & 0x00FF;
  cBuffer[1] = (dFormatTag & 0xFF00) >> 8;
  write(hFilename, cBuffer, 2);
  cBuffer[0] = dChannels & 0x00FF;
  cBuffer[1] = (dChannels & 0xFF00) >> 8;
  write(hFilename, cBuffer, 2);
  cBuffer[0] = ldSamplesPerSec & 0x000000FF;
  cBuffer[1] = (ldSamplesPerSec & 0x0000FF00) >> 8;
  cBuffer[2] = (ldSamplesPerSec & 0x00FF0000) >> 16;
  cBuffer[3] = (ldSamplesPerSec & 0xFF000000) >> 24;
  write(hFilename, cBuffer, 4);
  cBuffer[0] = dBytesPerSec & 0x000000FF;
  cBuffer[1] = (dBytesPerSec & 0x0000FF00) >> 8;
  cBuffer[2] = (dBytesPerSec & 0x00FF0000) >> 16;
  cBuffer[3] = (dBytesPerSec & 0xFF000000) >> 24;
  write(hFilename, cBuffer, 4);
  cBuffer[0] = dBlockAlign & 0x00FF;
  cBuffer[1] = (dBlockAlign & 0xFF00) >> 8;
  write(hFilename, cBuffer, 2);
  cBuffer[0] = dBitsPerSample & 0x00FF;
  cBuffer[1] = (dBitsPerSample & 0xFF00) >> 8;
  write(hFilename, cBuffer, 2);
  strcpy(cBuffer, "data");
  write(hFilename, cBuffer, 4);
  cBuffer[0] = dTotalSampleBytes & 0x000000FF;
  cBuffer[1] = (dTotalSampleBytes & 0x0000FF00) >> 8;
  cBuffer[2] = (dTotalSampleBytes & 0x00FF0000) >> 16;
  cBuffer[3] = (dTotalSampleBytes & 0xFF000000) >> 24;
  write(hFilename, cBuffer, 4);
  for (i = 0; i < dBufferWrites; i++) {
    read(hAudio, cBuffer, 8192);
    write(hFilename, cBuffer, 8192);
  }
  ftruncate(hFilename, lseek(hFilename, 0, SEEK_CUR));
  close(hFilename);
  return 0;
}


x86 assembly (clang, -O0):
<RecWavDesc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2060,%rsp
mov    %r9w,%ax
mov    0x10(%rbp),%r9d
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %cx,-0x1a(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %ax,-0x22(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2038(%rbp)
movw   $0x1,-0x204a(%rbp)
movzwl -0x204a(%rbp),%eax
cmp    $0x1,%eax
je     11ef <RecWavDesc+0x5f>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
movzwl -0x22(%rbp),%eax
mov    %eax,-0x2050(%rbp)
sub    $0x8,%eax
je     121b <RecWavDesc+0x8b>
jmp    1207 <RecWavDesc+0x77>
mov    -0x2050(%rbp),%eax
sub    $0x10,%eax
je     1267 <RecWavDesc+0xd7>
jmp    12b3 <RecWavDesc+0x123>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
call   1070 <ioctl@plt>
mov    -0x2c(%rbp),%eax
mov    0x2d5a(%rip),%rcx
cmp    (%rcx),%eax
je     1262 <RecWavDesc+0xd2>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
jmp    12c7 <RecWavDesc+0x137>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
call   1070 <ioctl@plt>
mov    -0x2c(%rbp),%eax
mov    0x2d36(%rip),%rcx
cmp    (%rcx),%eax
je     12ae <RecWavDesc+0x11e>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
jmp    12c7 <RecWavDesc+0x137>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
movzwl -0x1a(%rbp),%eax
cmp    $0x0,%eax
jle    132b <RecWavDesc+0x19b>
movzwl -0x1a(%rbp),%eax
cmp    $0x3,%eax
jge    132b <RecWavDesc+0x19b>
movzwl -0x1a(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2ceb(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
call   1070 <ioctl@plt>
mov    -0x2c(%rbp),%eax
movzwl -0x1a(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1326 <RecWavDesc+0x196>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
jmp    133f <RecWavDesc+0x1af>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
mov    -0x20(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2c71(%rip),%rax
mov    (%rax),%esi
lea    -0x2c(%rbp),%rdx
call   1070 <ioctl@plt>
mov    0x10(%rbp),%eax
and    $0x40000000,%eax
cmp    $0x0,%eax
je     1377 <RecWavDesc+0x1e7>
movl   $0x0,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
movzwl -0x22(%rbp),%eax
cmp    $0x8,%eax
jg     138e <RecWavDesc+0x1fe>
movl   $0x1,-0x2038(%rbp)
movzwl -0x22(%rbp),%eax
cmp    $0x8,%eax
jle    13b2 <RecWavDesc+0x222>
movzwl -0x22(%rbp),%eax
cmp    $0x10,%eax
jg     13b2 <RecWavDesc+0x222>
movl   $0x2,-0x2038(%rbp)
movzwl -0x22(%rbp),%eax
cmp    $0x10,%eax
jle    13c9 <RecWavDesc+0x239>
movl   $0x3,-0x2038(%rbp)
mov    -0x2038(%rbp),%eax
movzwl -0x1a(%rbp),%ecx
imul   %ecx,%eax
mov    %ax,-0x204c(%rbp)
mov    -0x20(%rbp),%eax
imul   -0x2038(%rbp),%eax
movzwl -0x1a(%rbp),%ecx
imul   %ecx,%eax
mov    %eax,-0x2034(%rbp)
mov    -0x2034(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x2040(%rbp)
mov    -0x2040(%rbp),%eax
shr    $0xd,%eax
add    $0x1,%eax
mov    %eax,-0x203c(%rbp)
mov    -0x203c(%rbp),%eax
shl    $0xd,%eax
mov    %eax,-0x2040(%rbp)
mov    -0x2040(%rbp),%eax
add    $0x24,%eax
mov    %eax,-0x2044(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2b69(%rip),%rax
mov    (%rax),%esi
mov    0x2bb0(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
call   10a0 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    1479 <RecWavDesc+0x2e9>
lea    0xb98(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    182d <RecWavDesc+0x69d>
lea    -0x2030(%rbp),%rdi
lea    0xb7e(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x2044(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
mov    -0x2044(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x2044(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
mov    %al,-0x202e(%rbp)
mov    -0x2044(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,-0x202d(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
lea    -0x2030(%rbp),%rdi
lea    0xafb(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
lea    -0x2030(%rbp),%rdi
lea    0xad9(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movb   $0x10,-0x2030(%rbp)
movb   $0x0,-0x202f(%rbp)
movb   $0x0,-0x202e(%rbp)
movb   $0x0,-0x202d(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movzwl -0x204a(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
movzwl -0x204a(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
movzwl -0x1a(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
movzwl -0x1a(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    -0x20(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
mov    %al,-0x202e(%rbp)
mov    -0x20(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,-0x202d(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x2034(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
mov    -0x2034(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x2034(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
mov    %al,-0x202e(%rbp)
mov    -0x2034(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,-0x202d(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movzwl -0x204c(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
movzwl -0x204c(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
movzwl -0x22(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
movzwl -0x22(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    -0x2030(%rbp),%rdi
lea    0x8f1(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    -0x2040(%rbp),%eax
and    $0xff,%eax
mov    %al,-0x2030(%rbp)
mov    -0x2040(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,-0x202f(%rbp)
mov    -0x2040(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
mov    %al,-0x202e(%rbp)
mov    -0x2040(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,-0x202d(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movl   $0x0,-0x2048(%rbp)
mov    -0x2048(%rbp),%eax
cmp    -0x203c(%rbp),%eax
jae    17f5 <RecWavDesc+0x665>
mov    -0x14(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2000,%edx
call   1090 <read@plt>
mov    -0x28(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x2000,%edx
call   1040 <write@plt>
mov    -0x2048(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2048(%rbp)
jmp    17a7 <RecWavDesc+0x617>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2054(%rbp)
mov    -0x28(%rbp),%edi
mov    0x27d0(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <lseek@plt>
mov    -0x2054(%rbp),%edi
mov    %eax,%esi
call   1050 <ftruncate@plt>
mov    -0x28(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2060,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecWavDesc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2038,%rsp
mov    %r9d,%r15d
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %edx,%ebx
mov    %esi,%r14d
cmp    $0x10,%r15w
je     11cf <RecWavDesc+0x3f>
cmp    $0x8,%r15w
jne    14df <RecWavDesc+0x34f>
mov    %rdi,0x8(%rsp)
mov    0x2dd3(%rip),%rbp
jmp    11db <RecWavDesc+0x4b>
mov    %rdi,0x8(%rsp)
mov    0x2ded(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x4(%rsp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
mov    0x4(%rsp),%eax
cmp    0x0(%rbp),%eax
jne    14df <RecWavDesc+0x34f>
lea    -0x1(%r13),%eax
cmp    $0x1,%ax
ja     14df <RecWavDesc+0x34f>
mov    %r13,0x20(%rsp)
movzwl %r13w,%r13d
lea    -0x1(%r13),%ebp
mov    %ebp,0x4(%rsp)
mov    0x2db5(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    %ebp,0x4(%rsp)
jne    14df <RecWavDesc+0x34f>
mov    0x2070(%rsp),%ebp
mov    %r12d,0x14(%rsp)
mov    %r12d,0x4(%rsp)
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
lea    0x4(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
xor    %r12d,%r12d
test   $0x40000000,%ebp
jne    14ec <RecWavDesc+0x35c>
mov    %r13,%rbp
xor    %eax,%eax
mov    %r15d,%ecx
sub    $0x9,%cx
setb   %al
cmp    $0x8,%cx
mov    $0x2,%r12d
cmovae %eax,%r12d
mov    0x2d0a(%rip),%rax
mov    0x2d53(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x8(%rsp),%rdi
mov    $0x1a4,%edx
call   10a0 <open@plt>
test   %eax,%eax
js     1501 <RecWavDesc+0x371>
mov    %eax,%r13d
imul   0x14(%rsp),%ebp
imul   %r12d,%ebp
mov    %rbp,0x28(%rsp)
imul   %ebp,%ebx
lea    0x2000(%rbx),%eax
mov    %eax,0x8(%rsp)
shr    $0xd,%ebx
mov    0x20(%rsp),%rax
imul   %r12d,%eax
mov    %eax,0x18(%rsp)
lea    0xd10(%rip),%rsi
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movb   $0x24,0x30(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,%r12d
shr    $0x8,%r12d
and    $0xe0,%r12b
mov    %r12b,0x31(%rsp)
mov    %eax,%ecx
shr    $0x10,%ecx
mov    %ecx,0x1c(%rsp)
mov    %cl,0x32(%rsp)
shr    $0x18,%eax
mov    %eax,0x8(%rsp)
mov    %al,0x33(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xcb0(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
lea    0xc96(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movl   $0x10,0x30(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movw   $0x1,0x30(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    0x20(%rsp),%rax
mov    %al,0x30(%rsp)
movb   $0x0,0x31(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    0x14(%rsp),%eax
mov    %eax,0x30(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    0x28(%rsp),%rax
mov    %eax,0x30(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    0x18(%rsp),%eax
mov    %al,0x30(%rsp)
movb   $0x0,0x31(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1040 <write@plt>
mov    %r15w,0x30(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1040 <write@plt>
lea    0xbcb(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcpy@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
movb   $0x0,0x30(%rsp)
mov    %r12b,0x31(%rsp)
mov    0x1c(%rsp),%eax
mov    %al,0x32(%rsp)
mov    0x8(%rsp),%eax
mov    %al,0x33(%rsp)
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x4,%edx
call   1040 <write@plt>
add    $0x1,%ebx
xchg   %ax,%ax
mov    %r14d,%edi
mov    %rbp,%rsi
mov    $0x2000,%edx
call   1090 <read@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    $0x2000,%edx
call   1040 <write@plt>
add    $0xffffffff,%ebx
jne    1490 <RecWavDesc+0x300>
mov    0x2b1c(%rip),%rax
mov    (%rax),%edx
xor    %r12d,%r12d
mov    %r13d,%edi
xor    %esi,%esi
call   1060 <lseek@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1050 <ftruncate@plt>
mov    %r13d,%edi
call   1080 <close@plt>
jmp    14ec <RecWavDesc+0x35c>
xor    %edi,%edi
call   1080 <close@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x2038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaf8(%rip),%rdi
call   10b0 <perror@plt>
jmp    14e6 <RecWavDesc+0x356>

LLVM IR (-O0):
@AFMT_U8 = global i32 0
@SNDCTL_DSP_SETFMT = global i32 0
@AFMT_S16_LE = global i32 0
@SNDCTL_DSP_STEREO = global i32 0
@SNDCTL_DSP_SPEED = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str = [5 x i8] c"open\00"
@.str.1 = [5 x i8] c"RIFF\00"
@.str.2 = [5 x i8] c"WAVE\00"
@.str.3 = [5 x i8] c"fmt \00"
@.str.4 = [5 x i8] c"data\00"
@SEEK_CUR = global i32 0
define i32 @RecWavDesc(i8* %0, i32 %1, i32 %2, i16 zeroext %3, i32 %4, i16 zeroext %5, i32 %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i16
%13 = alloca i32
%14 = alloca i16
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [8192 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i16
%26 = alloca i16
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i16 %3, i16* %12
store i32 %4, i32* %13
store i16 %5, i16* %14
store i32 %6, i32* %15
store i32 0, i32* %16
store i32 0, i32* %20
store i16 1, i16* %25
%27 = load i16, i16* %25
%28 = zext i16 %27 to i32
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %31
30: ; preds = %7
store i32 -1, i32* %8
br label %341
31: ; preds = %7
%32 = load i16, i16* %14
%33 = zext i16 %32 to i32
switch i32 %33, label %58 [
i32 8, label %34
i32 16, label %46
]
34: ; preds = %31
%35 = load i32, i32* @AFMT_U8
store i32 %35, i32* %17
%36 = load i32, i32* %10
%37 = load i32, i32* @SNDCTL_DSP_SETFMT
%38 = call i32 @ioctl(i32 %36, i32 %37, i32* %17)
%39 = load i32, i32* %17
%40 = load i32, i32* @AFMT_U8
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = load i32, i32* %16
%44 = call i32 @close(i32 %43)
store i32 -1, i32* %8
br label %341
45: ; preds = %34
br label %61
46: ; preds = %31
%47 = load i32, i32* @AFMT_S16_LE
store i32 %47, i32* %17
%48 = load i32, i32* %10
%49 = load i32, i32* @SNDCTL_DSP_SETFMT
%50 = call i32 @ioctl(i32 %48, i32 %49, i32* %17)
%51 = load i32, i32* %17
%52 = load i32, i32* @AFMT_S16_LE
%53 = icmp ne i32 %51, %52
br i1 %53, label %54, label %57
54: ; preds = %46
%55 = load i32, i32* %16
%56 = call i32 @close(i32 %55)
store i32 -1, i32* %8
br label %341
57: ; preds = %46
br label %61
58: ; preds = %31
%59 = load i32, i32* %16
%60 = call i32 @close(i32 %59)
store i32 -1, i32* %8
br label %341
61: ; preds = %57, %45
%62 = load i16, i16* %12
%63 = zext i16 %62 to i32
%64 = icmp sgt i32 %63, 0
br i1 %64, label %65, label %85
65: ; preds = %61
%66 = load i16, i16* %12
%67 = zext i16 %66 to i32
%68 = icmp slt i32 %67, 3
br i1 %68, label %69, label %85
69: ; preds = %65
%70 = load i16, i16* %12
%71 = zext i16 %70 to i32
%72 = sub nsw i32 %71, 1
store i32 %72, i32* %17
%73 = load i32, i32* %10
%74 = load i32, i32* @SNDCTL_DSP_STEREO
%75 = call i32 @ioctl(i32 %73, i32 %74, i32* %17)
%76 = load i32, i32* %17
%77 = load i16, i16* %12
%78 = zext i16 %77 to i32
%79 = sub nsw i32 %78, 1
%80 = icmp ne i32 %76, %79
br i1 %80, label %81, label %84
81: ; preds = %69
%82 = load i32, i32* %16
%83 = call i32 @close(i32 %82)
store i32 -1, i32* %8
br label %341
84: ; preds = %69
br label %88
85: ; preds = %65, %61
%86 = load i32, i32* %16
%87 = call i32 @close(i32 %86)
store i32 -1, i32* %8
br label %341
88: ; preds = %84
%89 = load i32, i32* %13
store i32 %89, i32* %17
%90 = load i32, i32* %10
%91 = load i32, i32* @SNDCTL_DSP_SPEED
%92 = call i32 @ioctl(i32 %90, i32 %91, i32* %17)
%93 = load i32, i32* %15
%94 = and i32 %93, 1073741824
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %97
96: ; preds = %88
store i32 0, i32* %8
br label %341
97: ; preds = %88
%98 = load i16, i16* %14
%99 = zext i16 %98 to i32
%100 = icmp sle i32 %99, 8
br i1 %100, label %101, label %102
101: ; preds = %97
store i32 1, i32* %20
br label %102
102: ; preds = %101, %97
%103 = load i16, i16* %14
%104 = zext i16 %103 to i32
%105 = icmp sgt i32 %104, 8
br i1 %105, label %106, label %111
106: ; preds = %102
%107 = load i16, i16* %14
%108 = zext i16 %107 to i32
%109 = icmp sle i32 %108, 16
br i1 %109, label %110, label %111
110: ; preds = %106
store i32 2, i32* %20
br label %111
111: ; preds = %110, %106, %102
%112 = load i16, i16* %14
%113 = zext i16 %112 to i32
%114 = icmp sgt i32 %113, 16
br i1 %114, label %115, label %116
115: ; preds = %111
store i32 3, i32* %20
br label %116
116: ; preds = %115, %111
%117 = load i32, i32* %20
%118 = load i16, i16* %12
%119 = zext i16 %118 to i32
%120 = mul i32 %117, %119
%121 = trunc i32 %120 to i16
store i16 %121, i16* %26
%122 = load i32, i32* %13
%123 = load i32, i32* %20
%124 = mul i32 %122, %123
%125 = load i16, i16* %12
%126 = zext i16 %125 to i32
%127 = mul i32 %124, %126
store i32 %127, i32* %19
%128 = load i32, i32* %19
%129 = load i32, i32* %11
%130 = mul i32 %128, %129
store i32 %130, i32* %22
%131 = load i32, i32* %22
%132 = udiv i32 %131, 8192
%133 = add i32 %132, 1
store i32 %133, i32* %21
%134 = load i32, i32* %21
%135 = mul i32 %134, 8192
store i32 %135, i32* %22
%136 = load i32, i32* %22
%137 = add i32 %136, 36
store i32 %137, i32* %23
%138 = load i8*, i8** %9
%139 = load i32, i32* @O_WRONLY
%140 = load i32, i32* @O_CREAT
%141 = or i32 %139, %140
%142 = call i32 @open(i8* %138, i32 %141, i32 420)
store i32 %142, i32* %16
%143 = load i32, i32* %16
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %147
145: ; preds = %116
%146 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %8
br label %341
147: ; preds = %116
%148 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%149 = call i32 @strcpy(i8* %148, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%150 = load i32, i32* %16
%151 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%152 = call i32 @write(i32 %150, i8* %151, i32 4)
%153 = load i32, i32* %23
%154 = and i32 %153, 255
%155 = trunc i32 %154 to i8
%156 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %155, i8* %156
%157 = load i32, i32* %23
%158 = and i32 %157, 65280
%159 = lshr i32 %158, 8
%160 = trunc i32 %159 to i8
%161 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %160, i8* %161
%162 = load i32, i32* %23
%163 = and i32 %162, 16711680
%164 = lshr i32 %163, 16
%165 = trunc i32 %164 to i8
%166 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 2
store i8 %165, i8* %166
%167 = load i32, i32* %23
%168 = and i32 %167, -16777216
%169 = lshr i32 %168, 24
%170 = trunc i32 %169 to i8
%171 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 3
store i8 %170, i8* %171
%172 = load i32, i32* %16
%173 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%174 = call i32 @write(i32 %172, i8* %173, i32 4)
%175 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%176 = call i32 @strcpy(i8* %175, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%177 = load i32, i32* %16
%178 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%179 = call i32 @write(i32 %177, i8* %178, i32 4)
%180 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%181 = call i32 @strcpy(i8* %180, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%182 = load i32, i32* %16
%183 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%184 = call i32 @write(i32 %182, i8* %183, i32 4)
%185 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 16, i8* %185
%186 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 0, i8* %186
%187 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 2
store i8 0, i8* %187
%188 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 3
store i8 0, i8* %188
%189 = load i32, i32* %16
%190 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%191 = call i32 @write(i32 %189, i8* %190, i32 4)
%192 = load i16, i16* %25
%193 = zext i16 %192 to i32
%194 = and i32 %193, 255
%195 = trunc i32 %194 to i8
%196 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %195, i8* %196
%197 = load i16, i16* %25
%198 = zext i16 %197 to i32
%199 = and i32 %198, 65280
%200 = ashr i32 %199, 8
%201 = trunc i32 %200 to i8
%202 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %201, i8* %202
%203 = load i32, i32* %16
%204 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%205 = call i32 @write(i32 %203, i8* %204, i32 2)
%206 = load i16, i16* %12
%207 = zext i16 %206 to i32
%208 = and i32 %207, 255
%209 = trunc i32 %208 to i8
%210 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %209, i8* %210
%211 = load i16, i16* %12
%212 = zext i16 %211 to i32
%213 = and i32 %212, 65280
%214 = ashr i32 %213, 8
%215 = trunc i32 %214 to i8
%216 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %215, i8* %216
%217 = load i32, i32* %16
%218 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%219 = call i32 @write(i32 %217, i8* %218, i32 2)
%220 = load i32, i32* %13
%221 = and i32 %220, 255
%222 = trunc i32 %221 to i8
%223 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %222, i8* %223
%224 = load i32, i32* %13
%225 = and i32 %224, 65280
%226 = lshr i32 %225, 8
%227 = trunc i32 %226 to i8
%228 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %227, i8* %228
%229 = load i32, i32* %13
%230 = and i32 %229, 16711680
%231 = lshr i32 %230, 16
%232 = trunc i32 %231 to i8
%233 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 2
store i8 %232, i8* %233
%234 = load i32, i32* %13
%235 = and i32 %234, -16777216
%236 = lshr i32 %235, 24
%237 = trunc i32 %236 to i8
%238 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 3
store i8 %237, i8* %238
%239 = load i32, i32* %16
%240 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%241 = call i32 @write(i32 %239, i8* %240, i32 4)
%242 = load i32, i32* %19
%243 = and i32 %242, 255
%244 = trunc i32 %243 to i8
%245 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %244, i8* %245
%246 = load i32, i32* %19
%247 = and i32 %246, 65280
%248 = lshr i32 %247, 8
%249 = trunc i32 %248 to i8
%250 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %249, i8* %250
%251 = load i32, i32* %19
%252 = and i32 %251, 16711680
%253 = lshr i32 %252, 16
%254 = trunc i32 %253 to i8
%255 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 2
store i8 %254, i8* %255
%256 = load i32, i32* %19
%257 = and i32 %256, -16777216
%258 = lshr i32 %257, 24
%259 = trunc i32 %258 to i8
%260 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 3
store i8 %259, i8* %260
%261 = load i32, i32* %16
%262 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%263 = call i32 @write(i32 %261, i8* %262, i32 4)
%264 = load i16, i16* %26
%265 = zext i16 %264 to i32
%266 = and i32 %265, 255
%267 = trunc i32 %266 to i8
%268 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %267, i8* %268
%269 = load i16, i16* %26
%270 = zext i16 %269 to i32
%271 = and i32 %270, 65280
%272 = ashr i32 %271, 8
%273 = trunc i32 %272 to i8
%274 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %273, i8* %274
%275 = load i32, i32* %16
%276 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%277 = call i32 @write(i32 %275, i8* %276, i32 2)
%278 = load i16, i16* %14
%279 = zext i16 %278 to i32
%280 = and i32 %279, 255
%281 = trunc i32 %280 to i8
%282 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %281, i8* %282
%283 = load i16, i16* %14
%284 = zext i16 %283 to i32
%285 = and i32 %284, 65280
%286 = ashr i32 %285, 8
%287 = trunc i32 %286 to i8
%288 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %287, i8* %288
%289 = load i32, i32* %16
%290 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%291 = call i32 @write(i32 %289, i8* %290, i32 2)
%292 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%293 = call i32 @strcpy(i8* %292, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%294 = load i32, i32* %16
%295 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%296 = call i32 @write(i32 %294, i8* %295, i32 4)
%297 = load i32, i32* %22
%298 = and i32 %297, 255
%299 = trunc i32 %298 to i8
%300 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
store i8 %299, i8* %300
%301 = load i32, i32* %22
%302 = and i32 %301, 65280
%303 = lshr i32 %302, 8
%304 = trunc i32 %303 to i8
%305 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 1
store i8 %304, i8* %305
%306 = load i32, i32* %22
%307 = and i32 %306, 16711680
%308 = lshr i32 %307, 16
%309 = trunc i32 %308 to i8
%310 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 2
store i8 %309, i8* %310
%311 = load i32, i32* %22
%312 = and i32 %311, -16777216
%313 = lshr i32 %312, 24
%314 = trunc i32 %313 to i8
%315 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 3
store i8 %314, i8* %315
%316 = load i32, i32* %16
%317 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%318 = call i32 @write(i32 %316, i8* %317, i32 4)
store i32 0, i32* %24
br label %319
319: ; preds = %330, %147
%320 = load i32, i32* %24
%321 = load i32, i32* %21
%322 = icmp ult i32 %320, %321
br i1 %322, label %323, label %333
323: ; preds = %319
%324 = load i32, i32* %10
%325 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%326 = call i32 @read(i32 %324, i8* %325, i32 8192)
%327 = load i32, i32* %16
%328 = getelementptr inbounds [8192 x i8], [8192 x i8]* %18, i64 0, i64 0
%329 = call i32 @write(i32 %327, i8* %328, i32 8192)
br label %330
330: ; preds = %323
%331 = load i32, i32* %24
%332 = add i32 %331, 1
store i32 %332, i32* %24
br label %319
333: ; preds = %319
%334 = load i32, i32* %16
%335 = load i32, i32* %16
%336 = load i32, i32* @SEEK_CUR
%337 = call i32 @lseek(i32 %335, i32 0, i32 %336)
%338 = call i32 @ftruncate(i32 %334, i32 %337)
%339 = load i32, i32* %16
%340 = call i32 @close(i32 %339)
store i32 0, i32* %8
br label %341
341: ; preds = %333, %145, %96, %85, %81, %58, %54, %42, %30
%342 = load i32, i32* %8
ret i32 %342
}

LLVM IR (-O2):
@AFMT_U8 = global i32 0
@SNDCTL_DSP_SETFMT = global i32 0
@AFMT_S16_LE = global i32 0
@SNDCTL_DSP_STEREO = global i32 0
@SNDCTL_DSP_SPEED = global i32 0
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str = [5 x i8] c"open\00"
@.str.1 = [5 x i8] c"RIFF\00"
@.str.2 = [5 x i8] c"WAVE\00"
@.str.3 = [5 x i8] c"fmt \00"
@.str.4 = [5 x i8] c"data\00"
@SEEK_CUR = global i32 0
define i32 @RecWavDesc(i8* nocapture %0, i32 %1, i32 %2, i16 zeroext %3, i32 %4, i16 zeroext %5, i32 %6) {
%8 = alloca i32
%9 = alloca [8192 x i8]
%10 = bitcast i32* %8 to i8*
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 0
switch i16 %5, label %30 [
i16 8, label %12
i16 16, label %21
]
12: ; preds = %7
%13 = load i32, i32* @AFMT_U8
store i32 %13, i32* %8
%14 = load i32, i32* @SNDCTL_DSP_SETFMT
%15 = call i32 @ioctl(i32 %1, i32 %14, i32* %8)
%16 = load i32, i32* %8
%17 = load i32, i32* @AFMT_U8
%18 = icmp eq i32 %16, %17
br i1 %18, label %32, label %19
19: ; preds = %12
%20 = call i32 @close(i32 0)
br label %129
21: ; preds = %7
%22 = load i32, i32* @AFMT_S16_LE
store i32 %22, i32* %8
%23 = load i32, i32* @SNDCTL_DSP_SETFMT
%24 = call i32 @ioctl(i32 %1, i32 %23, i32* %8)
%25 = load i32, i32* %8
%26 = load i32, i32* @AFMT_S16_LE
%27 = icmp eq i32 %25, %26
br i1 %27, label %32, label %28
28: ; preds = %21
%29 = call i32 @close(i32 0)
br label %129
30: ; preds = %7
%31 = tail call i32 @close(i32 0)
br label %129
32: ; preds = %21, %12
%33 = zext i16 %3 to i32
%34 = add i16 %3, -1
%35 = icmp ult i16 %34, 2
br i1 %35, label %36, label %44
36: ; preds = %32
%37 = add nsw i32 %33, -1
store i32 %37, i32* %8
%38 = load i32, i32* @SNDCTL_DSP_STEREO
%39 = call i32 @ioctl(i32 %1, i32 %38, i32* %8)
%40 = load i32, i32* %8
%41 = icmp eq i32 %40, %37
br i1 %41, label %46, label %42
42: ; preds = %36
%43 = call i32 @close(i32 0)
br label %129
44: ; preds = %32
%45 = call i32 @close(i32 0)
br label %129
46: ; preds = %36
store i32 %4, i32* %8
%47 = load i32, i32* @SNDCTL_DSP_SPEED
%48 = call i32 @ioctl(i32 %1, i32 %47, i32* %8)
%49 = and i32 %6, 1073741824
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %129
51: ; preds = %46
%52 = icmp ult i16 %5, 9
%53 = zext i1 %52 to i32
%54 = add nsw i16 %5, -9
%55 = icmp ult i16 %54, 8
%56 = select i1 %55, i32 2, i32 %53
%57 = mul i32 %33, %4
%58 = mul i32 %57, %56
%59 = mul i32 %58, %2
%60 = add i32 %59, 8192
%61 = load i32, i32* @O_WRONLY
%62 = load i32, i32* @O_CREAT
%63 = or i32 %62, %61
%64 = call i32 @open(i8* %0, i32 %63, i32 420)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %51
%67 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %129
68: ; preds = %51
%69 = lshr i32 %59, 13
%70 = trunc i32 %56 to i16
%71 = mul nuw nsw i16 %70, %3
%72 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%73 = call i32 @write(i32 %64, i8* %11, i32 4)
store i8 36, i8* %11
%74 = lshr i32 %60, 8
%75 = trunc i32 %74 to i8
%76 = and i8 %75, -32
%77 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 1
store i8 %76, i8* %77
%78 = lshr i32 %60, 16
%79 = trunc i32 %78 to i8
%80 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 2
store i8 %79, i8* %80
%81 = lshr i32 %60, 24
%82 = trunc i32 %81 to i8
%83 = getelementptr inbounds [8192 x i8], [8192 x i8]* %9, i64 0, i64 3
store i8 %82, i8* %83
%84 = call i32 @write(i32 %64, i8* %11, i32 4)
%85 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%86 = call i32 @write(i32 %64, i8* %11, i32 4)
%87 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%88 = call i32 @write(i32 %64, i8* %11, i32 4)
store i8 16, i8* %11
store i8 0, i8* %77
store i8 0, i8* %80
store i8 0, i8* %83
%89 = call i32 @write(i32 %64, i8* %11, i32 4)
store i8 1, i8* %11
store i8 0, i8* %77
%90 = call i32 @write(i32 %64, i8* %11, i32 2)
%91 = trunc i16 %3 to i8
store i8 %91, i8* %11
store i8 0, i8* %77
%92 = call i32 @write(i32 %64, i8* %11, i32 2)
%93 = trunc i32 %4 to i8
store i8 %93, i8* %11
%94 = lshr i32 %4, 8
%95 = trunc i32 %94 to i8
store i8 %95, i8* %77
%96 = lshr i32 %4, 16
%97 = trunc i32 %96 to i8
store i8 %97, i8* %80
%98 = lshr i32 %4, 24
%99 = trunc i32 %98 to i8
store i8 %99, i8* %83
%100 = call i32 @write(i32 %64, i8* %11, i32 4)
%101 = trunc i32 %58 to i8
store i8 %101, i8* %11
%102 = lshr i32 %58, 8
%103 = trunc i32 %102 to i8
store i8 %103, i8* %77
%104 = lshr i32 %58, 16
%105 = trunc i32 %104 to i8
store i8 %105, i8* %80
%106 = lshr i32 %58, 24
%107 = trunc i32 %106 to i8
store i8 %107, i8* %83
%108 = call i32 @write(i32 %64, i8* %11, i32 4)
%109 = trunc i16 %71 to i8
store i8 %109, i8* %11
store i8 0, i8* %77
%110 = call i32 @write(i32 %64, i8* %11, i32 2)
%111 = trunc i16 %5 to i8
store i8 %111, i8* %11
%112 = lshr i16 %5, 8
%113 = trunc i16 %112 to i8
store i8 %113, i8* %77
%114 = call i32 @write(i32 %64, i8* %11, i32 2)
%115 = call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%116 = call i32 @write(i32 %64, i8* %11, i32 4)
store i8 0, i8* %11
store i8 %76, i8* %77
store i8 %79, i8* %80
store i8 %82, i8* %83
%117 = call i32 @write(i32 %64, i8* %11, i32 4)
br label %118
118: ; preds = %68, %118
%119 = phi i32 [ 0, %68 ], [ %122, %118 ]
%120 = call i32 @read(i32 %1, i8* %11, i32 8192)
%121 = call i32 @write(i32 %64, i8* %11, i32 8192)
%122 = add nuw nsw i32 %119, 1
%123 = icmp eq i32 %119, %69
br i1 %123, label %124, label %118
124: ; preds = %118
%125 = load i32, i32* @SEEK_CUR
%126 = call i32 @lseek(i32 %64, i32 0, i32 %125)
%127 = call i32 @ftruncate(i32 %64, i32 %126)
%128 = call i32 @close(i32 %64)
br label %129
129: ; preds = %46, %124, %66, %44, %42, %30, %28, %19
%130 = phi i32 [ -1, %30 ], [ -1, %28 ], [ -1, %42 ], [ -1, %66 ], [ 0, %124 ], [ -1, %44 ], [ -1, %19 ], [ 0, %46 ]
ret i32 %130
}