#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*/ FILE;

/* Variables and functions */
scalar_t__ EOF;
scalar_t__ fputc(int, int /*<<< orphan*/ *);
int write_silence(FILE *out, int samples) {
  int a;
  for (a = 0; a < samples; a++)
    if (fputc(0x80, out) == EOF)
      return -1;
  return a;
}


x86 assembly (clang, -O0):
<write_silence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116f <write_silence+0x5f>
mov    -0x10(%rbp),%rsi
mov    $0x80,%edi
call   1030 <fputc@plt>
mov    0x2ea1(%rip),%rcx
cmp    (%rcx),%rax
jne    115c <write_silence+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1175 <write_silence+0x65>
jmp    1161 <write_silence+0x51>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <write_silence+0x16>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_silence>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1149 <write_silence+0x39>
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2ec0(%rip),%r15
mov    %esi,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x80,%edi
mov    %rbx,%rsi
call   1030 <fputc@plt>
cmp    (%r15),%rax
je     114e <write_silence+0x3e>
add    $0xffffffff,%ebp
jne    1130 <write_silence+0x20>
jmp    1154 <write_silence+0x44>
xor    %r14d,%r14d
jmp    1154 <write_silence+0x44>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @write_silence(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %6
%9 = load i32, i32* %5
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %21
11: ; preds = %7
%12 = load i32*, i32** %4
%13 = call i64 @fputc(i32 128, i32* %12)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %17
16: ; preds = %11
store i32 -1, i32* %3
br label %23
17: ; preds = %11
br label %18
18: ; preds = %17
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
br label %7
21: ; preds = %7
%22 = load i32, i32* %6
store i32 %22, i32* %3
br label %23
23: ; preds = %21, %16
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i64 0
define i32 @write_silence(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %12
4: ; preds = %2, %9
%5 = phi i32 [ %10, %9 ], [ 0, %2 ]
%6 = tail call i64 @fputc(i32 128, i32* %0)
%7 = load i64, i64* @EOF
%8 = icmp eq i64 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = add nuw nsw i32 %5, 1
%11 = icmp eq i32 %10, %1
br i1 %11, label %12, label %4
12: ; preds = %4, %9, %2
%13 = phi i32 [ 0, %2 ], [ %1, %9 ], [ -1, %4 ]
ret i32 %13
}