#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 *, ...);
int main() {
  char str1[15];
  char str2[15];
  int i = 0, j = 0;
  char a;
  printf("Enter any string: \n\n");
  scanf("%s", &str1);
  printf("Enter any character: \n\n");
  scanf("%s", &a);
  while (str1[i] != '\0') {
    if (str1[i] != a) {
      str2[j] = str1[i];
      j++;
    }
    i++;
  }
  str2[j] = '\0';
  printf("The resultant string is : %s", str2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
lea    -0x13(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x28(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11cb <main+0xab>
movslq -0x28(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
movsbl -0x2d(%rbp),%ecx
cmp    %ecx,%eax
je     11bd <main+0x9d>
movslq -0x28(%rbp),%rax
mov    -0x13(%rbp,%rax,1),%cl
movslq -0x2c(%rbp),%rax
mov    %cl,-0x22(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117d <main+0x5d>
movslq -0x2c(%rbp),%rax
movb   $0x0,-0x22(%rbp,%rax,1)
lea    -0x22(%rbp),%rsi
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xed0(%rip),%r14
xor    %ebx,%ebx
lea    0x19(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
lea    0x9(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x19(%rsp),%dl
test   %dl,%dl
je     11ab <main+0x7b>
mov    0x9(%rsp),%al
lea    0x1a(%rsp),%rcx
xor    %ebx,%ebx
jmp    119b <main+0x6b>
nopl   0x0(%rax,%rax,1)
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
je     11ab <main+0x7b>
cmp    %al,%dl
je     1190 <main+0x60>
movslq %ebx,%rbx
mov    %dl,0xa(%rsp,%rbx,1)
add    $0x1,%ebx
jmp    1190 <main+0x60>
movslq %ebx,%rax
movb   $0x0,0xa(%rsp,%rax,1)
lea    0xe46(%rip),%rdi
lea    0xa(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

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