#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__ wchar_t;

/* Variables and functions */
scalar_t__ malloc(int);
int strlen(char const *);
wchar_t *fakeUnicode(const char *ps, int *bytes) {
  wchar_t *r, *pw;
  int len = strlen(ps) + 1;
  pw = r = (wchar_t *)malloc(sizeof(wchar_t) * len);
  if (bytes)
    *bytes = len * sizeof(wchar_t);
  while (*ps) {
    if (*ps == '\n')
      *pw = (wchar_t)0x2028;
    else if (*ps == '\r')
      *pw = (wchar_t)0x2029;
    else
      *pw = (wchar_t)(unsigned char)*ps;
    ps++;
    pw++;
  }
  *pw = (wchar_t)0;
  return r;
}


x86 assembly (clang, -O0):
<fakeUnicode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1171 <fakeUnicode+0x51>
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1176 <fakeUnicode+0x56>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11f5 <fakeUnicode+0xd5>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    11a3 <fakeUnicode+0x83>
mov    -0x20(%rbp),%rax
movq   $0x2028,(%rax)
jmp    11d8 <fakeUnicode+0xb8>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    11c3 <fakeUnicode+0xa3>
mov    -0x20(%rbp),%rax
movq   $0x2029,(%rax)
jmp    11d3 <fakeUnicode+0xb3>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
jmp    11d8 <fakeUnicode+0xb8>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
jmp    1176 <fakeUnicode+0x56>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fakeUnicode>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    0x8(,%rax,8),%ebp
mov    %ebp,%edi
call   1040 <malloc@plt>
test   %r14,%r14
je     1145 <fakeUnicode+0x25>
mov    %ebp,(%r14)
xor    %ecx,%ecx
jmp    115d <fakeUnicode+0x3d>
nopl   0x0(%rax)
mov    $0x2029,%edx
mov    %rdx,(%rax,%rcx,8)
add    $0x1,%rcx
movzbl (%rbx,%rcx,1),%edx
cmp    $0xa,%rdx
je     1180 <fakeUnicode+0x60>
cmp    $0xd,%dl
je     1150 <fakeUnicode+0x30>
test   %dl,%dl
jne    1155 <fakeUnicode+0x35>
jmp    1187 <fakeUnicode+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2028,%edx
jmp    1155 <fakeUnicode+0x35>
movq   $0x0,(%rax,%rcx,8)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64* @fakeUnicode(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64*
%6 = alloca i64*
%7 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = add nsw i32 %9, 1
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = mul i64 8, %12
%14 = trunc i64 %13 to i32
%15 = call i64 @malloc(i32 %14)
%16 = inttoptr i64 %15 to i64*
store i64* %16, i64** %5
store i64* %16, i64** %6
%17 = load i32*, i32** %4
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = load i32*, i32** %4
store i32 %23, i32* %24
br label %25
25: ; preds = %19, %2
br label %26
26: ; preds = %50, %25
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %55
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i64*, i64** %6
store i64 8232, i64* %36
br label %50
37: ; preds = %30
%38 = load i8*, i8** %3
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 13
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = load i64*, i64** %6
store i64 8233, i64* %43
br label %49
44: ; preds = %37
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = zext i8 %46 to i64
%48 = load i64*, i64** %6
store i64 %47, i64* %48
br label %49
49: ; preds = %44, %42
br label %50
50: ; preds = %49, %35
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %3
%53 = load i64*, i64** %6
%54 = getelementptr inbounds i64, i64* %53, i32 1
store i64* %54, i64** %6
br label %26
55: ; preds = %26
%56 = load i64*, i64** %6
store i64 0, i64* %56
%57 = load i64*, i64** %5
ret i64* %57
}

LLVM IR (-O2):
define i64* @fakeUnicode(i8* %0, i32* writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = shl i32 %3, 3
%5 = add i32 %4, 8
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i64*
%8 = icmp eq i32* %1, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 %5, i32* %1
br label %10
10: ; preds = %9, %2
br label %11
11: ; preds = %10, %18
%12 = phi i64* [ %21, %18 ], [ %7, %10 ]
%13 = phi i8* [ %20, %18 ], [ %0, %10 ]
%14 = load i8, i8* %13
switch i8 %14, label %16 [
i8 0, label %22
i8 10, label %18
i8 13, label %15
]
15: ; preds = %11
br label %18
16: ; preds = %11
%17 = zext i8 %14 to i64
br label %18
18: ; preds = %11, %15, %16
%19 = phi i64 [ 8233, %15 ], [ %17, %16 ], [ 8232, %11 ]
store i64 %19, i64* %12
%20 = getelementptr inbounds i8, i8* %13, i64 1
%21 = getelementptr inbounds i64, i64* %12, i64 1
br label %11
22: ; preds = %11
store i64 0, i64* %12
ret i64* %7
}