#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 */
size_t Write(int, void const *, size_t);
int /*<<< orphan*/ assert(int /*<<< orphan*/);
void Writen(int fd, const void *buf, size_t count) {
  size_t off = 0;
  assert(buf != NULL);
  while (off < count) {
    size_t n;
    n = Write(fd, buf + off, count - off);
    off += n;
  }
}


x86 assembly (clang, -O0):
<Writen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1188 <Writen+0x68>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
add    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
sub    -0x20(%rbp),%rdx
call   1030 <Write@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    114d <Writen+0x2d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Writen>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %edi,%r15d
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
test   %rbx,%rbx
je     116a <Writen+0x4a>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbp,1),%rsi
mov    %rbx,%rdx
sub    %rbp,%rdx
mov    %r15d,%edi
call   1030 <Write@plt>
add    %rax,%rbp
cmp    %rbx,%rbp
jb     1150 <Writen+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @Writen(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i64 0, i64* %7
%9 = load i8*, i8** %5
%10 = icmp ne i8* %9, null
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
br label %13
13: ; preds = %17, %3
%14 = load i64, i64* %7
%15 = load i64, i64* %6
%16 = icmp ult i64 %14, %15
br i1 %16, label %17, label %29
17: ; preds = %13
%18 = load i32, i32* %4
%19 = load i8*, i8** %5
%20 = load i64, i64* %7
%21 = getelementptr i8, i8* %19, i64 %20
%22 = load i64, i64* %6
%23 = load i64, i64* %7
%24 = sub i64 %22, %23
%25 = call i64 @Write(i32 %18, i8* %21, i64 %24)
store i64 %25, i64* %8
%26 = load i64, i64* %8
%27 = load i64, i64* %7
%28 = add i64 %27, %26
store i64 %28, i64* %7
br label %13
29: ; preds = %13
ret void
}

LLVM IR (-O2):
define void @Writen(i32 %0, i8* %1, i64 %2) {
%4 = icmp ne i8* %1, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp eq i64 %2, 0
br i1 %7, label %15, label %8
8: ; preds = %3, %8
%9 = phi i64 [ %13, %8 ], [ 0, %3 ]
%10 = getelementptr i8, i8* %1, i64 %9
%11 = sub i64 %2, %9
%12 = tail call i64 @Write(i32 %0, i8* %10, i64 %11)
%13 = add i64 %12, %9
%14 = icmp ult i64 %13, %2
br i1 %14, label %8, label %15
15: ; preds = %8, %3
ret void
}