#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 */
char *strdup(char const *);
unsigned int strlen(char *);
char *Capitalized(const char *input) {
  char *result;
  unsigned int i;
  result = strdup(input);
  if (result[0] > 90) {
    result[0] -= 32;
  }
  for (i = 1; i < strlen(result); i++) {
    if ((result[i] > 64) && (result[i] < 91)) {
      result[i] += 32;
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<Capitalized>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5a,%eax
jle    1155 <Capitalized+0x35>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
sub    $0x20,%ecx
mov    %cl,(%rax)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jae    11c4 <Capitalized+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x40,%eax
jle    11b1 <Capitalized+0x91>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5b,%eax
jge    11b1 <Capitalized+0x91>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%edx
add    $0x20,%edx
mov    %dl,(%rax,%rcx,1)
jmp    11b6 <Capitalized+0x96>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115c <Capitalized+0x3c>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Capitalized>:
push   %r14
push   %rbx
push   %rax
call   1040 <strdup@plt>
mov    %rax,%r14
mov    (%rax),%al
cmp    $0x5b,%al
jl     1137 <Capitalized+0x17>
add    $0xe0,%al
mov    %al,(%r14)
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jb     1178 <Capitalized+0x58>
mov    $0x1,%ebx
jmp    1163 <Capitalized+0x43>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jae    1178 <Capitalized+0x58>
movzbl (%r14,%rbx,1),%eax
lea    -0x41(%rax),%ecx
cmp    $0x19,%cl
ja     1150 <Capitalized+0x30>
add    $0x20,%al
mov    %al,(%r14,%rbx,1)
jmp    1150 <Capitalized+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @Capitalized(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strdup(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 0
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp sgt i32 %10, 90
br i1 %11, label %12, label %19
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = sub nsw i32 %16, 32
%18 = trunc i32 %17 to i8
store i8 %18, i8* %14
br label %19
19: ; preds = %12, %1
store i32 1, i32* %4
br label %20
20: ; preds = %51, %19
%21 = load i32, i32* %4
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
%24 = icmp ult i32 %21, %23
br i1 %24, label %25, label %54
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = load i32, i32* %4
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp sgt i32 %31, 64
br i1 %32, label %33, label %50
33: ; preds = %25
%34 = load i8*, i8** %3
%35 = load i32, i32* %4
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp slt i32 %39, 91
br i1 %40, label %41, label %50
41: ; preds = %33
%42 = load i8*, i8** %3
%43 = load i32, i32* %4
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = add nsw i32 %47, 32
%49 = trunc i32 %48 to i8
store i8 %49, i8* %45
br label %50
50: ; preds = %41, %33, %25
br label %51
51: ; preds = %50
%52 = load i32, i32* %4
%53 = add i32 %52, 1
store i32 %53, i32* %4
br label %20
54: ; preds = %20
%55 = load i8*, i8** %3
ret i8* %55
}

LLVM IR (-O2):
define i8* @Capitalized(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = load i8, i8* %2
%4 = icmp sgt i8 %3, 90
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = add nsw i8 %3, -32
store i8 %6, i8* %2
br label %7
7: ; preds = %5, %1
%8 = tail call i32 @strlen(i8* %2)
%9 = icmp ugt i32 %8, 1
br i1 %9, label %10, label %23
10: ; preds = %7, %18
%11 = phi i64 [ %19, %18 ], [ 1, %7 ]
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = load i8, i8* %12
%14 = add i8 %13, -65
%15 = icmp ult i8 %14, 26
br i1 %15, label %16, label %18
16: ; preds = %10
%17 = add nuw nsw i8 %13, 32
store i8 %17, i8* %12
br label %18
18: ; preds = %10, %16
%19 = add nuw nsw i64 %11, 1
%20 = tail call i32 @strlen(i8* %2)
%21 = zext i32 %20 to i64
%22 = icmp ult i64 %19, %21
br i1 %22, label %10, label %23
23: ; preds = %18, %7
ret i8* %2
}