#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*/ MB_CUR_MAX;
int mblen(char *, int /*<<< orphan*/);
scalar_t__ toupper(unsigned char);
void _DtHelpCeUpperCase(char *string) {
  int len;
  if (string) {
    while (*string != '\0') {
      len = mblen(string, MB_CUR_MAX);
      if (len == 1) {
        *string = (unsigned char)toupper(*(unsigned char *)string);
        string++;
      } else if (len > 0)
        string += len;
      else
        return;
    }
  }
}


x86 assembly (clang, -O0):
<_DtHelpCeUpperCase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11c4 <_DtHelpCeUpperCase+0xa4>
jmp    113c <_DtHelpCeUpperCase+0x1c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bf <_DtHelpCeUpperCase+0x9f>
mov    -0x8(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
call   1030 <mblen@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    1190 <_DtHelpCeUpperCase+0x70>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11ba <_DtHelpCeUpperCase+0x9a>
cmpl   $0x0,-0xc(%rbp)
jle    11b0 <_DtHelpCeUpperCase+0x90>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11b5 <_DtHelpCeUpperCase+0x95>
jmp    11c4 <_DtHelpCeUpperCase+0xa4>
jmp    11ba <_DtHelpCeUpperCase+0x9a>
jmp    113c <_DtHelpCeUpperCase+0x1c>
jmp    11c4 <_DtHelpCeUpperCase+0xa4>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_DtHelpCeUpperCase>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     116f <_DtHelpCeUpperCase+0x4f>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     116f <_DtHelpCeUpperCase+0x4f>
mov    0x2ec0(%rip),%r14
jmp    1159 <_DtHelpCeUpperCase+0x39>
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%edi
call   1040 <toupper@plt>
mov    %al,(%rbx)
mov    $0x1,%eax
cmpb   $0x0,(%rbx,%rax,1)
lea    (%rbx,%rax,1),%rbx
je     116f <_DtHelpCeUpperCase+0x4f>
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <mblen@plt>
cmp    $0x1,%eax
je     1140 <_DtHelpCeUpperCase+0x20>
jl     116f <_DtHelpCeUpperCase+0x4f>
mov    %eax,%eax
jmp    114f <_DtHelpCeUpperCase+0x2f>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@MB_CUR_MAX = global i32 0
define void @_DtHelpCeUpperCase(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %38
6: ; preds = %1
br label %7
7: ; preds = %36, %6
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %37
12: ; preds = %7
%13 = load i8*, i8** %2
%14 = load i32, i32* @MB_CUR_MAX
%15 = call i32 @mblen(i8* %13, i32 %14)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %26
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = load i8, i8* %19
%21 = call i64 @toupper(i8 zeroext %20)
%22 = trunc i64 %21 to i8
%23 = load i8*, i8** %2
store i8 %22, i8* %23
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %2
br label %36
26: ; preds = %12
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load i32, i32* %3
%31 = load i8*, i8** %2
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds i8, i8* %31, i64 %32
store i8* %33, i8** %2
br label %35
34: ; preds = %26
br label %38
35: ; preds = %29
br label %36
36: ; preds = %35, %18
br label %7
37: ; preds = %7
br label %38
38: ; preds = %34, %37, %1
ret void
}

LLVM IR (-O2):
@MB_CUR_MAX = global i32 0
define void @_DtHelpCeUpperCase(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %24, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %24, label %6
6: ; preds = %3, %19
%7 = phi i8* [ %21, %19 ], [ %0, %3 ]
%8 = load i32, i32* @MB_CUR_MAX
%9 = tail call i32 @mblen(i8* %7, i32 %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = load i8, i8* %7
%13 = tail call i64 @toupper(i8 zeroext %12)
%14 = trunc i64 %13 to i8
store i8 %14, i8* %7
br label %19
15: ; preds = %6
%16 = icmp sgt i32 %9, 0
br i1 %16, label %17, label %24
17: ; preds = %15
%18 = zext i32 %9 to i64
br label %19
19: ; preds = %17, %11
%20 = phi i64 [ %18, %17 ], [ 1, %11 ]
%21 = getelementptr inbounds i8, i8* %7, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 0
br i1 %23, label %24, label %6
24: ; preds = %15, %19, %3, %1
ret void
}