#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*/ printf(char *, int);
void delchar(char *str, char del) {
  printf("%c", str[0]);
  char *p = str;
  printf("%lu", sizeof(*str));
  while (*str != '\0') {
    if (*str != del) {
      *p++ = *str;
    }
    ++str;
  }
  *p = '\0';
}


x86 assembly (clang, -O0):
<delchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xebf(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1199 <delchar+0x89>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
je     1188 <delchar+0x78>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114e <delchar+0x3e>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delchar>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
movsbl (%rdi),%esi
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
mov    $0x1,%esi
call   1030 <printf@plt>
mov    (%rbx),%cl
test   %cl,%cl
je     1168 <delchar+0x58>
lea    0x1(%rbx),%rax
jmp    115b <delchar+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rax),%ecx
add    $0x1,%rax
test   %cl,%cl
je     1168 <delchar+0x58>
cmp    %bpl,%cl
je     1150 <delchar+0x40>
mov    %cl,(%rbx)
add    $0x1,%rbx
jmp    1150 <delchar+0x40>
movb   $0x0,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%lu\00"
define void @delchar(i8* %0, i8 signext %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
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %3
store i8* %11, i8** %5
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
br label %13
13: ; preds = %30, %2
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %33
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %21, %23
br i1 %24, label %25, label %30
25: ; preds = %18
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
store i8 %27, i8* %28
br label %30
30: ; preds = %25, %18
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %3
br label %13
33: ; preds = %13
%34 = load i8*, i8** %5
store i8 0, i8* %34
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%lu\00"
define void @delchar(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = sext i8 %3 to i32
%5 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %2, %16
%10 = phi i8 [ %19, %16 ], [ %7, %2 ]
%11 = phi i8* [ %17, %16 ], [ %0, %2 ]
%12 = phi i8* [ %18, %16 ], [ %0, %2 ]
%13 = icmp eq i8 %10, %1
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %11, i64 1
store i8 %10, i8* %11
br label %16
16: ; preds = %14, %9
%17 = phi i8* [ %15, %14 ], [ %11, %9 ]
%18 = getelementptr inbounds i8, i8* %12, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %9
21: ; preds = %16, %2
%22 = phi i8* [ %0, %2 ], [ %17, %16 ]
store i8 0, i8* %22
ret void
}