#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*/ cleanctrlchar(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char *argv[]) {
  char ent[101] = {0};
  printf("Enter a string:");
  scanf("%100s", ent);
  printf("Before: %s\n", ent);
  cleanctrlchar(ent);
  printf("After: %s\n", ent);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x65,%edx
call   1040 <memset@plt>
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe95(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rdi
call   1050 <cleanctrlchar@plt>
lea    -0x80(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
movq   $0x0,0x5d(%rsp)
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9d(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <cleanctrlchar@plt>
lea    0xe84(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a string:\00"
@.str.1 = [6 x i8] c"%100s\00"
@.str.2 = [12 x i8] c"Before: %s\0A\00"
@.str.3 = [11 x i8] c"After: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [101 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = bitcast [101 x i8]* %5 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%13 = call i32 @cleanctrlchar(i8* %12)
%14 = getelementptr inbounds [101 x i8], [101 x i8]* %5, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %14)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter a string:\00"
@.str.1 = [6 x i8] c"%100s\00"
@.str.2 = [12 x i8] c"Before: %s\0A\00"
@.str.3 = [11 x i8] c"After: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [101 x i8]
%4 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%8 = call i32 @cleanctrlchar(i8* %4)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
ret i32 0
}