#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 /*<<< orphan*/ utf8catcodepoint(void *, int, int);
void *utf8codepoint(void *, int *);
void utf8upr(void *__restrict__ str) {
  void *p, *pn;
  int cp;
  p = (char *)str;
  pn = utf8codepoint(p, &cp);
  while (cp != 0) {
    if (('a' <= cp) && ('z' >= cp)) {
      cp &= ~0x20;
      utf8catcodepoint(p, cp, 1);
    }
    p = pn;
    pn = utf8codepoint(p, &cp);
  }
}


x86 assembly (clang, -O0):
<utf8upr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <utf8codepoint@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11a3 <utf8upr+0x83>
mov    $0x61,%eax
cmp    -0x1c(%rbp),%eax
jg     1185 <utf8upr+0x65>
mov    $0x7a,%eax
cmp    -0x1c(%rbp),%eax
jl     1185 <utf8upr+0x65>
mov    -0x1c(%rbp),%eax
and    $0xffffffdf,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x1,%edx
call   1030 <utf8catcodepoint@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <utf8codepoint@plt>
mov    %rax,-0x18(%rbp)
jmp    1145 <utf8upr+0x25>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8upr>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rsi
call   1040 <utf8codepoint@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1187 <utf8upr+0x67>
lea    0xc(%rsp),%r14
jmp    1166 <utf8upr+0x46>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <utf8codepoint@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rbx
test   %esi,%esi
je     1187 <utf8upr+0x67>
mov    %rax,%r15
lea    -0x61(%rsi),%eax
cmp    $0x19,%eax
ja     1150 <utf8upr+0x30>
and    $0xffffffdf,%esi
mov    %esi,0xc(%rsp)
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <utf8catcodepoint@plt>
jmp    1150 <utf8upr+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @utf8upr(i8* noalias %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @utf8codepoint(i8* %7, i32* %5)
store i8* %8, i8** %4
br label %9
9: ; preds = %24, %1
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32, i32* %5
%14 = icmp sle i32 97, %13
br i1 %14, label %15, label %24
15: ; preds = %12
%16 = load i32, i32* %5
%17 = icmp sge i32 122, %16
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* %5
%20 = and i32 %19, -33
store i32 %20, i32* %5
%21 = load i8*, i8** %3
%22 = load i32, i32* %5
%23 = call i32 @utf8catcodepoint(i8* %21, i32 %22, i32 1)
br label %24
24: ; preds = %18, %15, %12
%25 = load i8*, i8** %4
store i8* %25, i8** %3
%26 = load i8*, i8** %3
%27 = call i8* @utf8codepoint(i8* %26, i32* %5)
store i8* %27, i8** %4
br label %9
28: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @utf8upr(i8* noalias %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i8* @utf8codepoint(i8* %0, i32* %2)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %20, label %7
7: ; preds = %1, %16
%8 = phi i32 [ %18, %16 ], [ %5, %1 ]
%9 = phi i8* [ %17, %16 ], [ %4, %1 ]
%10 = phi i8* [ %9, %16 ], [ %0, %1 ]
%11 = add i32 %8, -97
%12 = icmp ult i32 %11, 26
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = and i32 %8, -33
store i32 %14, i32* %2
%15 = call i32 @utf8catcodepoint(i8* %10, i32 %14, i32 1)
br label %16
16: ; preds = %13, %7
%17 = call i8* @utf8codepoint(i8* %9, i32* %2)
%18 = load i32, i32* %2
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %7
20: ; preds = %16, %1
ret void
}