#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 a_mayus(char);
char a_minus(char);
char *ucfirst(char *pdesde, char *phasta) {
  char *pact = pdesde;
  *pact = a_mayus(*pact);
  pact++;
  while (pact <= phasta) {
    *pact = a_minus(*pact);
    pact++;
  }
  return pdesde;
}


x86 assembly (clang, -O0):
<ucfirst>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <a_mayus@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     118b <ucfirst+0x6b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <a_minus@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <ucfirst+0x38>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ucfirst>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
movsbl (%rdi),%edi
call   1040 <a_mayus@plt>
mov    %al,(%r14)
lea    0x1(%r14),%rbx
cmp    %r15,%rbx
ja     1153 <ucfirst+0x33>
nop
movsbl (%rbx),%edi
call   1030 <a_minus@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    %r15,%rbx
jbe    1140 <ucfirst+0x20>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @ucfirst(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = call signext i8 @a_mayus(i8 signext %8)
%10 = load i8*, i8** %5
store i8 %9, i8* %10
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i32 1
store i8* %12, i8** %5
br label %13
13: ; preds = %17, %2
%14 = load i8*, i8** %5
%15 = load i8*, i8** %4
%16 = icmp ule i8* %14, %15
br i1 %16, label %17, label %24
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call signext i8 @a_minus(i8 signext %19)
%21 = load i8*, i8** %5
store i8 %20, i8* %21
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %13
24: ; preds = %13
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
define i8* @ucfirst(i8* returned %0, i8* readnone %1) {
%3 = load i8, i8* %0
%4 = tail call signext i8 @a_mayus(i8 signext %3)
store i8 %4, i8* %0
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = icmp ugt i8* %5, %1
br i1 %6, label %13, label %7
7: ; preds = %2, %7
%8 = phi i8* [ %11, %7 ], [ %5, %2 ]
%9 = load i8, i8* %8
%10 = tail call signext i8 @a_minus(i8 signext %9)
store i8 %10, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 1
%12 = icmp ugt i8* %11, %1
br i1 %12, label %13, label %7
13: ; preds = %7, %2
ret i8* %0
}