#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 /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SNDCTL_DSP_GETBLKSIZE;
int /*<<< orphan*/ SNDCTL_DSP_SETFMT;
int /*<<< orphan*/ SNDCTL_DSP_SETFRAGMENT;
int /*<<< orphan*/ SNDCTL_DSP_SPEED;
int /*<<< orphan*/ SNDCTL_DSP_STEREO;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int ioctl(int, int /*<<< orphan*/, int *);
scalar_t__ open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, short *, int);
int write(int, short *, int);
int main(int argc, char *argv[]) {
  int len, format, stereo, speed, cycle, frag_size, samps, srate, chans, magic,
      class;
  int Nspeed, Nmagic, Nchans, Nclass;
  int in_port, out_port;
  int arg, i, j, c1, c2;
  int ifp, ifp2;
  short sampbuff[64];
  short waveform[64];
  float time;
  int check;
  int rec_time;
  printf("======== RTCmix (full-duplex-test) LINUX ========\n");
  speed = 44100;
  chans = 2;
  printf("rate: %d\n", speed);
  printf("chans: %d\n", chans);
  if ((out_port = (int)open("/dev/dsp", O_RDWR, 0)) == -1) {
    perror("/dev/dsp");
    exit(1);
  }
  in_port = out_port;
  arg = 0x000a0006;
  if (ioctl(out_port, SNDCTL_DSP_SETFRAGMENT, &arg) == -1) {
    perror("FRAGMENT SIZE");
    exit(1);
  }
  format = AFMT_S16_LE;
  if (ioctl(out_port, SNDCTL_DSP_SETFMT, &format) == -1) {
    perror("SNDCTL_DSP_SETFMT");
    exit(1);
  }
  stereo = chans - 1;
  if (ioctl(out_port, SNDCTL_DSP_STEREO, &stereo) == -1) {
    perror("SNDCTL_DSP_STEREO");
    exit(1);
  }
  if (ioctl(out_port, SNDCTL_DSP_SPEED, &speed) == -1) {
    perror("SNDCTL_DSP_SPEED");
    exit(1);
  }
  if (ioctl(out_port, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) {
    exit(1);
  }
  printf("audio_in buffer:  %d\n", frag_size);
  printf("audio_out buffer:  %d\n", frag_size);
  for (i = 0; i < 64; i++) {
    sampbuff[i] = 0;
  }
  printf("attempting write...\n");
  if ((len = write(out_port, sampbuff, 2 * 64)) == -1) {
    perror("audio write");
    exit(1);
  }
  printf("write done.\n");
  printf("reading/writing in loop\n");
  while (1) {
    if ((len = read(in_port, sampbuff, 2 * 64)) == -1) {
      perror("audio read");
      exit(1);
    }
    if ((len = write(out_port, sampbuff, 2 * 64)) == -1) {
      perror("audio write");
      exit(1);
    }
    printf(".");
    for (i = 0; i < 64; i++) {
      sampbuff[i] = 0;
    }
  }
  printf("\n");
  close(in_port);
  close(out_port);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xac44,-0x20(%rbp)
movl   $0x2,-0x34(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%esi
lea    0xe71(%rip),%rdi
xor    %edx,%edx
call   1070 <open@plt>
mov    %eax,-0x54(%rbp)
cmp    $0xffffffff,%eax
jne    1200 <main+0x90>
lea    0xe57(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x54(%rbp),%eax
mov    %eax,-0x50(%rbp)
movl   $0xa0006,-0x58(%rbp)
mov    -0x54(%rbp),%edi
mov    0x2da9(%rip),%rax
mov    (%rax),%esi
lea    -0x58(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1241 <main+0xd1>
lea    0xe1f(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x54(%rbp),%edi
mov    0x2d59(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1281 <main+0x111>
lea    0xded(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x54(%rbp),%edi
mov    0x2d4c(%rip),%rax
mov    (%rax),%esi
lea    -0x1c(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12be <main+0x14e>
lea    0xdc2(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x54(%rbp),%edi
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12f2 <main+0x182>
lea    0xda0(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x54(%rbp),%edi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    131a <main+0x1aa>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x28(%rbp),%esi
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x40,-0x5c(%rbp)
jge    1369 <main+0x1f9>
movslq -0x5c(%rbp),%rax
movw   $0x0,-0xf0(%rbp,%rax,2)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1343 <main+0x1d3>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0x80,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    13ad <main+0x23d>
lea    0xd38(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x50(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0x80,%edx
call   1060 <read@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    13ff <main+0x28f>
lea    0xd18(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x54(%rbp),%edi
lea    -0xf0(%rbp),%rsi
mov    $0x80,%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1435 <main+0x2c5>
lea    0xcb0(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
cmpl   $0x40,-0x5c(%rbp)
jge    1470 <main+0x300>
movslq -0x5c(%rbp),%rax
movw   $0x0,-0xf0(%rbp,%rax,2)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    144a <main+0x2da>
jmp    13c9 <main+0x259>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xa8,%rsp
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
movl   $0xac44,0x14(%rsp)
lea    0xe4b(%rip),%rdi
mov    $0xac44,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe42(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
lea    0xe31(%rip),%rdi
xor    %edx,%edx
call   1090 <open@plt>
mov    %rax,%r14
cmp    $0xffffffff,%r14d
jne    1200 <main+0x70>
lea    0xe1a(%rip),%rdi
jmp    140c <main+0x27c>
movl   $0xa0006,0x10(%rsp)
mov    0x2db1(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    122f <main+0x9f>
lea    0xdf4(%rip),%rdi
jmp    140c <main+0x27c>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
lea    0x1c(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1263 <main+0xd3>
lea    0xdce(%rip),%rdi
jmp    140c <main+0x27c>
movl   $0x1,0x18(%rsp)
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
lea    0x18(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    1292 <main+0x102>
lea    0xdb1(%rip),%rdi
jmp    140c <main+0x27c>
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
lea    0x14(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12b9 <main+0x129>
lea    0xd9c(%rip),%rdi
jmp    140c <main+0x27c>
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
lea    0xc(%rsp),%rdx
mov    %r14d,%edi
call   1070 <ioctl@plt>
cmp    $0xffffffff,%eax
jne    12de <main+0x14e>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0xc(%rsp),%esi
lea    0xd78(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
lea    0xd7c(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
lea    0xd9d(%rip),%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rsi
mov    %r14d,%edi
mov    $0x80,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
jne    1362 <main+0x1d2>
lea    0xd31(%rip),%rdi
jmp    140c <main+0x27c>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
lea    0x20(%rsp),%rsi
mov    %r14d,%edi
mov    $0x80,%edx
call   1080 <read@plt>
cmp    $0xffffffff,%eax
je     1405 <main+0x275>
lea    0x20(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1050 <write@plt>
cmp    $0xffffffff,%eax
je     1356 <main+0x1c6>
mov    $0x2e,%edi
call   1030 <putchar@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1080 <read@plt>
cmp    $0xffffffff,%eax
jne    13a0 <main+0x210>
lea    0xc8e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [51 x i8] c"======== RTCmix (full-duplex-test) LINUX ========\0A\00"
@.str.1 = [10 x i8] c"rate: %d\0A\00"
@.str.2 = [11 x i8] c"chans: %d\0A\00"
@.str.3 = [9 x i8] c"/dev/dsp\00"
@O_RDWR = global i32 0
@SNDCTL_DSP_SETFRAGMENT = global i32 0
@.str.4 = [14 x i8] c"FRAGMENT SIZE\00"
@AFMT_S16_LE = global i32 0
@SNDCTL_DSP_SETFMT = global i32 0
@.str.5 = [18 x i8] c"SNDCTL_DSP_SETFMT\00"
@SNDCTL_DSP_STEREO = global i32 0
@.str.6 = [18 x i8] c"SNDCTL_DSP_STEREO\00"
@SNDCTL_DSP_SPEED = global i32 0
@.str.7 = [17 x i8] c"SNDCTL_DSP_SPEED\00"
@SNDCTL_DSP_GETBLKSIZE = global i32 0
@.str.8 = [22 x i8] c"audio_in buffer: %d\0A\00"
@.str.9 = [23 x i8] c"audio_out buffer: %d\0A\00"
@.str.10 = [21 x i8] c"attempting write...\0A\00"
@.str.11 = [12 x i8] c"audio write\00"
@.str.12 = [13 x i8] c"write done.\0A\00"
@.str.13 = [25 x i8] c"reading/writing in loop\0A\00"
@.str.14 = [11 x i8] c"audio read\00"
@.str.15 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca i32
%30 = alloca [64 x i16]
%31 = alloca [64 x i16]
%32 = alloca float
%33 = alloca i32
%34 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 44100, i32* %9
store i32 2, i32* %14
%36 = load i32, i32* %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %14
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* @O_RDWR
%41 = call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %40, i32 0)
%42 = trunc i64 %41 to i32
store i32 %42, i32* %22
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %2
%45 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %2
%48 = load i32, i32* %22
store i32 %48, i32* %21
store i32 655366, i32* %23
%49 = load i32, i32* %22
%50 = load i32, i32* @SNDCTL_DSP_SETFRAGMENT
%51 = call i32 @ioctl(i32 %49, i32 %50, i32* %23)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %47
%54 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%55 = call i32 @exit(i32 1)
unreachable
56: ; preds = %47
%57 = load i32, i32* @AFMT_S16_LE
store i32 %57, i32* %7
%58 = load i32, i32* %22
%59 = load i32, i32* @SNDCTL_DSP_SETFMT
%60 = call i32 @ioctl(i32 %58, i32 %59, i32* %7)
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %65
62: ; preds = %56
%63 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %56
%66 = load i32, i32* %14
%67 = sub nsw i32 %66, 1
store i32 %67, i32* %8
%68 = load i32, i32* %22
%69 = load i32, i32* @SNDCTL_DSP_STEREO
%70 = call i32 @ioctl(i32 %68, i32 %69, i32* %8)
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %65
%76 = load i32, i32* %22
%77 = load i32, i32* @SNDCTL_DSP_SPEED
%78 = call i32 @ioctl(i32 %76, i32 %77, i32* %9)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %83
80: ; preds = %75
%81 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %75
%84 = load i32, i32* %22
%85 = load i32, i32* @SNDCTL_DSP_GETBLKSIZE
%86 = call i32 @ioctl(i32 %84, i32 %85, i32* %11)
%87 = icmp eq i32 %86, -1
br i1 %87, label %88, label %90
88: ; preds = %83
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %83
%91 = load i32, i32* %11
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %11
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %93)
store i32 0, i32* %24
br label %95
95: ; preds = %102, %90
%96 = load i32, i32* %24
%97 = icmp slt i32 %96, 64
br i1 %97, label %98, label %105
98: ; preds = %95
%99 = load i32, i32* %24
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds [64 x i16], [64 x i16]* %30, i64 0, i64 %100
store i16 0, i16* %101
br label %102
102: ; preds = %98
%103 = load i32, i32* %24
%104 = add nsw i32 %103, 1
store i32 %104, i32* %24
br label %95
105: ; preds = %95
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
%107 = load i32, i32* %22
%108 = getelementptr inbounds [64 x i16], [64 x i16]* %30, i64 0, i64 0
%109 = call i32 @write(i32 %107, i16* %108, i32 128)
store i32 %109, i32* %6
%110 = icmp eq i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %105
%112 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%113 = call i32 @exit(i32 1)
unreachable
114: ; preds = %105
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%116 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0))
br label %117
117: ; preds = %114, %145
%118 = load i32, i32* %21
%119 = getelementptr inbounds [64 x i16], [64 x i16]* %30, i64 0, i64 0
%120 = call i32 @read(i32 %118, i16* %119, i32 128)
store i32 %120, i32* %6
%121 = icmp eq i32 %120, -1
br i1 %121, label %122, label %125
122: ; preds = %117
%123 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%124 = call i32 @exit(i32 1)
unreachable
125: ; preds = %117
%126 = load i32, i32* %22
%127 = getelementptr inbounds [64 x i16], [64 x i16]* %30, i64 0, i64 0
%128 = call i32 @write(i32 %126, i16* %127, i32 128)
store i32 %128, i32* %6
%129 = icmp eq i32 %128, -1
br i1 %129, label %130, label %133
130: ; preds = %125
%131 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%132 = call i32 @exit(i32 1)
unreachable
133: ; preds = %125
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %24
br label %135
135: ; preds = %142, %133
%136 = load i32, i32* %24
%137 = icmp slt i32 %136, 64
br i1 %137, label %138, label %145
138: ; preds = %135
%139 = load i32, i32* %24
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds [64 x i16], [64 x i16]* %30, i64 0, i64 %140
store i16 0, i16* %141
br label %142
142: ; preds = %138
%143 = load i32, i32* %24
%144 = add nsw i32 %143, 1
store i32 %144, i32* %24
br label %135
145: ; preds = %135
br label %117
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"rate: %d\0A\00"
@.str.2 = [11 x i8] c"chans: %d\0A\00"
@.str.3 = [9 x i8] c"/dev/dsp\00"
@O_RDWR = global i32 0
@SNDCTL_DSP_SETFRAGMENT = global i32 0
@.str.4 = [14 x i8] c"FRAGMENT SIZE\00"
@AFMT_S16_LE = global i32 0
@SNDCTL_DSP_SETFMT = global i32 0
@.str.5 = [18 x i8] c"SNDCTL_DSP_SETFMT\00"
@SNDCTL_DSP_STEREO = global i32 0
@.str.6 = [18 x i8] c"SNDCTL_DSP_STEREO\00"
@SNDCTL_DSP_SPEED = global i32 0
@.str.7 = [17 x i8] c"SNDCTL_DSP_SPEED\00"
@SNDCTL_DSP_GETBLKSIZE = global i32 0
@.str.8 = [22 x i8] c"audio_in buffer: %d\0A\00"
@.str.9 = [23 x i8] c"audio_out buffer: %d\0A\00"
@.str.11 = [12 x i8] c"audio write\00"
@.str.14 = [11 x i8] c"audio read\00"
@str = [50 x i8] c"======== RTCmix (full-duplex-test) LINUX ========\00"
@str.16 = [20 x i8] c"attempting write...\00"
@str.17 = [12 x i8] c"write done.\00"
@str.18 = [24 x i8] c"reading/writing in loop\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [64 x i16]
%9 = bitcast [64 x i16]* %8 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
store i32 44100, i32* %5
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 44100)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 2)
%18 = load i32, i32* @O_RDWR
%19 = tail call i64 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 0)
%20 = trunc i64 %19 to i32
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %2
store i32 655366, i32* %7
%26 = load i32, i32* @SNDCTL_DSP_SETFRAGMENT
%27 = call i32 @ioctl(i32 %20, i32 %26, i32* %7)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %32
29: ; preds = %25
%30 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%31 = call i32 @exit(i32 1)
unreachable
32: ; preds = %25
%33 = load i32, i32* @AFMT_S16_LE
store i32 %33, i32* %3
%34 = load i32, i32* @SNDCTL_DSP_SETFMT
%35 = call i32 @ioctl(i32 %20, i32 %34, i32* %3)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %32
store i32 1, i32* %4
%41 = load i32, i32* @SNDCTL_DSP_STEREO
%42 = call i32 @ioctl(i32 %20, i32 %41, i32* %4)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %40
%48 = load i32, i32* @SNDCTL_DSP_SPEED
%49 = call i32 @ioctl(i32 %20, i32 %48, i32* %5)
%50 = icmp eq i32 %49, -1
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %47
%55 = load i32, i32* @SNDCTL_DSP_GETBLKSIZE
%56 = call i32 @ioctl(i32 %20, i32 %55, i32* %6)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = call i32 @exit(i32 1)
unreachable
60: ; preds = %54
%61 = load i32, i32* %6
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %6
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %63)
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.16, i64 0, i64 0))
%66 = getelementptr inbounds [64 x i16], [64 x i16]* %8, i64 0, i64 0
%67 = call i32 @write(i32 %20, i16* %66, i32 128)
%68 = icmp eq i32 %67, -1
br i1 %68, label %69, label %72
69: ; preds = %60
%70 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %60
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.17, i64 0, i64 0))
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.18, i64 0, i64 0))
%75 = call i32 @read(i32 %20, i16* %66, i32 128)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %80
77: ; preds = %86, %72
%78 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %72, %86
%81 = call i32 @write(i32 %20, i16* %66, i32 128)
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
%85 = call i32 @exit(i32 1)
unreachable
86: ; preds = %80
%87 = call i32 @putchar(i32 46)
%88 = call i32 @read(i32 %20, i16* %66, i32 128)
%89 = icmp eq i32 %88, -1
br i1 %89, label %77, label %80
}