#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 /*<<< orphan*/ wchar_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
char *get_unicode_from(char *);
int /*<<< orphan*/ str2uni(char *);
int de_unicode(FILE *fd, char *str) {
  wchar_t u_ch;
  unsigned int count = 0;
  char *begin = get_unicode_from(str);
  while ((u_ch = str2uni(get_unicode_from(begin))) != 0) {
    fprintf(fd, "%lc", u_ch);
    begin += 6;
    count++;
  }
  return count;
}


x86 assembly (clang, -O0):
<de_unicode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <get_unicode_from@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <get_unicode_from@plt>
mov    %rax,%rdi
call   1050 <str2uni@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     119e <de_unicode+0x6e>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe81(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x6,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <de_unicode+0x24>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<de_unicode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <get_unicode_from@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <get_unicode_from@plt>
mov    %rax,%rdi
call   1050 <str2uni@plt>
test   %eax,%eax
je     119a <de_unicode+0x6a>
add    $0x6,%rbx
xor    %ebp,%ebp
lea    0xe9a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
add    $0x1,%ebp
mov    %rbx,%rdi
call   1040 <get_unicode_from@plt>
mov    %rax,%rdi
call   1050 <str2uni@plt>
add    $0x6,%rbx
test   %eax,%eax
jne    1170 <de_unicode+0x40>
jmp    119c <de_unicode+0x6c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lc\00"
define i32 @de_unicode(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32 0, i32* %6
%8 = load i8*, i8** %4
%9 = call i8* @get_unicode_from(i8* %8)
store i8* %9, i8** %7
br label %10
10: ; preds = %15, %2
%11 = load i8*, i8** %7
%12 = call i8* @get_unicode_from(i8* %11)
%13 = call i32 @str2uni(i8* %12)
store i32 %13, i32* %5
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = call i32 @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 6
store i8* %20, i8** %7
%21 = load i32, i32* %6
%22 = add i32 %21, 1
store i32 %22, i32* %6
br label %10
23: ; preds = %10
%24 = load i32, i32* %6
ret i32 %24
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lc\00"
define i32 @de_unicode(i32* nocapture %0, i8* %1) {
%3 = tail call i8* @get_unicode_from(i8* %1)
%4 = tail call i8* @get_unicode_from(i8* %3)
%5 = tail call i32 @str2uni(i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %2, %7
%8 = phi i32 [ %15, %7 ], [ %5, %2 ]
%9 = phi i8* [ %12, %7 ], [ %3, %2 ]
%10 = phi i32 [ %13, %7 ], [ 0, %2 ]
%11 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%12 = getelementptr inbounds i8, i8* %9, i64 6
%13 = add i32 %10, 1
%14 = tail call i8* @get_unicode_from(i8* %12)
%15 = tail call i32 @str2uni(i8* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %2
%18 = phi i32 [ 0, %2 ], [ %13, %7 ]
ret i32 %18
}