#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*/ assert(char *);
char *tcstrtoupper(char *str) {
  assert(str);
  char *wp = str;
  while (*wp != '\0') {
    if (*wp >= 'a' && *wp <= 'z')
      *wp -= 'a' - 'A';
    wp++;
  }
  return str;
}


x86 assembly (clang, -O0):
<tcstrtoupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     117a <tcstrtoupper+0x6a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x61,%eax
jl     1169 <tcstrtoupper+0x59>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     1169 <tcstrtoupper+0x59>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x20,%ecx
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112d <tcstrtoupper+0x1d>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcstrtoupper>:
push   %rbx
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    (%rbx),%al
test   %al,%al
je     114a <tcstrtoupper+0x3a>
lea    0x1(%rbx),%rcx
jmp    113b <tcstrtoupper+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
je     114a <tcstrtoupper+0x3a>
lea    -0x61(%rax),%edx
cmp    $0x19,%dl
ja     1130 <tcstrtoupper+0x20>
add    $0xe0,%al
mov    %al,-0x1(%rcx)
jmp    1130 <tcstrtoupper+0x20>
mov    %rbx,%rax
pop    %rbx
ret

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

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