#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int fd;
  char buf[257 * 1024];
  int l;
  if ((fd = open("/dev/mixer0", O_RDONLY, 0)) == -1) {
    perror("/dev/mixer0");
    exit(-1);
  }
  while (1) {
    if ((l = read(fd, buf, sizeof(buf))) < 0) {
      perror("read");
      exit(-1);
    }
    if (l)
      write(1, buf, l);
    usleep(100000);
  }
  close(fd);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40420,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
lea    0xe7e(%rip),%rdi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
cmp    $0xffffffff,%eax
jne    11ab <main+0x4b>
lea    0xe64(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
jmp    11b0 <main+0x50>
mov    -0x8(%rbp),%edi
lea    -0x40410(%rbp),%rsi
mov    $0x40400,%edx
call   1040 <read@plt>
mov    %eax,-0x40414(%rbp)
cmp    $0x0,%eax
jge    11e9 <main+0x89>
lea    0xe32(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x40414(%rbp)
je     120d <main+0xad>
lea    -0x40410(%rbp),%rsi
mov    -0x40414(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
mov    $0x186a0,%edi
call   1080 <usleep@plt>
jmp    11b0 <main+0x50>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x40408,%rsp
mov    0x2e78(%rip),%rax
mov    (%rax),%esi
lea    0xe87(%rip),%rdi
xor    %edx,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
jne    118e <main+0x2e>
lea    0xe74(%rip),%rdi
jmp    11aa <main+0x4a>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x40400,%edx
call   1040 <read@plt>
test   %eax,%eax
jns    11b9 <main+0x59>
lea    0xe62(%rip),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>
mov    %rsp,%rbx
jmp    11dd <main+0x7d>
xchg   %ax,%ax
mov    $0x186a0,%edi
call   1080 <usleep@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x40400,%edx
call   1040 <read@plt>
test   %eax,%eax
js     11a3 <main+0x43>
test   %eax,%eax
je     11c0 <main+0x60>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
jmp    11c0 <main+0x60>

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/mixer0\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"read\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [263168 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0)
store i32 %6, i32* %2
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %0
br label %12
12: ; preds = %11, %27
%13 = load i32, i32* %2
%14 = getelementptr inbounds [263168 x i8], [263168 x i8]* %3, i64 0, i64 0
%15 = call i32 @read(i32 %13, i8* %14, i32 263168)
store i32 %15, i32* %4
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %12
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = getelementptr inbounds [263168 x i8], [263168 x i8]* %3, i64 0, i64 0
%25 = load i32, i32* %4
%26 = call i32 @write(i32 1, i8* %24, i32 %25)
br label %27
27: ; preds = %23, %20
%28 = call i32 @usleep(i32 100000)
br label %12
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/mixer0\00"
@O_RDONLY = global i32 0
@.str.1 = [5 x i8] c"read\00"
define i32 @main() {
%1 = alloca [263168 x i8]
%2 = getelementptr inbounds [263168 x i8], [263168 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 @read(i32 %4, i8* %2, i32 263168)
%8 = icmp slt i32 %7, 0
br i1 %8, label %12, label %15
9: ; preds = %0
%10 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %20, %6
%13 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -1)
unreachable
15: ; preds = %6, %20
%16 = phi i32 [ %22, %20 ], [ %7, %6 ]
%17 = icmp eq i32 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @write(i32 1, i8* %2, i32 %16)
br label %20
20: ; preds = %18, %15
%21 = tail call i32 @usleep(i32 100000)
%22 = call i32 @read(i32 %4, i8* %2, i32 263168)
%23 = icmp slt i32 %22, 0
br i1 %23, label %12, label %15
}