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


x86 assembly (clang, -O0):
<AddStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1195 <AddStr+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%rax
je     116f <AddStr+0x4f>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x20,%eax
jge    116f <AddStr+0x4f>
mov    $0x3f,%eax
mov    %eax,-0xc(%rbp)
jmp    1179 <AddStr+0x59>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl %al,%edi
call   1040 <addch@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <AddStr+0xc>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<AddStr>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     116d <AddStr+0x4d>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    $0x3f,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <iscntrl@plt>
movzbl -0x1(%rbx),%ecx
cmp    $0x20,%cl
mov    %ecx,%edx
cmovb  %ebp,%edx
test   %rax,%rax
cmove  %ecx,%edx
movsbl %dl,%edi
call   1040 <addch@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <AddStr+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

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