#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 */
scalar_t__ isalpha(char);
int /*<<< orphan*/ toupper(char);
void preprocess(char *str) {
  char *src = str, *dest = str;
  while (*src != '\0') {
    if (isalpha(*src))
      *(dest++) = toupper(*src);
    src++;
  }
  *dest = '\0';
}


x86 assembly (clang, -O0):
<preprocess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1192 <preprocess+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1181 <preprocess+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <preprocess+0x1c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<preprocess>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     116a <preprocess+0x4a>
lea    0x1(%r14),%rbx
jmp    114b <preprocess+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     116a <preprocess+0x4a>
movsbl %al,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
je     1140 <preprocess+0x20>
movsbl -0x1(%rbx),%edi
call   1030 <toupper@plt>
mov    %al,(%r14)
add    $0x1,%r14
jmp    1140 <preprocess+0x20>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @preprocess(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %3
%6 = load i8*, i8** %2
store i8* %6, i8** %4
br label %7
7: ; preds = %24, %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 %27
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = call i64 @isalpha(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = call i32 @toupper(i8 signext %19)
%21 = trunc i32 %20 to i8
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
store i8 %21, i8* %22
br label %24
24: ; preds = %17, %12
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
br label %7
27: ; preds = %7
%28 = load i8*, i8** %4
store i8 0, i8* %28
ret void
}

LLVM IR (-O2):
define void @preprocess(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %18, %15 ], [ %2, %1 ]
%6 = phi i8* [ %16, %15 ], [ %0, %1 ]
%7 = phi i8* [ %17, %15 ], [ %0, %1 ]
%8 = tail call i64 @isalpha(i8 signext %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = load i8, i8* %7
%12 = tail call i32 @toupper(i8 signext %11)
%13 = trunc i32 %12 to i8
%14 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %13, i8* %6
br label %15
15: ; preds = %10, %4
%16 = phi i8* [ %14, %10 ], [ %6, %4 ]
%17 = getelementptr inbounds i8, i8* %7, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %15, %1
%21 = phi i8* [ %0, %1 ], [ %16, %15 ]
store i8 0, i8* %21
ret void
}