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

/* Variables and functions */
int /*<<< orphan*/ __chk_fail();
scalar_t__ __glibc_unlikely(int);
size_t __wcsnrtombs(char *, int /*<<< orphan*/ const **, size_t, size_t,
                    int /*<<< orphan*/ *);
size_t __wcsnrtombs_chk(char *dst, const wchar_t **src, size_t nwc, size_t len,
                        mbstate_t *ps, size_t dstlen) {
  if (__glibc_unlikely(dstlen < len))
    __chk_fail();
  return __wcsnrtombs(dst, src, nwc, len, ps);
}


x86 assembly (clang, -O0):
<__wcsnrtombs_chk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <__glibc_unlikely@plt>
cmp    $0x0,%rax
je     1176 <__wcsnrtombs_chk+0x46>
mov    $0x0,%al
call   1030 <__chk_fail@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1050 <__wcsnrtombs@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__wcsnrtombs_chk>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %edi,%edi
cmp    %rcx,%r9
setb   %dil
call   1040 <__glibc_unlikely@plt>
test   %rax,%rax
je     1162 <__wcsnrtombs_chk+0x32>
xor    %eax,%eax
call   1030 <__chk_fail@plt>
mov    %r13,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %rbx,%rcx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <__wcsnrtombs@plt>

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

LLVM IR (-O2):
define i64 @__wcsnrtombs_chk(i8* %0, i32** %1, i64 %2, i64 %3, i32* %4, i64 %5) {
%7 = icmp ult i64 %5, %3
%8 = zext i1 %7 to i32
%9 = tail call i64 @__glibc_unlikely(i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = tail call i32 (...) @__chk_fail()
br label %13
13: ; preds = %11, %6
%14 = tail call i64 @__wcsnrtombs(i8* %0, i32** %1, i64 %2, i64 %3, i32* %4)
ret i64 %14
}