#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 scalar_t__ chtype;
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ _wputch(int /*<<< orphan*/ *, scalar_t__ const, int);
void _wputchstr(WINDOW *win, const chtype *chstr, int wrap, int n) {
  for (; *chstr && n--; chstr++) {
    _wputch(win, *chstr, wrap);
  }
}


x86 assembly (clang, -O0):
<_wputchstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmpq   $0x0,(%rcx)
mov    %al,-0x19(%rbp)
je     114d <_wputchstr+0x3d>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115d <_wputchstr+0x4d>
jmp    1181 <_wputchstr+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x14(%rbp),%edx
call   1030 <_wputch@plt>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    1126 <_wputchstr+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_wputchstr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r12
mov    (%rsi),%rsi
test   %rsi,%rsi
je     115f <_wputchstr+0x4f>
test   %ecx,%ecx
je     115f <_wputchstr+0x4f>
mov    %edx,%r14d
mov    %rdi,%r15
mov    %ecx,%ebp
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14d,%edx
call   1030 <_wputch@plt>
mov    (%r12,%rbx,8),%rsi
test   %rsi,%rsi
je     115f <_wputchstr+0x4f>
lea    0x1(%rbx),%rax
cmp    %ebx,%ebp
mov    %rax,%rbx
jne    1140 <_wputchstr+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @_wputchstr(i32* %0, i64* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i64* %1, i64** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
br label %9
9: ; preds = %25, %4
%10 = load i64*, i64** %6
%11 = load i64, i64* %10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %8
%15 = add nsw i32 %14, -1
store i32 %15, i32* %8
%16 = icmp ne i32 %14, 0
br label %17
17: ; preds = %13, %9
%18 = phi i1 [ false, %9 ], [ %16, %13 ]
br i1 %18, label %19, label %28
19: ; preds = %17
%20 = load i32*, i32** %5
%21 = load i64*, i64** %6
%22 = load i64, i64* %21
%23 = load i32, i32* %7
%24 = call i32 @_wputch(i32* %20, i64 %22, i32 %23)
br label %25
25: ; preds = %19
%26 = load i64*, i64** %6
%27 = getelementptr inbounds i64, i64* %26, i32 1
store i64* %27, i64** %6
br label %9
28: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @_wputchstr(i32* %0, i64* nocapture %1, i32 %2, i32 %3) {
%5 = load i64, i64* %1
%6 = icmp eq i64 %5, 0
%7 = icmp eq i32 %3, 0
%8 = or i1 %6, %7
br i1 %8, label %20, label %9
9: ; preds = %4, %9
%10 = phi i64 [ %16, %9 ], [ %5, %4 ]
%11 = phi i32 [ %13, %9 ], [ %3, %4 ]
%12 = phi i64* [ %15, %9 ], [ %1, %4 ]
%13 = add nsw i32 %11, -1
%14 = tail call i32 @_wputch(i32* %0, i64 %10, i32 %2)
%15 = getelementptr inbounds i64, i64* %12, i64 1
%16 = load i64, i64* %15
%17 = icmp eq i64 %16, 0
%18 = icmp eq i32 %13, 0
%19 = select i1 %17, i1 true, i1 %18
br i1 %19, label %20, label %9
20: ; preds = %9, %4
ret void
}