#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*/ TabbingNextCellEnd(char *, char **, char **);
int /*<<< orphan*/ diagnostics(int, char *, char *);
int /*<<< orphan*/ free(char *);
char *my_strndup(char *, size_t);
char *strdup_noendblanks(char *);
char *strstr(char *, char *);
char *TabbingNextCell(char *cell_start, char **cell_end) {
  char *end = NULL, *dup, *dup2, *next_cell = NULL, *p;
  TabbingNextCellEnd(cell_start, &end, &next_cell);
  if (end < cell_start)
    end = cell_start;
  dup = my_strndup(cell_start, (size_t)(end - cell_start));
  if (*next_cell == '\0')
    *cell_end = NULL;
  else
    *cell_end = next_cell;
  while (((p = strstr(dup, "\\+")) != NULL) ||
         ((p = strstr(dup, "\\-")) != NULL)) {
    *p = ' ';
    p++;
    *p = ' ';
  }
  dup2 = strdup_noendblanks(dup);
  free(dup);
  diagnostics(5, "next cell = [[%s]]", dup);
  return dup2;
}


x86 assembly (clang, -O0):
<TabbingNextCell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <TabbingNextCellEnd@plt>
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11a7 <TabbingNextCell+0x47>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x8(%rbp),%rax
sub    %rax,%rsi
call   1060 <my_strndup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11df <TabbingNextCell+0x7f>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
jmp    11ea <TabbingNextCell+0x8a>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11ef <TabbingNextCell+0x8f>
mov    -0x20(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x39(%rbp)
jne    1233 <TabbingNextCell+0xd3>
mov    -0x20(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1243 <TabbingNextCell+0xe3>
jmp    1262 <TabbingNextCell+0x102>
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movb   $0x20,(%rax)
jmp    11ef <TabbingNextCell+0x8f>
mov    -0x20(%rbp),%rdi
call   1040 <strdup_noendblanks@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdx
mov    $0x5,%edi
lea    0xd7e(%rip),%rsi
call   1050 <diagnostics@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TabbingNextCell>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
call   1070 <TabbingNextCellEnd@plt>
mov    (%rsp),%rsi
cmp    %rbx,%rsi
jae    119d <TabbingNextCell+0x3d>
mov    %rbx,(%rsp)
mov    %rbx,%rsi
sub    %rbx,%rsi
mov    %rbx,%rdi
call   1060 <my_strndup@plt>
mov    0x8(%rsp),%rcx
xor    %edx,%edx
cmpb   $0x0,(%rcx)
cmovne %rcx,%rdx
mov    %rax,%rbx
mov    %rdx,(%r14)
lea    0xe3d(%rip),%r14
lea    0xe39(%rip),%r15
jmp    11d5 <TabbingNextCell+0x75>
nopl   0x0(%rax)
movw   $0x2020,(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    11d0 <TabbingNextCell+0x70>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strstr@plt>
test   %rax,%rax
jne    11d0 <TabbingNextCell+0x70>
mov    %rbx,%rdi
call   1040 <strdup_noendblanks@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xdf7(%rip),%rsi
mov    $0x5,%edi
mov    %rbx,%rdx
call   1050 <diagnostics@plt>
mov    %r14,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\\+\00"
@.str.1 = [3 x i8] c"\\-\00"
@.str.2 = [19 x i8] c"next cell = [[%s]]\00"
define i8* @TabbingNextCell(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %3
store i8** %1, i8*** %4
store i8* null, i8** %5
store i8* null, i8** %8
%10 = load i8*, i8** %3
%11 = call i32 @TabbingNextCellEnd(i8* %10, i8** %5, i8** %8)
%12 = load i8*, i8** %5
%13 = load i8*, i8** %3
%14 = icmp ult i8* %12, %13
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = load i8*, i8** %3
store i8* %16, i8** %5
br label %17
17: ; preds = %15, %2
%18 = load i8*, i8** %3
%19 = load i8*, i8** %5
%20 = load i8*, i8** %3
%21 = ptrtoint i8* %19 to i64
%22 = ptrtoint i8* %20 to i64
%23 = sub i64 %21, %22
%24 = call i8* @my_strndup(i8* %18, i64 %23)
store i8* %24, i8** %6
%25 = load i8*, i8** %8
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %17
%30 = load i8**, i8*** %4
store i8* null, i8** %30
br label %34
31: ; preds = %17
%32 = load i8*, i8** %8
%33 = load i8**, i8*** %4
store i8* %32, i8** %33
br label %34
34: ; preds = %31, %29
br label %35
35: ; preds = %45, %34
%36 = load i8*, i8** %6
%37 = call i8* @strstr(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %37, i8** %9
%38 = icmp ne i8* %37, null
br i1 %38, label %43, label %39
39: ; preds = %35
%40 = load i8*, i8** %6
%41 = call i8* @strstr(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %41, i8** %9
%42 = icmp ne i8* %41, null
br label %43
43: ; preds = %39, %35
%44 = phi i1 [ true, %35 ], [ %42, %39 ]
br i1 %44, label %45, label %50
45: ; preds = %43
%46 = load i8*, i8** %9
store i8 32, i8* %46
%47 = load i8*, i8** %9
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %9
%49 = load i8*, i8** %9
store i8 32, i8* %49
br label %35
50: ; preds = %43
%51 = load i8*, i8** %6
%52 = call i8* @strdup_noendblanks(i8* %51)
store i8* %52, i8** %7
%53 = load i8*, i8** %6
%54 = call i32 @free(i8* %53)
%55 = load i8*, i8** %6
%56 = call i32 @diagnostics(i32 5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %7
ret i8* %57
}

LLVM IR (-O2):
@.str = [3 x i8] c"\\+\00"
@.str.1 = [3 x i8] c"\\-\00"
@.str.2 = [19 x i8] c"next cell = [[%s]]\00"
define i8* @TabbingNextCell(i8* %0, i8** nocapture writeonly %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = call i32 @TabbingNextCellEnd(i8* %0, i8** %3, i8** %4)
%8 = load i8*, i8** %3
%9 = icmp ult i8* %8, %0
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* %0, i8** %3
br label %11
11: ; preds = %10, %2
%12 = phi i8* [ %0, %10 ], [ %8, %2 ]
%13 = ptrtoint i8* %12 to i64
%14 = ptrtoint i8* %0 to i64
%15 = sub i64 %13, %14
%16 = call i8* @my_strndup(i8* %0, i64 %15)
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
%20 = select i1 %19, i8* null, i8* %17
store i8* %20, i8** %1
br label %21
21: ; preds = %27, %11
%22 = call i8* @strstr(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = call i8* @strstr(i8* dereferenceable(1) %16, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i8* %25, null
br i1 %26, label %30, label %27
27: ; preds = %21, %24
%28 = phi i8* [ %22, %21 ], [ %25, %24 ]
store i8 32, i8* %28
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 32, i8* %29
br label %21
30: ; preds = %24
%31 = call i8* @strdup_noendblanks(i8* %16)
%32 = call i32 @free(i8* %16)
%33 = call i32 @diagnostics(i32 5, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %16)
ret i8* %31
}