#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 char uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(char *);
scalar_t__ unicode_is_valid_code_point(char);
char unicode_reverse_codepoint_utf32(char, int);
int unicode_read_utf32_imp(char *string, uint32_t *code_point, bool reverse) {
  assert(string);
  assert(code_point);
  *code_point = unicode_reverse_codepoint_utf32(*(uint32_t *)string, reverse);
  if (unicode_is_valid_code_point(*code_point))
    return 4;
  else
    return -4;
}


x86 assembly (clang, -O0):
<unicode_read_utf32_imp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x1c(%rbp),%esi
movsbl %al,%edi
call   1040 <unicode_reverse_codepoint_utf32@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <unicode_is_valid_code_point@plt>
cmp    $0x0,%rax
je     1190 <unicode_read_utf32_imp+0x60>
movl   $0x4,-0x4(%rbp)
jmp    1197 <unicode_read_utf32_imp+0x67>
movl   $0xfffffffc,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicode_read_utf32_imp>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <assert@plt>
mov    %rbx,%rdi
call   1030 <assert@plt>
movsbl 0x0(%rbp),%edi
mov    %r14d,%esi
call   1040 <unicode_reverse_codepoint_utf32@plt>
mov    %al,(%rbx)
movsbl %al,%edi
call   1050 <unicode_is_valid_code_point@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    -0x4(,%rcx,8),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @unicode_read_utf32_imp(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i8*, i8** %5
%9 = call i32 @assert(i8* %8)
%10 = load i8*, i8** %6
%11 = call i32 @assert(i8* %10)
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = load i32, i32* %7
%15 = call signext i8 @unicode_reverse_codepoint_utf32(i8 signext %13, i32 %14)
%16 = load i8*, i8** %6
store i8 %15, i8* %16
%17 = load i8*, i8** %6
%18 = load i8, i8* %17
%19 = call i64 @unicode_is_valid_code_point(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %3
store i32 4, i32* %4
br label %23
22: ; preds = %3
store i32 -4, i32* %4
br label %23
23: ; preds = %22, %21
%24 = load i32, i32* %4
ret i32 %24
}

LLVM IR (-O2):
define i32 @unicode_read_utf32_imp(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @assert(i8* %1)
%6 = load i8, i8* %0
%7 = tail call signext i8 @unicode_reverse_codepoint_utf32(i8 signext %6, i32 %2)
store i8 %7, i8* %1
%8 = tail call i64 @unicode_is_valid_code_point(i8 signext %7)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i32 -4, i32 4
ret i32 %10
}