#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__ ispunct(unsigned char);
scalar_t__ isupper(unsigned char);
int /*<<< orphan*/ tolower(unsigned char);
void remove_punct_and_make_lower_case(char *p) {
  char *src = p, *dst = p;
  while (*src) {
    if (ispunct((unsigned char)*src)) {
      src++;
    } else if (isupper((unsigned char)*src)) {
      *dst++ = tolower((unsigned char)*src);
      src++;
    } else if (src == dst) {
      src++;
      dst++;
    } else {
      *dst++ = *src++;
    }
  }
  *dst = 0;
}


x86 assembly (clang, -O0):
<remove_punct_and_make_lower_case>:
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
cmpb   $0x0,(%rax)
je     1222 <remove_punct_and_make_lower_case+0xf2>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <ispunct@plt>
cmp    $0x0,%rax
je     1180 <remove_punct_and_make_lower_case+0x50>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    121d <remove_punct_and_make_lower_case+0xed>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11c6 <remove_punct_and_make_lower_case+0x96>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1040 <tolower@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    1218 <remove_punct_and_make_lower_case+0xe8>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11f1 <remove_punct_and_make_lower_case+0xc1>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1213 <remove_punct_and_make_lower_case+0xe3>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1218 <remove_punct_and_make_lower_case+0xe8>
jmp    121d <remove_punct_and_make_lower_case+0xed>
jmp    114c <remove_punct_and_make_lower_case+0x1c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_punct_and_make_lower_case>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     1192 <remove_punct_and_make_lower_case+0x62>
mov    %r14,%rbx
jmp    116b <remove_punct_and_make_lower_case+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl (%rbx),%edi
call   1040 <tolower@plt>
mov    %al,(%r14)
add    $0x1,%r14
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1192 <remove_punct_and_make_lower_case+0x62>
movzbl %al,%edi
call   1030 <ispunct@plt>
test   %rax,%rax
jne    115f <remove_punct_and_make_lower_case+0x2f>
movzbl (%rbx),%edi
call   1050 <isupper@plt>
test   %rax,%rax
jne    1150 <remove_punct_and_make_lower_case+0x20>
cmp    %r14,%rbx
je     115b <remove_punct_and_make_lower_case+0x2b>
movzbl (%rbx),%eax
mov    %al,(%r14)
jmp    115b <remove_punct_and_make_lower_case+0x2b>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @remove_punct_and_make_lower_case(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 = %50, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %51
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i64 @ispunct(i8 zeroext %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %3
br label %50
19: ; preds = %11
%20 = load i8*, i8** %3
%21 = load i8, i8* %20
%22 = call i64 @isupper(i8 zeroext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = call i32 @tolower(i8 zeroext %26)
%28 = trunc i32 %27 to i8
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %4
store i8 %28, i8* %29
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %49
33: ; preds = %19
%34 = load i8*, i8** %3
%35 = load i8*, i8** %4
%36 = icmp eq i8* %34, %35
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
%40 = load i8*, i8** %4
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %4
br label %48
42: ; preds = %33
%43 = load i8*, i8** %3
%44 = getelementptr inbounds i8, i8* %43, i32 1
store i8* %44, i8** %3
%45 = load i8, i8* %43
%46 = load i8*, i8** %4
%47 = getelementptr inbounds i8, i8* %46, i32 1
store i8* %47, i8** %4
store i8 %45, i8* %46
br label %48
48: ; preds = %42, %37
br label %49
49: ; preds = %48, %24
br label %50
50: ; preds = %49, %16
br label %7
51: ; preds = %7
%52 = load i8*, i8** %4
store i8 0, i8* %52
ret void
}

LLVM IR (-O2):
define void @remove_punct_and_make_lower_case(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %31, label %4
4: ; preds = %1, %26
%5 = phi i8 [ %29, %26 ], [ %2, %1 ]
%6 = phi i8* [ %27, %26 ], [ %0, %1 ]
%7 = phi i8* [ %28, %26 ], [ %0, %1 ]
%8 = tail call i64 @ispunct(i8 zeroext %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %4
%11 = load i8, i8* %7
%12 = tail call i64 @isupper(i8 zeroext %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %19, label %14
14: ; preds = %10
%15 = load i8, i8* %7
%16 = tail call i32 @tolower(i8 zeroext %15)
%17 = trunc i32 %16 to i8
%18 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %17, i8* %6
br label %26
19: ; preds = %10
%20 = icmp eq i8* %7, %6
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = getelementptr inbounds i8, i8* %6, i64 1
br label %26
23: ; preds = %19
%24 = load i8, i8* %7
%25 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %24, i8* %6
br label %26
26: ; preds = %4, %14, %23, %21
%27 = phi i8* [ %18, %14 ], [ %22, %21 ], [ %25, %23 ], [ %6, %4 ]
%28 = getelementptr inbounds i8, i8* %7, i64 1
%29 = load i8, i8* %28
%30 = icmp eq i8 %29, 0
br i1 %30, label %31, label %4
31: ; preds = %26, %1
%32 = phi i8* [ %0, %1 ], [ %27, %26 ]
store i8 0, i8* %32
ret void
}