#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 */
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
void main() {
  char s[80], c;
  int j, k;
  printf("Input a string:");
  fgets(s, sizeof(s), stdin);
  printf("Enter a character:");
  c = getchar();
  for (j = k = 0; s[j] != '\0'; j++)
    if (s[j] != c) {
      s[k++] = s[j];
    }
  printf("%s\n", s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1040 <fgets@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x51(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x58(%rbp)
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d6 <main+0xa6>
movslq -0x58(%rbp),%rax
movsbl -0x50(%rbp,%rax,1),%eax
movsbl -0x51(%rbp),%ecx
cmp    %ecx,%eax
je     11c3 <main+0x93>
movslq -0x58(%rbp),%rax
mov    -0x50(%rbp,%rax,1),%cl
mov    -0x5c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x5c(%rbp)
cltq
mov    %cl,-0x50(%rbp,%rax,1)
jmp    11c8 <main+0x98>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1183 <main+0x53>
lea    -0x50(%rbp),%rsi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
lea    0xeb4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    (%rsp),%dl
test   %dl,%dl
je     11aa <main+0x6a>
lea    0x1(%rsp),%rcx
jmp    119b <main+0x5b>
xchg   %ax,%ax
movzbl (%rcx),%edx
add    $0x1,%rcx
test   %dl,%dl
je     11aa <main+0x6a>
cmp    %al,%dl
je     1190 <main+0x50>
movslq %ebx,%rsi
add    $0x1,%ebx
mov    %dl,(%rsp,%rsi,1)
jmp    1190 <main+0x50>
mov    %rsp,%rdi
call   1030 <puts@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Input a string:\00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"Enter a character:\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @main() {
%1 = alloca [80 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %6, i32 80, i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %2
store i32 0, i32* %4
store i32 0, i32* %3
br label %11
11: ; preds = %37, %0
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %1, 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* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = load i8, i8* %2
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %36
27: ; preds = %18
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %29
%31 = load i8, i8* %30
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
%34 = sext i32 %32 to i64
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %34
store i8 %31, i8* %35
br label %36
36: ; preds = %27, %18
br label %37
37: ; preds = %36
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
store i32 %39, i32* %3
br label %11
40: ; preds = %11
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %41)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"Input a string:\00"
@stdin = global i32 0
@.str.1 = [19 x i8] c"Enter a character:\00"
define void @main() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 80, i32 %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call signext i8 (...) @getchar()
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %0, %19
%11 = phi i64 [ %21, %19 ], [ 0, %0 ]
%12 = phi i8 [ %23, %19 ], [ %8, %0 ]
%13 = phi i32 [ %20, %19 ], [ 0, %0 ]
%14 = icmp eq i8 %12, %7
br i1 %14, label %19, label %15
15: ; preds = %10
%16 = add nsw i32 %13, 1
%17 = sext i32 %13 to i64
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %17
store i8 %12, i8* %18
br label %19
19: ; preds = %10, %15
%20 = phi i32 [ %16, %15 ], [ %13, %10 ]
%21 = add nuw i64 %11, 1
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %10
25: ; preds = %19, %0
%26 = call i32 @puts(i8* %2)
ret void
}