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

/* Variables and functions */
const char *utf8_prev_char(const char *string_start, const char *string) {
  if (!string || (string <= string_start))
    return NULL;
  string--;
  if (((unsigned char)(string[0]) & 0xC0) == 0x80) {
    string--;
    if (string < string_start)
      return (char *)string + 1;
    if (((unsigned char)(string[0]) & 0xC0) == 0x80) {
      string--;
      if (string < string_start)
        return (char *)string + 1;
      if (((unsigned char)(string[0]) & 0xC0) == 0x80) {
        string--;
        if (string < string_start)
          return (char *)string + 1;
        return (char *)string;
      } else
        return (char *)string;
    } else
      return (char *)string;
  }
  return (char *)string;
}


x86 assembly (clang, -O0):
<utf8_prev_char>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1125 <utf8_prev_char+0x25>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     1132 <utf8_prev_char+0x32>
movq   $0x0,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    122b <utf8_prev_char+0x12b>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1180 <utf8_prev_char+0x80>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    121e <utf8_prev_char+0x11e>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11c2 <utf8_prev_char+0xc2>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
and    $0xc0,%eax
cmp    $0x80,%eax
jne    1211 <utf8_prev_char+0x111>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1204 <utf8_prev_char+0x104>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1233 <utf8_prev_char+0x133>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_prev_char>:
cmp    %rdi,%rsi
jbe    111e <utf8_prev_char+0x1e>
lea    -0x1(%rsi),%rax
mov    -0x1(%rsi),%cl
and    $0xc0,%cl
cmp    $0x80,%cl
jne    111d <utf8_prev_char+0x1d>
lea    -0x2(%rsi),%rdx
cmp    %rdi,%rdx
jae    1121 <utf8_prev_char+0x21>
ret
xor    %eax,%eax
ret
mov    (%rdx),%al
and    $0xc0,%al
cmp    $0x80,%al
jne    114c <utf8_prev_char+0x4c>
lea    -0x3(%rsi),%rcx
mov    %rdx,%rax
cmp    %rdi,%rcx
jb     111d <utf8_prev_char+0x1d>
mov    (%rcx),%al
and    $0xc0,%al
cmp    $0x80,%al
jne    1150 <utf8_prev_char+0x50>
add    $0xfffffffffffffffc,%rsi
cmp    %rdi,%rsi
cmovb  %rcx,%rsi
mov    %rsi,%rax
ret
mov    %rdx,%rax
ret
mov    %rcx,%rax
ret

LLVM IR (-O0):
define i8* @utf8_prev_char(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = load i8*, i8** %4
%11 = icmp ule i8* %9, %10
br i1 %11, label %12, label %13
12: ; preds = %8, %2
store i8* null, i8** %3
br label %71
13: ; preds = %8
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i32 -1
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = and i32 %19, 192
%21 = icmp eq i32 %20, 128
br i1 %21, label %22, label %69
22: ; preds = %13
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %5
%25 = load i8*, i8** %5
%26 = load i8*, i8** %4
%27 = icmp ult i8* %25, %26
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %30, i8** %3
br label %71
31: ; preds = %22
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = and i32 %35, 192
%37 = icmp eq i32 %36, 128
br i1 %37, label %38, label %67
38: ; preds = %31
%39 = load i8*, i8** %5
%40 = getelementptr inbounds i8, i8* %39, i32 -1
store i8* %40, i8** %5
%41 = load i8*, i8** %5
%42 = load i8*, i8** %4
%43 = icmp ult i8* %41, %42
br i1 %43, label %44, label %47
44: ; preds = %38
%45 = load i8*, i8** %5
%46 = getelementptr inbounds i8, i8* %45, i64 1
store i8* %46, i8** %3
br label %71
47: ; preds = %38
%48 = load i8*, i8** %5
%49 = getelementptr inbounds i8, i8* %48, i64 0
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
%52 = and i32 %51, 192
%53 = icmp eq i32 %52, 128
br i1 %53, label %54, label %65
54: ; preds = %47
%55 = load i8*, i8** %5
%56 = getelementptr inbounds i8, i8* %55, i32 -1
store i8* %56, i8** %5
%57 = load i8*, i8** %5
%58 = load i8*, i8** %4
%59 = icmp ult i8* %57, %58
br i1 %59, label %60, label %63
60: ; preds = %54
%61 = load i8*, i8** %5
%62 = getelementptr inbounds i8, i8* %61, i64 1
store i8* %62, i8** %3
br label %71
63: ; preds = %54
%64 = load i8*, i8** %5
store i8* %64, i8** %3
br label %71
65: ; preds = %47
%66 = load i8*, i8** %5
store i8* %66, i8** %3
br label %71
67: ; preds = %31
%68 = load i8*, i8** %5
store i8* %68, i8** %3
br label %71
69: ; preds = %13
%70 = load i8*, i8** %5
store i8* %70, i8** %3
br label %71
71: ; preds = %69, %67, %65, %63, %60, %44, %28, %12
%72 = load i8*, i8** %3
ret i8* %72
}

LLVM IR (-O2):
define i8* @utf8_prev_char(i8* readnone %0, i8* %1) {
%3 = icmp ugt i8* %1, %0
br i1 %3, label %4, label %27
4: ; preds = %2
%5 = getelementptr inbounds i8, i8* %1, i64 -1
%6 = load i8, i8* %5
%7 = and i8 %6, -64
%8 = icmp eq i8 %7, -128
br i1 %8, label %9, label %27
9: ; preds = %4
%10 = getelementptr inbounds i8, i8* %1, i64 -2
%11 = icmp ult i8* %10, %0
br i1 %11, label %27, label %12
12: ; preds = %9
%13 = load i8, i8* %10
%14 = and i8 %13, -64
%15 = icmp eq i8 %14, -128
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %1, i64 -3
%18 = icmp ult i8* %17, %0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = load i8, i8* %17
%21 = and i8 %20, -64
%22 = icmp eq i8 %21, -128
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = getelementptr inbounds i8, i8* %1, i64 -4
%25 = icmp ult i8* %24, %0
%26 = select i1 %25, i8* %17, i8* %24
br label %27
27: ; preds = %16, %9, %23, %4, %12, %19, %2
%28 = phi i8* [ null, %2 ], [ %17, %19 ], [ %10, %12 ], [ %5, %4 ], [ %26, %23 ], [ %5, %9 ], [ %10, %16 ]
ret i8* %28
}