#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int fragstotal;
  int fragsize;
};
typedef TYPE_1__ audio_buf_info;

/* Variables and functions */
int /*<<< orphan*/ SNDCTL_DSP_GETOSPACE;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ ioctl(int, int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
void silence(int dsp) {
  int i;
  audio_buf_info abi;
  char buf[1024];
  if (ioctl(dsp, SNDCTL_DSP_GETOSPACE, &abi))
    fprintf(stderr, "SNDCTL_DSP_GETOSPACE:%s.\n", strerror(errno));
  for (i = 0; i < 1024; i++)
    buf[i] = 0;
  for (i = 0; i < abi.fragstotal * abi.fragsize; i += 1024)
    write(dsp, buf, 1024);
  return;
}


x86 assembly (clang, -O0):
<silence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e90(%rip),%rax
mov    (%rax),%esi
lea    -0x10(%rbp),%rdx
call   1040 <ioctl@plt>
cmp    $0x0,%rax
je     119f <silence+0x5f>
mov    0x2e64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x414(%rbp)
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1060 <strerror@plt>
mov    -0x414(%rbp),%edi
mov    %rax,%rdx
lea    0xe66(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jge    11cd <silence+0x8d>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x410(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a6 <silence+0x66>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    120a <silence+0xca>
mov    -0x4(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
call   1030 <write@plt>
mov    -0x8(%rbp),%eax
add    $0x400,%eax
mov    %eax,-0x8(%rbp)
jmp    11d4 <silence+0x94>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<silence>:
push   %rbp
push   %r14
push   %rbx
sub    $0x410,%rsp
mov    %edi,%ebx
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
lea    0x8(%rsp),%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
je     119d <silence+0x4d>
mov    0x2e5c(%rip),%rax
mov    (%rax),%ebp
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe6d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
lea    0x10(%rsp),%rdi
xor    %ebp,%ebp
mov    $0x400,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0xc(%rsp),%eax
imul   0x8(%rsp),%eax
test   %eax,%eax
jle    11f2 <silence+0xa2>
lea    0x10(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1030 <write@plt>
add    $0x400,%ebp
mov    0xc(%rsp),%eax
imul   0x8(%rsp),%eax
cmp    %eax,%ebp
jl     11d0 <silence+0x80>
add    $0x410,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32 }
@SNDCTL_DSP_GETOSPACE = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"SNDCTL_DSP_GETOSPACE:%s.\0A\00"
@errno = global i32 0
define void @silence(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.TYPE_3__
%5 = alloca [1024 x i8]
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* @SNDCTL_DSP_GETOSPACE
%8 = call i64 @ioctl(i32 %6, i32 %7, %struct.TYPE_3__* %4)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %1
store i32 0, i32* %3
br label %16
16: ; preds = %23, %15
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 1024
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %21
store i8 0, i8* %22
br label %23
23: ; preds = %19
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %16
26: ; preds = %16
store i32 0, i32* %3
br label %27
27: ; preds = %39, %26
%28 = load i32, i32* %3
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 0
%30 = load i32, i32* %29
%31 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i32 0, i32 1
%32 = load i32, i32* %31
%33 = mul nsw i32 %30, %32
%34 = icmp slt i32 %28, %33
br i1 %34, label %35, label %42
35: ; preds = %27
%36 = load i32, i32* %2
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%38 = call i32 @write(i32 %36, i8* %37, i32 1024)
br label %39
39: ; preds = %35
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1024
store i32 %41, i32* %3
br label %27
42: ; preds = %27
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32 }
@SNDCTL_DSP_GETOSPACE = global i32 0
@stderr = global i32 0
@.str = [26 x i8] c"SNDCTL_DSP_GETOSPACE:%s.\0A\00"
@errno = global i32 0
define void @silence(i32 %0) {
%2 = alloca %struct.TYPE_3__
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = bitcast %struct.TYPE_3__* %2 to i8*
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @SNDCTL_DSP_GETOSPACE
%8 = call i64 @ioctl(i32 %0, i32 %7, %struct.TYPE_3__* %2)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %1
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 1
%18 = load i32, i32* %16
%19 = load i32, i32* %17
%20 = mul nsw i32 %19, %18
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %15, %22
%23 = phi i32 [ %25, %22 ], [ 0, %15 ]
%24 = call i32 @write(i32 %0, i8* %6, i32 1024)
%25 = add nuw nsw i32 %23, 1024
%26 = load i32, i32* %16
%27 = load i32, i32* %17
%28 = mul nsw i32 %27, %26
%29 = icmp slt i32 %25, %28
br i1 %29, label %22, label %30
30: ; preds = %22, %15
ret void
}