#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*/ str_del_char(char *, int);
int strlen(char *);
void str_del_char_ch(char *S, char ch) {
  int flag_well = 1;
  for (;;) {
    int len = strlen(S);
    flag_well = 1;
    for (int i = 0; i < len; i++) {
      if (S[i] == ch) {
        flag_well = 0;
        str_del_char(S, i);
        break;
      }
    }
    if (flag_well == 1)
      break;
  }
}


x86 assembly (clang, -O0):
<str_del_char_ch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11a2 <str_del_char_ch+0x82>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    118f <str_del_char_ch+0x6f>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1040 <str_del_char@plt>
jmp    11a2 <str_del_char_ch+0x82>
jmp    1194 <str_del_char_ch+0x74>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1153 <str_del_char_ch+0x33>
cmpl   $0x1,-0x10(%rbp)
jne    11b1 <str_del_char_ch+0x91>
jmp    11b6 <str_del_char_ch+0x96>
jmp    1139 <str_del_char_ch+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_del_char_ch>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    116d <str_del_char_ch+0x4d>
mov    %eax,%eax
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %bpl,(%rbx,%rsi,1)
je     1160 <str_del_char_ch+0x40>
add    $0x1,%rsi
cmp    %rsi,%rax
jne    1140 <str_del_char_ch+0x20>
jmp    116d <str_del_char_ch+0x4d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <str_del_char@plt>
mov    %rbx,%rdi
jmp    1128 <str_del_char_ch+0x8>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @str_del_char_ch(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 1, i32* %5
br label %8
8: ; preds = %37, %2
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %6
store i32 1, i32* %5
store i32 0, i32* %7
br label %11
11: ; preds = %30, %8
%12 = load i32, i32* %7
%13 = load i32, i32* %6
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %33
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %29
25: ; preds = %15
store i32 0, i32* %5
%26 = load i8*, i8** %3
%27 = load i32, i32* %7
%28 = call i32 @str_del_char(i8* %26, i32 %27)
br label %33
29: ; preds = %15
br label %30
30: ; preds = %29
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
br label %11
33: ; preds = %25, %11
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %33
br label %38
37: ; preds = %33
br label %8
38: ; preds = %36
ret void
}

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