#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 /*<<< orphan*/ scanf(char *, char *);
int main() {
  char str[100] = {0};
  char new_str[100] = {0};
  char ch;
  int i, j;
  printf("Enter str: ");
  scanf(" %s", str);
  printf("str : %s\n", str);
  printf("Enter char to remove\n");
  scanf(" %c", &ch);
  for (i = 0, j = 0; str[i] != '\0'; i++) {
    if (str[i] != ch) {
      new_str[j] = str[i];
      j++;
    }
  }
  new_str[j] = '\0';
  printf("new str : %s\n", new_str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1040 <memset@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe8e(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7c(%rip),%rdi
lea    -0xe1(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0xe8(%rbp)
movl   $0x0,-0xec(%rbp)
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     123b <main+0x10b>
movslq -0xe8(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
movsbl -0xe1(%rbp),%ecx
cmp    %ecx,%eax
je     1222 <main+0xf2>
movslq -0xe8(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0xec(%rbp),%rax
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    1227 <main+0xf7>
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11ca <main+0x9a>
movslq -0xec(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0xe0(%rbp),%rsi
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xe8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xe0(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe5b(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe57(%rip),%rdi
lea    0x80(%rsp),%r14
mov    %r14,%rsi
call   1050 <scanf@plt>
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    0xe27(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x80(%rsp),%dl
test   %dl,%dl
je     122b <main+0xfb>
mov    0xf(%rsp),%al
lea    0x81(%rsp),%rcx
xor    %ebx,%ebx
jmp    121b <main+0xeb>
xchg   %ax,%ax
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
je     122b <main+0xfb>
cmp    %al,%dl
je     1210 <main+0xe0>
movslq %ebx,%rbx
mov    %dl,0x10(%rsp,%rbx,1)
add    $0x1,%ebx
jmp    1210 <main+0xe0>
movslq %ebx,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0xdda(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Enter str: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [10 x i8] c"str : %s\0A\00"
@.str.3 = [22 x i8] c"Enter char to remove\0A\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [14 x i8] c"new str : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca [100 x i8]
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [100 x i8]* %2 to i8*
%8 = bitcast [100 x i8]* %3 to i8*
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %4)
store i32 0, i32* %5
store i32 0, i32* %6
br label %16
16: ; preds = %43, %0
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %46
23: ; preds = %16
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp ne i32 %28, %30
br i1 %31, label %32, label %42
32: ; preds = %23
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %38
store i8 %36, i8* %39
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
br label %42
42: ; preds = %32, %23
br label %43
43: ; preds = %42
%44 = load i32, i32* %5
%45 = add nsw i32 %44, 1
store i32 %45, i32* %5
br label %16
46: ; preds = %16
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %48
store i8 0, i8* %49
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Enter str: \00"
@.str.1 = [4 x i8] c" %s\00"
@.str.2 = [10 x i8] c"str : %s\0A\00"
@.str.4 = [4 x i8] c" %c\00"
@.str.5 = [14 x i8] c"new str : %s\0A\00"
@str = [21 x i8] c"Enter char to remove\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%11 = load i8, i8* %4
%12 = icmp eq i8 %11, 0
br i1 %12, label %30, label %13
13: ; preds = %0
%14 = load i8, i8* %3
br label %15
15: ; preds = %13, %24
%16 = phi i64 [ 0, %13 ], [ %26, %24 ]
%17 = phi i8 [ %11, %13 ], [ %28, %24 ]
%18 = phi i32 [ 0, %13 ], [ %25, %24 ]
%19 = icmp eq i8 %17, %14
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = sext i32 %18 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %21
store i8 %17, i8* %22
%23 = add nsw i32 %18, 1
br label %24
24: ; preds = %15, %20
%25 = phi i32 [ %23, %20 ], [ %18, %15 ]
%26 = add nuw i64 %16, 1
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %15
30: ; preds = %24, %0
%31 = phi i32 [ 0, %0 ], [ %25, %24 ]
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %5)
ret i32 0
}