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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printWideString(uint8_t *s, unsigned int length) {
  if (length == 0)
    return;
  for (int offset = 0; offset < length - 2; offset += 2) {
    wchar_t wc = (s[offset] << 8) | (s[offset + 1]);
    printf("%lc", wc);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printWideString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    112e <printWideString+0x1e>
jmp    1194 <printWideString+0x84>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jae    1186 <printWideString+0x76>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
shl    $0x8,%eax
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
or     (%rcx,%rdx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
jmp    1135 <printWideString+0x25>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printWideString>:
test   %esi,%esi
je     1174 <printWideString+0x54>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
add    $0xfffffffe,%esi
je     115f <printWideString+0x3f>
mov    %rdi,%r12
mov    %esi,%r15d
lea    0xec2(%rip),%r14
xor    %ebx,%ebx
mov    (%r12,%rbx,4),%esi
shl    $0x8,%esi
or     0x4(%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x2,%rbx
cmp    %r15,%rbx
jb     1140 <printWideString+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lc\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @printWideString(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
br label %37
10: ; preds = %2
store i32 0, i32* %5
br label %11
11: ; preds = %32, %10
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = sub i32 %13, 2
%15 = icmp ult i32 %12, %14
br i1 %15, label %16, label %35
16: ; preds = %11
%17 = load i32*, i32** %3
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = shl i32 %21, 8
%23 = load i32*, i32** %3
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = load i32, i32* %27
%29 = or i32 %22, %28
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %16
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 2
store i32 %34, i32* %5
br label %11
35: ; preds = %11
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %9
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lc\00"
define void @printWideString(i32* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %23, label %4
4: ; preds = %2
%5 = add i32 %1, -2
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = zext i32 %5 to i64
br label %11
9: ; preds = %11, %4
%10 = tail call i32 @putchar(i32 10)
br label %23
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %21, %11 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = load i32, i32* %13
%15 = shl i32 %14, 8
%16 = or i64 %12, 1
%17 = getelementptr inbounds i32, i32* %0, i64 %16
%18 = load i32, i32* %17
%19 = or i32 %15, %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = add nuw nsw i64 %12, 2
%22 = icmp ult i64 %21, %8
br i1 %22, label %11, label %9
23: ; preds = %2, %9
ret void
}