#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;
struct output {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ ismark(int /*<<< orphan*/);
int /*<<< orphan*/ output_char(struct output *, int /*<<< orphan*/);
int /*<<< orphan*/ u_char_general_category(int /*<<< orphan*/);
int /*<<< orphan*/ u_decode(char const **, char const *, char const *);
const char *output_marks(const char *q, const char *end,
                         struct output *output) {
  while (q < end) {
    const char *r;
    uint32_t c = u_decode(&r, q, end);
    if (!ismark(u_char_general_category(c)))
      break;
    output_char(output, c);
    q = r;
  }
  return q;
}


x86 assembly (clang, -O0):
<output_marks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    11ac <output_marks+0x6c>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    -0x20(%rbp),%rdi
call   1040 <u_decode@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1060 <u_char_general_category@plt>
mov    %eax,%edi
call   1050 <ismark@plt>
cmp    $0x0,%eax
jne    1193 <output_marks+0x53>
jmp    11ac <output_marks+0x6c>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <output_char@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1154 <output_marks+0x14>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_marks>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
cmp    %rsi,%rdi
jae    1196 <output_marks+0x56>
mov    %rdx,%r14
mov    %rsi,%r15
lea    0x8(%rsp),%r12
nop
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <u_decode@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1060 <u_char_general_category@plt>
mov    %eax,%edi
call   1050 <ismark@plt>
test   %eax,%eax
je     1196 <output_marks+0x56>
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <output_char@plt>
mov    0x8(%rsp),%rbx
cmp    %r15,%rbx
jb     1160 <output_marks+0x20>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.output = type { i32 }
define i8* @output_marks(i8* %0, i8* %1, %struct.output* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.output*
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.output* %2, %struct.output** %6
br label %9
9: ; preds = %22, %3
%10 = load i8*, i8** %4
%11 = load i8*, i8** %5
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i32 @u_decode(i8** %7, i8* %14, i8* %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = call i32 @u_char_general_category(i32 %17)
%19 = call i32 @ismark(i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %13
br label %27
22: ; preds = %13
%23 = load %struct.output*, %struct.output** %6
%24 = load i32, i32* %8
%25 = call i32 @output_char(%struct.output* %23, i32 %24)
%26 = load i8*, i8** %7
store i8* %26, i8** %4
br label %9
27: ; preds = %21, %9
%28 = load i8*, i8** %4
ret i8* %28
}

LLVM IR (-O2):
%struct.output = type { i32 }
define i8* @output_marks(i8* %0, i8* %1, %struct.output* %2) {
%4 = alloca i8*
%5 = icmp ult i8* %0, %1
br i1 %5, label %6, label %19
6: ; preds = %3
%7 = bitcast i8** %4 to i8*
br label %8
8: ; preds = %6, %15
%9 = phi i8* [ %0, %6 ], [ %17, %15 ]
%10 = call i32 @u_decode(i8** %4, i8* %9, i8* %1)
%11 = call i32 @u_char_general_category(i32 %10)
%12 = call i32 @ismark(i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %8
br label %19
15: ; preds = %8
%16 = call i32 @output_char(%struct.output* %2, i32 %10)
%17 = load i8*, i8** %4
%18 = icmp ult i8* %17, %1
br i1 %18, label %8, label %19
19: ; preds = %15, %3, %14
%20 = phi i8* [ %9, %14 ], [ %0, %3 ], [ %17, %15 ]
ret i8* %20
}