#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 */
struct feed_screen_iterator {
  int dummy;
};
struct feed_screen_info {
  int dummy;
};

/* Variables and functions */
unsigned long feed_screen_iterator_clear(struct feed_screen_info const *const,
                                         struct feed_screen_iterator *const);
unsigned short
feed_screen_iterator_get_cursor_x(struct feed_screen_info const *const,
                                  struct feed_screen_iterator *const);
scalar_t__ feed_screen_iterator_test_write(struct feed_screen_info const *const,
                                           struct feed_screen_iterator *const,
                                           unsigned long);
int /*<<< orphan*/
feed_screen_iterator_write(struct feed_screen_info const *const,
                           struct feed_screen_iterator *const, unsigned long);
unsigned long int
feed_screen_iterator_tab(struct feed_screen_info const *const p_screen_info,
                         struct feed_screen_iterator *const p_screen_iterator) {
  unsigned long int i_width;
  unsigned short int i_cursor_x;
  i_cursor_x =
      feed_screen_iterator_get_cursor_x(p_screen_info, p_screen_iterator);
  i_width = (unsigned long int)(8u - (i_cursor_x & 7u));
  if (feed_screen_iterator_test_write(p_screen_info, p_screen_iterator,
                                      i_width)) {
    feed_screen_iterator_write(p_screen_info, p_screen_iterator, i_width);
  } else {
    i_width = feed_screen_iterator_clear(p_screen_info, p_screen_iterator);
  }
  return i_width;
}


x86 assembly (clang, -O0):
<feed_screen_iterator_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <feed_screen_iterator_get_cursor_x@plt>
mov    %ax,-0x1a(%rbp)
movzwl -0x1a(%rbp),%ecx
and    $0x7,%ecx
mov    $0x8,%eax
sub    %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <feed_screen_iterator_test_write@plt>
cmp    $0x0,%rax
je     11a6 <feed_screen_iterator_tab+0x66>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <feed_screen_iterator_write@plt>
jmp    11b7 <feed_screen_iterator_tab+0x77>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <feed_screen_iterator_clear@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_screen_iterator_tab>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1060 <feed_screen_iterator_get_cursor_x@plt>
and    $0x7,%eax
mov    $0x8,%ebx
sub    %eax,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <feed_screen_iterator_test_write@plt>
mov    %r15,%rdi
mov    %r14,%rsi
test   %rax,%rax
je     1184 <feed_screen_iterator_tab+0x44>
mov    %rbx,%rdx
call   1030 <feed_screen_iterator_write@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <feed_screen_iterator_clear@plt>

LLVM IR (-O0):
%struct.feed_screen_info = type { i32 }
%struct.feed_screen_iterator = type { i32 }
define i64 @feed_screen_iterator_tab(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1) {
%3 = alloca %struct.feed_screen_info*
%4 = alloca %struct.feed_screen_iterator*
%5 = alloca i64
%6 = alloca i16
store %struct.feed_screen_info* %0, %struct.feed_screen_info** %3
store %struct.feed_screen_iterator* %1, %struct.feed_screen_iterator** %4
%7 = load %struct.feed_screen_info*, %struct.feed_screen_info** %3
%8 = load %struct.feed_screen_iterator*, %struct.feed_screen_iterator** %4
%9 = call zeroext i16 @feed_screen_iterator_get_cursor_x(%struct.feed_screen_info* %7, %struct.feed_screen_iterator* %8)
store i16 %9, i16* %6
%10 = load i16, i16* %6
%11 = zext i16 %10 to i32
%12 = and i32 %11, 7
%13 = sub i32 8, %12
%14 = zext i32 %13 to i64
store i64 %14, i64* %5
%15 = load %struct.feed_screen_info*, %struct.feed_screen_info** %3
%16 = load %struct.feed_screen_iterator*, %struct.feed_screen_iterator** %4
%17 = load i64, i64* %5
%18 = call i64 @feed_screen_iterator_test_write(%struct.feed_screen_info* %15, %struct.feed_screen_iterator* %16, i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %2
%21 = load %struct.feed_screen_info*, %struct.feed_screen_info** %3
%22 = load %struct.feed_screen_iterator*, %struct.feed_screen_iterator** %4
%23 = load i64, i64* %5
%24 = call i32 @feed_screen_iterator_write(%struct.feed_screen_info* %21, %struct.feed_screen_iterator* %22, i64 %23)
br label %29
25: ; preds = %2
%26 = load %struct.feed_screen_info*, %struct.feed_screen_info** %3
%27 = load %struct.feed_screen_iterator*, %struct.feed_screen_iterator** %4
%28 = call i64 @feed_screen_iterator_clear(%struct.feed_screen_info* %26, %struct.feed_screen_iterator* %27)
store i64 %28, i64* %5
br label %29
29: ; preds = %25, %20
%30 = load i64, i64* %5
ret i64 %30
}

LLVM IR (-O2):
%struct.feed_screen_info = type { i32 }
%struct.feed_screen_iterator = type { i32 }
define i64 @feed_screen_iterator_tab(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1) {
%3 = tail call zeroext i16 @feed_screen_iterator_get_cursor_x(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1)
%4 = and i16 %3, 7
%5 = sub nuw nsw i16 8, %4
%6 = zext i16 %5 to i64
%7 = tail call i64 @feed_screen_iterator_test_write(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1, i64 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %2
%10 = tail call i32 @feed_screen_iterator_write(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1, i64 %6)
br label %13
11: ; preds = %2
%12 = tail call i64 @feed_screen_iterator_clear(%struct.feed_screen_info* %0, %struct.feed_screen_iterator* %1)
br label %13
13: ; preds = %11, %9
%14 = phi i64 [ %6, %9 ], [ %12, %11 ]
ret i64 %14
}