#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*/ cgc_memset(char *, int /*<<< orphan*/, size_t);
int cgc_strlen(char *);
char *malloc(size_t);
int /*<<< orphan*/ *strchr(char *, char);
char *get_no_ws_line(char *line) {
  if (line == NULL)
    return NULL;
  size_t size = cgc_strlen(line) + 1, i;
  char *nline = NULL, *iter;
  nline = malloc(size);
  if (nline == NULL)
    return NULL;
  cgc_memset(nline, 0, size);
  iter = nline;
  for (i = 0; i < size; i++) {
    if (strchr(" \t\n", line[i]) == NULL)
      *iter++ = line[i];
  }
  return nline;
}


x86 assembly (clang, -O0):
<get_no_ws_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1164 <get_no_ws_line+0x24>
movq   $0x0,-0x8(%rbp)
jmp    122c <get_no_ws_line+0xec>
mov    -0x10(%rbp),%rdi
call   1040 <cgc_strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a3 <get_no_ws_line+0x63>
movq   $0x0,-0x8(%rbp)
jmp    122c <get_no_ws_line+0xec>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
xor    %esi,%esi
call   1050 <cgc_memset@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1224 <get_no_ws_line+0xe4>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
lea    0xe21(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
jne    120e <get_no_ws_line+0xce>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    1213 <get_no_ws_line+0xd3>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c2 <get_no_ws_line+0x82>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_no_ws_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     11cb <get_no_ws_line+0x8b>
mov    %rdi,%r13
call   1040 <cgc_strlen@plt>
add    $0x1,%eax
movslq %eax,%r15
mov    %r15,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     11cb <get_no_ws_line+0x8b>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1050 <cgc_memset@plt>
test   %r15d,%r15d
je     11ce <get_no_ws_line+0x8e>
cmp    $0x2,%r15
mov    $0x1,%r12d
cmovae %r15,%r12
xor    %ebx,%ebx
lea    0xe69(%rip),%r15
mov    %r14,%rbp
jmp    11a9 <get_no_ws_line+0x69>
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    %rbx,%r12
je     11ce <get_no_ws_line+0x8e>
movsbl 0x0(%r13,%rbx,1),%esi
mov    %r15,%rdi
call   1030 <strchr@plt>
test   %rax,%rax
jne    11a0 <get_no_ws_line+0x60>
movzbl 0x0(%r13,%rbx,1),%eax
mov    %al,0x0(%rbp)
add    $0x1,%rbp
jmp    11a0 <get_no_ws_line+0x60>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" \09\0A\00"
define i8* @get_no_ws_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %50
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @cgc_strlen(i8* %12)
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
store i64 %15, i64* %4
store i8* null, i8** %6
%16 = load i64, i64* %4
%17 = call i8* @malloc(i64 %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %21
20: ; preds = %11
store i8* null, i8** %2
br label %50
21: ; preds = %11
%22 = load i8*, i8** %6
%23 = load i64, i64* %4
%24 = call i32 @cgc_memset(i8* %22, i32 0, i64 %23)
%25 = load i8*, i8** %6
store i8* %25, i8** %7
store i64 0, i64* %5
br label %26
26: ; preds = %45, %21
%27 = load i64, i64* %5
%28 = load i64, i64* %4
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %48
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i64, i64* %5
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %34)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %44
37: ; preds = %30
%38 = load i8*, i8** %3
%39 = load i64, i64* %5
%40 = getelementptr inbounds i8, i8* %38, i64 %39
%41 = load i8, i8* %40
%42 = load i8*, i8** %7
%43 = getelementptr inbounds i8, i8* %42, i32 1
store i8* %43, i8** %7
store i8 %41, i8* %42
br label %44
44: ; preds = %37, %30
br label %45
45: ; preds = %44
%46 = load i64, i64* %5
%47 = add i64 %46, 1
store i64 %47, i64* %5
br label %26
48: ; preds = %26
%49 = load i8*, i8** %6
store i8* %49, i8** %2
br label %50
50: ; preds = %48, %20, %10
%51 = load i8*, i8** %2
ret i8* %51
}

LLVM IR (-O2):
@.str = [4 x i8] c" \09\0A\00"
define i8* @get_no_ws_line(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %28, label %3
3: ; preds = %1
%4 = tail call i32 @cgc_strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = tail call i8* @malloc(i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %28, label %9
9: ; preds = %3
%10 = tail call i32 @cgc_memset(i8* %7, i32 0, i64 %6)
%11 = icmp eq i32 %5, 0
br i1 %11, label %28, label %12
12: ; preds = %9
%13 = call i64 @llvm.umax.i64(i64 %6, i64 1)
br label %14
14: ; preds = %12, %24
%15 = phi i8* [ %25, %24 ], [ %7, %12 ]
%16 = phi i64 [ %26, %24 ], [ 0, %12 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = load i8, i8* %17
%19 = tail call i32* @strchr(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i8, i8* %17
%23 = getelementptr inbounds i8, i8* %15, i64 1
store i8 %22, i8* %15
br label %24
24: ; preds = %14, %21
%25 = phi i8* [ %23, %21 ], [ %15, %14 ]
%26 = add nuw i64 %16, 1
%27 = icmp eq i64 %26, %13
br i1 %27, label %28, label %14
28: ; preds = %24, %9, %3, %1
%29 = phi i8* [ null, %1 ], [ null, %3 ], [ %7, %9 ], [ %7, %24 ]
ret i8* %29
}