#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 my_strlen(char *);
void my_toupper(char *str) {
  if (str == NULL) {
    return;
  }
  int i;
  for (i = 0; i < my_strlen(str); i++) {
    if ((str[i] >= 'a') && (str[i] <= 'z')) {
      str[i] = str[i] & ~(1 << 5);
    }
  }
}


x86 assembly (clang, -O0):
<my_toupper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <my_toupper+0x1c>
jmp    11a8 <my_toupper+0x98>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <my_strlen@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    11a8 <my_toupper+0x98>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     1195 <my_toupper+0x85>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7a,%eax
jg     1195 <my_toupper+0x85>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
and    $0xffffffdf,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    119a <my_toupper+0x8a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <my_toupper+0x23>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_toupper>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     1158 <my_toupper+0x48>
mov    %rdi,%r14
call   1030 <my_strlen@plt>
test   %eax,%eax
jle    1158 <my_toupper+0x48>
xor    %ebx,%ebx
jmp    1143 <my_toupper+0x33>
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <my_strlen@plt>
cltq
cmp    %rax,%rbx
jge    1158 <my_toupper+0x48>
movzbl (%r14,%rbx,1),%eax
lea    -0x61(%rax),%ecx
cmp    $0x19,%cl
ja     1130 <my_toupper+0x20>
and    $0xdf,%al
mov    %al,(%r14,%rbx,1)
jmp    1130 <my_toupper+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @my_toupper(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
br label %46
7: ; preds = %1
store i32 0, i32* %3
br label %8
8: ; preds = %43, %7
%9 = load i32, i32* %3
%10 = load i8*, i8** %2
%11 = call i32 @my_strlen(i8* %10)
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %46
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp sge i32 %19, 97
br i1 %20, label %21, label %42
21: ; preds = %13
%22 = load i8*, i8** %2
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp sle i32 %27, 122
br i1 %28, label %29, label %42
29: ; preds = %21
%30 = load i8*, i8** %2
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = and i32 %35, -33
%37 = trunc i32 %36 to i8
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
store i8 %37, i8* %41
br label %42
42: ; preds = %29, %21, %13
br label %43
43: ; preds = %42
%44 = load i32, i32* %3
%45 = add nsw i32 %44, 1
store i32 %45, i32* %3
br label %8
46: ; preds = %6, %8
ret void
}

LLVM IR (-O2):
define void @my_toupper(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = tail call i32 @my_strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %19
6: ; preds = %3, %14
%7 = phi i64 [ %15, %14 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = add i8 %9, -97
%11 = icmp ult i8 %10, 26
br i1 %11, label %12, label %14
12: ; preds = %6
%13 = and i8 %9, -33
store i8 %13, i8* %8
br label %14
14: ; preds = %6, %12
%15 = add nuw nsw i64 %7, 1
%16 = tail call i32 @my_strlen(i8* %0)
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %6, label %19
19: ; preds = %14, %3, %1
ret void
}