#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 EOF;
scalar_t__ getCharset();
char *getUnicodeCell(unsigned char, int /*<<< orphan*/);
int convertWcharToChar(unsigned char wc) {
  if (getCharset()) {
    char *cell = getUnicodeCell(wc, 0);
    if (cell)
      if (*cell || !wc)
        return *cell & 0XFF;
  }
  return EOF;
}


x86 assembly (clang, -O0):
<convertWcharToChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1040 <getCharset@plt>
cmp    $0x0,%rax
je     1191 <convertWcharToChar+0x71>
xor    %esi,%esi
movzbl -0x5(%rbp),%edi
call   1030 <getUnicodeCell@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118c <convertWcharToChar+0x6c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1173 <convertWcharToChar+0x53>
cmpb   $0x0,-0x5(%rbp)
jne    1187 <convertWcharToChar+0x67>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
mov    %eax,-0x4(%rbp)
jmp    119d <convertWcharToChar+0x7d>
jmp    118c <convertWcharToChar+0x6c>
jmp    1191 <convertWcharToChar+0x71>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertWcharToChar>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <getCharset@plt>
test   %rax,%rax
je     114b <convertWcharToChar+0x2b>
movzbl %bl,%edi
xor    %esi,%esi
call   1030 <getUnicodeCell@plt>
test   %rax,%rax
je     114b <convertWcharToChar+0x2b>
mov    (%rax),%cl
movzbl %cl,%eax
test   %bl,%bl
je     1154 <convertWcharToChar+0x34>
test   %cl,%cl
jne    1154 <convertWcharToChar+0x34>
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @convertWcharToChar(i8 zeroext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i8*
store i8 %0, i8* %3
%5 = call i64 (...) @getCharset()
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %27
7: ; preds = %1
%8 = load i8, i8* %3
%9 = call i8* @getUnicodeCell(i8 zeroext %8, i32 0)
store i8* %9, i8** %4
%10 = load i8*, i8** %4
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %26
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i8, i8* %3
%19 = icmp ne i8 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %17, %12
%21 = load i8*, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = and i32 %23, 255
store i32 %24, i32* %2
br label %29
25: ; preds = %17
br label %26
26: ; preds = %25, %7
br label %27
27: ; preds = %26, %1
%28 = load i32, i32* @EOF
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %20
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @convertWcharToChar(i8 zeroext %0) {
%2 = tail call i64 (...) @getCharset()
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i8* @getUnicodeCell(i8 zeroext %0, i32 0)
%6 = icmp eq i8* %5, null
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
%10 = icmp ne i8 %0, 0
%11 = and i1 %10, %9
%12 = zext i8 %8 to i32
br i1 %11, label %13, label %15
13: ; preds = %7, %4, %1
%14 = load i32, i32* @EOF
br label %15
15: ; preds = %7, %13
%16 = phi i32 [ %14, %13 ], [ %12, %7 ]
ret i32 %16
}