#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 *, char, unsigned int);
void cleanctrlchar(char in[]) {
  char *tmp = in;
  while (*in) {
    printf("%c=%d\n", *in, (unsigned int)*in);
    if (*in <= 122 && *in >= 48) {
      tmp[0] = *in;
      tmp++;
    }
    in++;
  }
}


x86 assembly (clang, -O0):
<cleanctrlchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1196 <cleanctrlchar+0x86>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rcx
movsbl (%rcx),%edx
lea    0xebb(%rip),%rdi
movsbl %al,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7a,%eax
jg     1185 <cleanctrlchar+0x75>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jl     1185 <cleanctrlchar+0x75>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1124 <cleanctrlchar+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanctrlchar>:
push   %r15
push   %r14
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     115d <cleanctrlchar+0x4d>
mov    %rdi,%r15
lea    0x1(%rdi),%rbx
lea    0xed7(%rip),%r14
jmp    113b <cleanctrlchar+0x2b>
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     115d <cleanctrlchar+0x4d>
movsbl %al,%edx
mov    %r14,%rdi
mov    %edx,%esi
call   1030 <printf@plt>
movzbl -0x1(%rbx),%eax
lea    -0x30(%rax),%ecx
cmp    $0x4a,%cl
ja     1130 <cleanctrlchar+0x20>
mov    %al,(%r15)
add    $0x1,%r15
jmp    1130 <cleanctrlchar+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%c=%d\0A\00"
define void @cleanctrlchar(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %32, %1
%6 = load i8*, i8** %2
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %35
9: ; preds = %5
%10 = load i8*, i8** %2
%11 = load i8, i8* %10
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %11, i32 %14)
%16 = load i8*, i8** %2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp sle i32 %18, 122
br i1 %19, label %20, label %32
20: ; preds = %9
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 48
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
%28 = load i8*, i8** %3
%29 = getelementptr inbounds i8, i8* %28, i64 0
store i8 %27, i8* %29
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %3
br label %32
32: ; preds = %25, %20, %9
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %2
br label %5
35: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%c=%d\0A\00"
define void @cleanctrlchar(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %20, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %18, %15 ], [ %2, %1 ]
%6 = phi i8* [ %16, %15 ], [ %0, %1 ]
%7 = phi i8* [ %17, %15 ], [ %0, %1 ]
%8 = sext i8 %5 to i32
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext %5, i32 %8)
%10 = load i8, i8* %7
%11 = add i8 %10, -48
%12 = icmp ult i8 %11, 75
br i1 %12, label %13, label %15
13: ; preds = %4
store i8 %10, i8* %6
%14 = getelementptr inbounds i8, i8* %6, i64 1
br label %15
15: ; preds = %13, %4
%16 = phi i8* [ %14, %13 ], [ %6, %4 ]
%17 = getelementptr inbounds i8, i8* %7, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %4
20: ; preds = %15, %1
ret void
}