#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_handle {
  int dummy;
};

/* Variables and functions */
int feed_main_exec_char(struct feed_handle *const, unsigned char,
                        int /*<<< orphan*/);
int feed_exec(struct feed_handle *const p_this,
              unsigned char const *const p_data,
              unsigned long int const i_data_length) {
  int i_result;
  unsigned long int i_data_iterator;
  i_result = 0;
  i_data_iterator = 0ul;
  while ((0 <= i_result) && (i_data_iterator < i_data_length)) {
    unsigned char c;
    c = p_data[i_data_iterator];
    i_result = feed_main_exec_char(p_this, c, 0);
    if (0 <= i_result) {
      i_data_iterator++;
    }
  }
  return i_result;
}


x86 assembly (clang, -O0):
<feed_exec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
xor    %eax,%eax
xor    %ecx,%ecx
cmp    -0x1c(%rbp),%ecx
mov    %al,-0x2a(%rbp)
jg     1151 <feed_exec+0x41>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
setb   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    1161 <feed_exec+0x51>
jmp    119d <feed_exec+0x8d>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
movzbl -0x29(%rbp),%esi
call   1030 <feed_main_exec_char@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmp    -0x1c(%rbp),%eax
jg     1198 <feed_exec+0x88>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1133 <feed_exec+0x23>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_exec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1154 <feed_exec+0x44>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%r14,%rbx,1),%esi
mov    %r12,%rdi
xor    %edx,%edx
call   1030 <feed_main_exec_char@plt>
test   %eax,%eax
js     1156 <feed_exec+0x46>
mov    %eax,%ecx
not    %ecx
shr    $0x1f,%ecx
add    %rcx,%rbx
cmp    %r15,%rbx
jb     1130 <feed_exec+0x20>
jmp    1156 <feed_exec+0x46>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.feed_handle = type { i32 }
define i32 @feed_exec(%struct.feed_handle* %0, i8* %1, i64 %2) {
%4 = alloca %struct.feed_handle*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i8
store %struct.feed_handle* %0, %struct.feed_handle** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
store i32 0, i32* %7
store i64 0, i64* %8
br label %10
10: ; preds = %32, %3
%11 = load i32, i32* %7
%12 = icmp sle i32 0, %11
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* %8
%15 = load i64, i64* %6
%16 = icmp ult i64 %14, %15
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %19, label %33
19: ; preds = %17
%20 = load i8*, i8** %5
%21 = load i64, i64* %8
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %9
%24 = load %struct.feed_handle*, %struct.feed_handle** %4
%25 = load i8, i8* %9
%26 = call i32 @feed_main_exec_char(%struct.feed_handle* %24, i8 zeroext %25, i32 0)
store i32 %26, i32* %7
%27 = load i32, i32* %7
%28 = icmp sle i32 0, %27
br i1 %28, label %29, label %32
29: ; preds = %19
%30 = load i64, i64* %8
%31 = add i64 %30, 1
store i64 %31, i64* %8
br label %32
32: ; preds = %29, %19
br label %10
33: ; preds = %17
%34 = load i32, i32* %7
ret i32 %34
}

LLVM IR (-O2):
%struct.feed_handle = type { i32 }
define i32 @feed_exec(%struct.feed_handle* %0, i8* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %17, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %13, %5 ], [ 0, %3 ]
%7 = getelementptr inbounds i8, i8* %1, i64 %6
%8 = load i8, i8* %7
%9 = tail call i32 @feed_main_exec_char(%struct.feed_handle* %0, i8 zeroext %8, i32 0)
%10 = xor i32 %9, -1
%11 = lshr i32 %10, 31
%12 = zext i32 %11 to i64
%13 = add nuw i64 %6, %12
%14 = icmp sgt i32 %9, -1
%15 = icmp ult i64 %13, %2
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %5, label %17
17: ; preds = %5, %3
%18 = phi i32 [ 0, %3 ], [ %9, %5 ]
ret i32 %18
}