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

/* Variables and functions */
char feed_tty_write_character(struct feed_tty *const, unsigned char);
char feed_tty_write_character_array(struct feed_tty *const p_tty,
                                    unsigned char const *const p_buf_min,
                                    unsigned char const *const p_buf_max) {
  char b_result;
  unsigned char const *p_buf_iterator;
  unsigned char c_data;
  b_result = 1;
  p_buf_iterator = p_buf_min;
  while (b_result && (p_buf_iterator != p_buf_max)) {
    c_data = *(p_buf_iterator);
    p_buf_iterator++;
    b_result = feed_tty_write_character(p_tty, c_data);
  }
  return b_result;
}


x86 assembly (clang, -O0):
<feed_tty_write_character_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movb   $0x1,-0x19(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x2a(%rbp)
je     1150 <feed_tty_write_character_array+0x40>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
setne  %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    1160 <feed_tty_write_character_array+0x50>
jmp    118a <feed_tty_write_character_array+0x7a>
mov    -0x28(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x29(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x29(%rbp),%esi
call   1030 <feed_tty_write_character@plt>
mov    %al,-0x19(%rbp)
jmp    1130 <feed_tty_write_character_array+0x20>
movsbl -0x19(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<feed_tty_write_character_array>:
push   %r15
push   %r14
push   %rbx
cmp    %rdx,%rsi
je     114e <feed_tty_write_character_array+0x3e>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%esi
mov    %r15,%rdi
call   1030 <feed_tty_write_character@plt>
test   %al,%al
je     1150 <feed_tty_write_character_array+0x40>
lea    0x1(%rbx),%rcx
cmp    %r14,%rbx
mov    %rcx,%rbx
jne    1130 <feed_tty_write_character_array+0x20>
jmp    1150 <feed_tty_write_character_array+0x40>
mov    $0x1,%al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.feed_tty = type { i32 }
define signext i8 @feed_tty_write_character_array(%struct.feed_tty* %0, i8* %1, i8* %2) {
%4 = alloca %struct.feed_tty*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i8
store %struct.feed_tty* %0, %struct.feed_tty** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8 1, i8* %7
%10 = load i8*, i8** %5
store i8* %10, i8** %8
br label %11
11: ; preds = %21, %3
%12 = load i8, i8* %7
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8*, i8** %8
%17 = load i8*, i8** %6
%18 = icmp ne i8* %16, %17
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %29
21: ; preds = %19
%22 = load i8*, i8** %8
%23 = load i8, i8* %22
store i8 %23, i8* %9
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %8
%26 = load %struct.feed_tty*, %struct.feed_tty** %4
%27 = load i8, i8* %9
%28 = call signext i8 @feed_tty_write_character(%struct.feed_tty* %26, i8 zeroext %27)
store i8 %28, i8* %7
br label %11
29: ; preds = %19
%30 = load i8, i8* %7
ret i8 %30
}

LLVM IR (-O2):
%struct.feed_tty = type { i32 }
define signext i8 @feed_tty_write_character_array(%struct.feed_tty* %0, i8* %1, i8* readnone %2) {
%4 = icmp eq i8* %1, %2
br i1 %4, label %13, label %5
5: ; preds = %3, %5
%6 = phi i8* [ %8, %5 ], [ %1, %3 ]
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = tail call signext i8 @feed_tty_write_character(%struct.feed_tty* %0, i8 zeroext %7)
%10 = icmp ne i8 %9, 0
%11 = icmp ne i8* %8, %2
%12 = select i1 %10, i1 %11, i1 false
br i1 %12, label %5, label %13
13: ; preds = %5, %3
%14 = phi i8 [ 1, %3 ], [ %9, %5 ]
ret i8 %14
}