#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 */
scalar_t__ iscntrl(char);
int /*<<< orphan*/ mvaddch(int, int /*<<< orphan*/, char);
int MvAddStr(int y, int x, char *str) {
  for (; *str != '\0'; str++)
    mvaddch(y, x++,
            (iscntrl(*str) && (((unsigned char)(*str)) < ' '))
                ? ('?')
                : ((unsigned char)(*str)));
  return 0;
}


x86 assembly (clang, -O0):
<MvAddStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b3 <MvAddStr+0x93>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%rax
je     1187 <MvAddStr+0x67>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jge    1187 <MvAddStr+0x67>
mov    $0x3f,%eax
mov    %eax,-0x1c(%rbp)
jmp    1191 <MvAddStr+0x71>
mov    -0x10(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%eax
movsbl %al,%edx
call   1040 <mvaddch@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1132 <MvAddStr+0x12>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MvAddStr>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%rdx),%al
test   %al,%al
je     117a <MvAddStr+0x5a>
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %edi,%r14d
add    $0x1,%rbx
mov    $0x3f,%r15d
lea    0x1(%rbp),%r12d
movsbl %al,%edi
call   1030 <iscntrl@plt>
movzbl -0x1(%rbx),%ecx
cmp    $0x20,%cl
mov    %ecx,%edx
cmovb  %r15d,%edx
test   %rax,%rax
cmove  %ecx,%edx
movsbl %dl,%edx
mov    %r14d,%edi
mov    %ebp,%esi
call   1040 <mvaddch@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
mov    %r12d,%ebp
test   %al,%al
jne    1140 <MvAddStr+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @MvAddStr(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
br label %7
7: ; preds = %34, %3
%8 = load i8*, i8** %6
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %7
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %5
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = call i64 @iscntrl(i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %12
%21 = load i8*, i8** %6
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp slt i32 %23, 32
br i1 %24, label %25, label %26
25: ; preds = %20
br label %30
26: ; preds = %20, %12
%27 = load i8*, i8** %6
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
br label %30
30: ; preds = %26, %25
%31 = phi i32 [ 63, %25 ], [ %29, %26 ]
%32 = trunc i32 %31 to i8
%33 = call i32 @mvaddch(i32 %13, i32 %14, i8 signext %32)
br label %34
34: ; preds = %30
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %6
br label %7
37: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
define i32 @MvAddStr(i32 %0, i32 %1, i8* nocapture %2) {
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3, %6
%7 = phi i8 [ %19, %6 ], [ %4, %3 ]
%8 = phi i8* [ %18, %6 ], [ %2, %3 ]
%9 = phi i32 [ %10, %6 ], [ %1, %3 ]
%10 = add nsw i32 %9, 1
%11 = tail call i64 @iscntrl(i8 signext %7)
%12 = icmp ne i64 %11, 0
%13 = load i8, i8* %8
%14 = icmp ult i8 %13, 32
%15 = select i1 %12, i1 %14, i1 false
%16 = select i1 %15, i8 63, i8 %13
%17 = tail call i32 @mvaddch(i32 %0, i32 %9, i8 signext %16)
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %6
21: ; preds = %6, %3
ret i32 0
}