#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 *, int /*<<< orphan*/);
char *process_line(char *line) {
  if (line[0] != '[')
    return NULL;
  char *end = strchr(line, 0);
  end--;
  if (*end == '\n')
    end--;
  if (*end == '\r')
    end--;
  if (*end != ']')
    return NULL;
  *end = 0;
  return line + 1;
}


x86 assembly (clang, -O0):
<process_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
je     1139 <process_line+0x29>
movq   $0x0,-0x8(%rbp)
jmp    11bc <process_line+0xac>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1170 <process_line+0x60>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    118c <process_line+0x7c>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
je     11a9 <process_line+0x99>
movq   $0x0,-0x8(%rbp)
jmp    11bc <process_line+0xac>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_line>:
push   %rbx
cmpb   $0x5b,(%rdi)
jne    1153 <process_line+0x43>
mov    %rdi,%rbx
call   1030 <strlen@plt>
lea    (%rbx,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
xor    %edx,%edx
cmpb   $0xa,-0x1(%rbx,%rax,1)
sete   %dl
sub    %rdx,%rcx
xor    %eax,%eax
cmpb   $0xd,(%rcx)
sete   %al
mov    %rcx,%rdx
sub    %rax,%rdx
cmpb   $0x5d,(%rdx)
jne    1153 <process_line+0x43>
neg    %rax
movb   $0x0,(%rcx,%rax,1)
add    $0x1,%rbx
jmp    1155 <process_line+0x45>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

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

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