#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 len(char *);
int /*<<< orphan*/ printf(char *, char *);
void convertToUpper(char a[]) {
  int i, l;
  l = len(a);
  for (i = 0; a[i] != '\0'; i++) {
    if (a[i] >= 'a' && a[i] <= 'z')
      a[i] = a[i] - 32;
  }
  printf("After Converting to Upper Case: %s\n", a);
}


x86 assembly (clang, -O0):
<convertToUpper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <len@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11ad <convertToUpper+0x8d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x61,%eax
jl     119a <convertToUpper+0x7a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x7a,%eax
jg     119a <convertToUpper+0x7a>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x20,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
jmp    119f <convertToUpper+0x7f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113f <convertToUpper+0x1f>
mov    -0x8(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertToUpper>:
push   %rbx
mov    %rdi,%rbx
call   1030 <len@plt>
mov    (%rbx),%al
test   %al,%al
je     115a <convertToUpper+0x3a>
lea    0x1(%rbx),%rcx
jmp    114b <convertToUpper+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rcx),%eax
add    $0x1,%rcx
test   %al,%al
je     115a <convertToUpper+0x3a>
lea    -0x61(%rax),%edx
cmp    $0x19,%dl
ja     1140 <convertToUpper+0x20>
add    $0xe0,%al
mov    %al,-0x1(%rcx)
jmp    1140 <convertToUpper+0x20>
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"After Converting to Upper Case: %s\0A\00"
define void @convertToUpper(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @len(i8* %5)
store i32 %6, i32* %4
store i32 0, i32* %3
br label %7
7: ; preds = %45, %1
%8 = load i8*, i8** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %8, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %48
15: ; preds = %7
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp sge i32 %21, 97
br i1 %22, label %23, label %44
23: ; preds = %15
%24 = load i8*, i8** %2
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 122
br i1 %30, label %31, label %44
31: ; preds = %23
%32 = load i8*, i8** %2
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 32
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %2
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
store i8 %39, i8* %43
br label %44
44: ; preds = %31, %23, %15
br label %45
45: ; preds = %44
%46 = load i32, i32* %3
%47 = add nsw i32 %46, 1
store i32 %47, i32* %3
br label %7
48: ; preds = %7
%49 = load i8*, i8** %2
%50 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %49)
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"After Converting to Upper Case: %s\0A\00"
define void @convertToUpper(i8* %0) {
%2 = tail call i32 @len(i8* %0)
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %18, label %5
5: ; preds = %1, %13
%6 = phi i64 [ %14, %13 ], [ 0, %1 ]
%7 = phi i8 [ %16, %13 ], [ %3, %1 ]
%8 = phi i8* [ %15, %13 ], [ %0, %1 ]
%9 = add i8 %7, -97
%10 = icmp ult i8 %9, 26
br i1 %10, label %11, label %13
11: ; preds = %5
%12 = add nsw i8 %7, -32
store i8 %12, i8* %8
br label %13
13: ; preds = %5, %11
%14 = add nuw i64 %6, 1
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %5
18: ; preds = %13, %1
%19 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0)
ret void
}