#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 fasc(char);
int /*<<< orphan*/ printf(char *, char);
char *ascii2l(char *buf) {
  char *p;
  char *q;
  int c;
  p = buf;
  q = buf;
  while (*p != '\0') {
    c = fasc(*p);
    if (c == '\0') {
      printf("warning - converting x'%02X' to space\n", *p);
      c = ' ';
    }
    if (c != '\r') {
      *q++ = (char)c;
    }
    p++;
  }
  *q = '\0';
  return (buf);
}


x86 assembly (clang, -O0):
<ascii2l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b0 <ascii2l+0x90>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <fasc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    117f <ascii2l+0x5f>
mov    -0x10(%rbp),%rax
lea    0xe90(%rip),%rdi
movsbl (%rax),%esi
call   1030 <printf@plt>
movl   $0x20,-0x1c(%rbp)
cmpl   $0xd,-0x1c(%rbp)
je     119f <ascii2l+0x7f>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <ascii2l+0x1c>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ascii2l>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    (%rdi),%al
mov    %rdi,%r12
test   %al,%al
je     1187 <ascii2l+0x67>
lea    0x1(%r15),%rbx
lea    0xec1(%rip),%r14
mov    %r15,%r12
jmp    1163 <ascii2l+0x43>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %al,(%r12)
add    $0x1,%r12
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1187 <ascii2l+0x67>
movsbl %al,%edi
call   1040 <fasc@plt>
cmp    $0xd,%eax
je     1158 <ascii2l+0x38>
test   %eax,%eax
jne    1150 <ascii2l+0x30>
movsbl -0x1(%rbx),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
mov    $0x20,%eax
jmp    1150 <ascii2l+0x30>
movb   $0x0,(%r12)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [39 x i8] c"warning - converting x'%02X' to space\0A\00"
define i8* @ascii2l(i8* returned %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %21, label %4
4: ; preds = %1, %16
%5 = phi i8 [ %19, %16 ], [ %2, %1 ]
%6 = phi i8* [ %17, %16 ], [ %0, %1 ]
%7 = phi i8* [ %18, %16 ], [ %0, %1 ]
%8 = tail call i32 @fasc(i8 signext %5)
switch i32 %8, label %12 [
i32 0, label %9
i32 13, label %16
]
9: ; preds = %4
%10 = load i8, i8* %7
%11 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8 signext %10)
br label %12
12: ; preds = %4, %9
%13 = phi i32 [ 32, %9 ], [ %8, %4 ]
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %14, i8* %6
br label %16
16: ; preds = %4, %12
%17 = phi i8* [ %15, %12 ], [ %6, %4 ]
%18 = getelementptr inbounds i8, i8* %7, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %4
21: ; preds = %16, %1
%22 = phi i8* [ %0, %1 ], [ %17, %16 ]
store i8 0, i8* %22
ret i8* %0
}