#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 /*<<< orphan*/ sprintf(char *, char *, char);
scalar_t__ strreplace(char *, char *, char *);
const char *strremovelower(const char *orig) {
  char *str = (char *)orig;
  for (char c = 'a'; c <= 'z'; c++) {
    char buf[2];
    sprintf(buf, "%c", c);
    str = (char *)strreplace(str, buf, "");
  }
  return (const char *)str;
}


x86 assembly (clang, -O0):
<strremovelower>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movb   $0x61,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x7a,%eax
jg     117e <strremovelower+0x5e>
lea    -0x13(%rbp),%rdi
lea    0xeb0(%rip),%rsi
movsbl -0x11(%rbp),%edx
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x13(%rbp),%rsi
lea    0xe9a(%rip),%rdx
call   1030 <strreplace@plt>
mov    %rax,-0x10(%rbp)
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1138 <strremovelower+0x18>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strremovelower>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rax
mov    $0x61,%bl
lea    0xedb(%rip),%r14
lea    0xe(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %bl,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <strreplace@plt>
add    $0x1,%bl
cmp    $0x7b,%bl
jne    1130 <strremovelower+0x20>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @strremovelower(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
%5 = alloca [2 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
store i8* %6, i8** %3
store i8 97, i8* %4
br label %7
7: ; preds = %19, %1
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
%10 = icmp sle i32 %9, 122
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%13 = load i8, i8* %4
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8 signext %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds [2 x i8], [2 x i8]* %5, i64 0, i64 0
%17 = call i64 @strreplace(i8* %15, i8* %16, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %3
br label %19
19: ; preds = %11
%20 = load i8, i8* %4
%21 = add i8 %20, 1
store i8 %21, i8* %4
br label %7
22: ; preds = %7
%23 = load i8*, i8** %3
ret i8* %23
}

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
define i8* @strremovelower(i8* %0) {
%2 = alloca [2 x i8]
%3 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
br label %7
5: ; preds = %7
%6 = inttoptr i64 %10 to i8*
ret i8* %6
7: ; preds = %1, %7
%8 = phi i8 [ 97, %1 ], [ %12, %7 ]
%9 = phi i8* [ %0, %1 ], [ %11, %7 ]
store i8 %8, i8* %3
store i8 0, i8* %4
%10 = call i64 @strreplace(i8* %9, i8* %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%11 = inttoptr i64 %10 to i8*
%12 = add nuw nsw i8 %8, 1
%13 = icmp eq i8 %12, 123
br i1 %13, label %5, label %7
}