#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 */
scalar_t__ utf8_next_char(char *);
void string_toupper(char *string) {
  while (string && string[0]) {
    if ((string[0] >= 'a') && (string[0] <= 'z'))
      string[0] -= ('a' - 'A');
    string = (char *)utf8_next_char(string);
  }
}


x86 assembly (clang, -O0):
<string_toupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
je     113c <string_toupper+0x2c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    114c <string_toupper+0x3c>
jmp    118a <string_toupper+0x7a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     1178 <string_toupper+0x68>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     1178 <string_toupper+0x68>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x20,%ecx
mov    %cl,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <utf8_next_char@plt>
mov    %rax,-0x8(%rbp)
jmp    111c <string_toupper+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_toupper>:
push   %rax
test   %rdi,%rdi
je     1143 <string_toupper+0x33>
mov    %rdi,%rax
jmp    112d <string_toupper+0x1d>
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1030 <utf8_next_char@plt>
test   %rax,%rax
je     1143 <string_toupper+0x33>
movzbl (%rax),%ecx
test   %cl,%cl
je     1143 <string_toupper+0x33>
lea    -0x61(%rcx),%edx
cmp    $0x19,%dl
ja     1120 <string_toupper+0x10>
add    $0xe0,%cl
mov    %cl,(%rax)
jmp    1120 <string_toupper+0x10>
pop    %rax
ret

LLVM IR (-O0):
define void @string_toupper(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
br label %3
3: ; preds = %33, %1
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br label %12
12: ; preds = %6, %3
%13 = phi i1 [ false, %3 ], [ %11, %6 ]
br i1 %13, label %14, label %37
14: ; preds = %12
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sge i32 %18, 97
br i1 %19, label %20, label %33
20: ; preds = %14
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp sle i32 %24, 122
br i1 %25, label %26, label %33
26: ; preds = %20
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 32
%32 = trunc i32 %31 to i8
store i8 %32, i8* %28
br label %33
33: ; preds = %26, %20, %14
%34 = load i8*, i8** %2
%35 = call i64 @utf8_next_char(i8* %34)
%36 = inttoptr i64 %35 to i8*
store i8* %36, i8** %2
br label %3
37: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @string_toupper(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1, %12
%4 = phi i8* [ %14, %12 ], [ %0, %1 ]
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 0
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = add i8 %5, -97
%9 = icmp ult i8 %8, 26
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = add nsw i8 %5, -32
store i8 %11, i8* %4
br label %12
12: ; preds = %10, %7
%13 = tail call i64 @utf8_next_char(i8* %4)
%14 = inttoptr i64 %13 to i8*
%15 = icmp eq i64 %13, 0
br i1 %15, label %16, label %3
16: ; preds = %3, %12, %1
ret void
}