#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 */
char *allocstr(char *);
int /*<<< orphan*/ memset(char *, char, int);
char *ASCII_to_text(char *s) {
  char buffer[1024];
  char *b;
  b = buffer;
  memset(buffer, '\0', 1024);
  while (*s != '\0') {
    if (((*s) & 0x80) == 0) {
      *b = *s;
      b++;
    }
    s++;
  }
  *b = '\0';
  return allocstr(buffer);
}


x86 assembly (clang, -O0):
<ASCII_to_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x410(%rbp),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a7 <ASCII_to_text+0x87>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1196 <ASCII_to_text+0x76>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x418(%rbp),%rax
mov    %cl,(%rax)
mov    -0x418(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x418(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1150 <ASCII_to_text+0x30>
mov    -0x418(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x410(%rbp),%rdi
call   1040 <allocstr@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASCII_to_text>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1030 <memset@plt>
mov    (%rbx),%al
test   %al,%al
je     1168 <ASCII_to_text+0x48>
mov    %rsp,%r14
add    $0x1,%rbx
jmp    115b <ASCII_to_text+0x3b>
xchg   %ax,%ax
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1168 <ASCII_to_text+0x48>
test   %al,%al
js     1150 <ASCII_to_text+0x30>
mov    %al,(%r14)
add    $0x1,%r14
jmp    1150 <ASCII_to_text+0x30>
movb   $0x0,(%r14)
mov    %rsp,%rdi
call   1040 <allocstr@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @ASCII_to_text(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i8*
store i8* %0, i8** %2
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8* %5, i8** %4
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i8 signext 0, i32 1024)
br label %8
8: ; preds = %25, %1
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = and i32 %16, 128
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %13
%20 = load i8*, i8** %2
%21 = load i8, i8* %20
%22 = load i8*, i8** %4
store i8 %21, i8* %22
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
br label %25
25: ; preds = %19, %13
%26 = load i8*, i8** %2
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %2
br label %8
28: ; preds = %8
%29 = load i8*, i8** %4
store i8 0, i8* %29
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%31 = call i8* @allocstr(i8* %30)
ret i8* %31
}

LLVM IR (-O2):
define i8* @ASCII_to_text(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i8 signext 0, i32 1024)
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %1, %14
%8 = phi i8 [ %17, %14 ], [ %5, %1 ]
%9 = phi i8* [ %15, %14 ], [ %3, %1 ]
%10 = phi i8* [ %16, %14 ], [ %0, %1 ]
%11 = icmp sgt i8 %8, -1
br i1 %11, label %12, label %14
12: ; preds = %7
store i8 %8, i8* %9
%13 = getelementptr inbounds i8, i8* %9, i64 1
br label %14
14: ; preds = %12, %7
%15 = phi i8* [ %13, %12 ], [ %9, %7 ]
%16 = getelementptr inbounds i8, i8* %10, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %7
19: ; preds = %14, %1
%20 = phi i8* [ %3, %1 ], [ %15, %14 ]
store i8 0, i8* %20
%21 = call i8* @allocstr(i8* %3)
ret i8* %21
}