#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ unicode_is_valid_code_point(int /*<<< orphan*/);
int /*<<< orphan*/ unicode_reverse_codepoint_utf32(int /*<<< orphan*/, int);
bool unicode_is_well_formed_utf32_imp(uint32_t *data, size_t data_length,
                                      bool reverse) {
  for (int k = 0; k < data_length; k++) {
    if (!unicode_is_valid_code_point(
            unicode_reverse_codepoint_utf32(data[k], reverse)))
      return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<unicode_is_well_formed_utf32_imp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118a <unicode_is_well_formed_utf32_imp+0x6a>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x1c(%rbp),%esi
call   1030 <unicode_reverse_codepoint_utf32@plt>
mov    %eax,%edi
call   1040 <unicode_is_valid_code_point@plt>
cmp    $0x0,%eax
jne    1177 <unicode_is_well_formed_utf32_imp+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1191 <unicode_is_well_formed_utf32_imp+0x71>
jmp    117c <unicode_is_well_formed_utf32_imp+0x5c>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113a <unicode_is_well_formed_utf32_imp+0x1a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unicode_is_well_formed_utf32_imp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     117d <unicode_is_well_formed_utf32_imp+0x5d>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
mov    (%rdi),%edi
mov    %edx,%esi
call   1030 <unicode_reverse_codepoint_utf32@plt>
mov    %eax,%edi
call   1040 <unicode_is_valid_code_point@plt>
test   %eax,%eax
je     1184 <unicode_is_well_formed_utf32_imp+0x64>
mov    $0x1,%ecx
xchg   %ax,%ax
mov    %rcx,%rbp
cmp    %rcx,%rbx
je     1173 <unicode_is_well_formed_utf32_imp+0x53>
mov    (%r15,%rbp,4),%edi
mov    %r14d,%esi
call   1030 <unicode_reverse_codepoint_utf32@plt>
mov    %eax,%edi
call   1040 <unicode_is_valid_code_point@plt>
lea    0x1(%rbp),%rcx
test   %eax,%eax
jne    1150 <unicode_is_well_formed_utf32_imp+0x30>
xor    %eax,%eax
cmp    %rbx,%rbp
setae  %al
jmp    1186 <unicode_is_well_formed_utf32_imp+0x66>
mov    $0x1,%eax
jmp    1186 <unicode_is_well_formed_utf32_imp+0x66>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @unicode_is_well_formed_utf32_imp(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %26, %3
%10 = load i32, i32* %8
%11 = sext i32 %10 to i64
%12 = load i64, i64* %6
%13 = icmp ult i64 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %9
%15 = load i32*, i32** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
%19 = load i32, i32* %18
%20 = load i32, i32* %7
%21 = call i32 @unicode_reverse_codepoint_utf32(i32 %19, i32 %20)
%22 = call i32 @unicode_is_valid_code_point(i32 %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %25, label %24
24: ; preds = %14
store i32 0, i32* %4
br label %30
25: ; preds = %14
br label %26
26: ; preds = %25
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %9
29: ; preds = %9
store i32 1, i32* %4
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %4
ret i32 %31
}

LLVM IR (-O2):
define i32 @unicode_is_well_formed_utf32_imp(i32* nocapture %0, i64 %1, i32 %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = load i32, i32* %0
%7 = tail call i32 @unicode_reverse_codepoint_utf32(i32 %6, i32 %2)
%8 = tail call i32 @unicode_is_valid_code_point(i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %23, label %10
10: ; preds = %5, %13
%11 = phi i64 [ %19, %13 ], [ 1, %5 ]
%12 = icmp eq i64 %11, %1
br i1 %12, label %20, label %13
13: ; preds = %10
%14 = getelementptr inbounds i32, i32* %0, i64 %11
%15 = load i32, i32* %14
%16 = tail call i32 @unicode_reverse_codepoint_utf32(i32 %15, i32 %2)
%17 = tail call i32 @unicode_is_valid_code_point(i32 %16)
%18 = icmp eq i32 %17, 0
%19 = add nuw i64 %11, 1
br i1 %18, label %20, label %10
20: ; preds = %10, %13
%21 = icmp uge i64 %11, %1
%22 = zext i1 %21 to i32
br label %23
23: ; preds = %20, %5, %3
%24 = phi i32 [ 1, %3 ], [ 0, %5 ], [ %22, %20 ]
ret i32 %24
}