#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 uint8_t;
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ putchar(int);
void print_unicode(const uint8_t *ptr, int len) {
  uint16_t c;
  for (; len > 1; ptr += 2, len -= 2) {
    c = ptr[0] | (ptr[1] << 8);
    putchar((c >= 0x20 && c <= 0x7E) ? c : '?');
  }
}


x86 assembly (clang, -O0):
<print_unicode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    118c <print_unicode+0x7c>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jl     115d <print_unicode+0x4d>
cmpl   $0x7e,-0x10(%rbp)
jg     115d <print_unicode+0x4d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    116a <print_unicode+0x5a>
mov    $0x3f,%eax
mov    %eax,-0x14(%rbp)
jmp    116a <print_unicode+0x5a>
mov    -0x14(%rbp),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    111f <print_unicode+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_unicode>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%esi
jl     1158 <print_unicode+0x48>
mov    %esi,%ebp
mov    %rdi,%rbx
add    $0x2,%ebp
jmp    1141 <print_unicode+0x31>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
call   1030 <putchar@plt>
add    $0xfffffffe,%ebp
add    $0x8,%rbx
cmp    $0x3,%ebp
jbe    1158 <print_unicode+0x48>
mov    0x4(%rbx),%edi
shl    $0x8,%edi
or     (%rbx),%edi
lea    -0x20(%rdi),%eax
cmp    $0x5f,%eax
jb     1130 <print_unicode+0x20>
mov    $0x3f,%edi
jmp    1130 <print_unicode+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @print_unicode(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
br label %6
6: ; preds = %29, %2
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %34
9: ; preds = %6
%10 = load i32*, i32** %3
%11 = getelementptr inbounds i32, i32* %10, i64 0
%12 = load i32, i32* %11
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = shl i32 %15, 8
%17 = or i32 %12, %16
store i32 %17, i32* %5
%18 = load i32, i32* %5
%19 = icmp sge i32 %18, 32
br i1 %19, label %20, label %25
20: ; preds = %9
%21 = load i32, i32* %5
%22 = icmp sle i32 %21, 126
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* %5
br label %26
25: ; preds = %20, %9
br label %26
26: ; preds = %25, %23
%27 = phi i32 [ %24, %23 ], [ 63, %25 ]
%28 = call i32 @putchar(i32 %27)
br label %29
29: ; preds = %26
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 2
store i32* %31, i32** %3
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 2
store i32 %33, i32* %4
br label %6
34: ; preds = %6
ret void
}

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