#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 *strchr(char const *, char);
char *endOfData(const char *l) {
  char *end;
  char c;
  end = strchr(l, '#');
  if (end != NULL) {
    while (l != end && ((c = *(end - 1)) == ' ' || c == '\t')) {
      --end;
    }
  } else {
    end = strchr(l, 0);
  }
  return end;
}


x86 assembly (clang, -O0):
<endOfData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x23,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a5 <endOfData+0x95>
jmp    113e <endOfData+0x2e>
mov    -0x8(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x12(%rbp)
je     117f <endOfData+0x6f>
mov    -0x10(%rbp),%rax
mov    -0x1(%rax),%al
mov    %al,-0x11(%rbp)
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x13(%rbp)
je     1179 <endOfData+0x69>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x13(%rbp)
mov    -0x13(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    118f <endOfData+0x7f>
jmp    11a0 <endOfData+0x90>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    113e <endOfData+0x2e>
jmp    11b4 <endOfData+0xa4>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endOfData>:
push   %rbx
mov    %rdi,%rbx
mov    $0x23,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1159 <endOfData+0x39>
cmp    %rbx,%rax
jne    1149 <endOfData+0x29>
mov    %rbx,%rax
pop    %rbx
ret
nopl   (%rax)
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
je     1138 <endOfData+0x18>
movzbl -0x1(%rax),%ecx
cmp    $0x20,%cl
je     1140 <endOfData+0x20>
cmp    $0x9,%cl
je     1140 <endOfData+0x20>
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <strlen@plt>
add    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @endOfData(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @strchr(i8* %5, i8 signext 35)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %32
9: ; preds = %1
br label %10
10: ; preds = %28, %9
%11 = load i8*, i8** %2
%12 = load i8*, i8** %3
%13 = icmp ne i8* %11, %12
br i1 %13, label %14, label %26
14: ; preds = %10
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 -1
%17 = load i8, i8* %16
store i8 %17, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 32
br i1 %19, label %24, label %20
20: ; preds = %14
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 9
br label %24
24: ; preds = %20, %14
%25 = phi i1 [ true, %14 ], [ %23, %20 ]
br label %26
26: ; preds = %24, %10
%27 = phi i1 [ false, %10 ], [ %25, %24 ]
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i32 -1
store i8* %30, i8** %3
br label %10
31: ; preds = %26
br label %35
32: ; preds = %1
%33 = load i8*, i8** %2
%34 = call i8* @strchr(i8* %33, i8 signext 0)
store i8* %34, i8** %3
br label %35
35: ; preds = %32, %31
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @endOfData(i8* %0) {
%2 = ptrtoint i8* %0 to i64
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 35)
%4 = ptrtoint i8* %3 to i64
%5 = icmp eq i8* %3, null
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = icmp eq i8* %3, %0
br i1 %7, label %20, label %8
8: ; preds = %6
%9 = sub i64 %2, %4
%10 = getelementptr i8, i8* %3, i64 %9
br label %11
11: ; preds = %8, %15
%12 = phi i8* [ %13, %15 ], [ %3, %8 ]
%13 = getelementptr inbounds i8, i8* %12, i64 -1
%14 = load i8, i8* %13
switch i8 %14, label %20 [
i8 32, label %15
i8 9, label %15
]
15: ; preds = %11, %11
%16 = icmp eq i8* %13, %0
br i1 %16, label %20, label %11
17: ; preds = %1
%18 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%19 = getelementptr i8, i8* %0, i64 %18
br label %20
20: ; preds = %15, %11, %6, %17
%21 = phi i8* [ %19, %17 ], [ %0, %6 ], [ %10, %15 ], [ %12, %11 ]
ret i8* %21
}