#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 */
typedef int /*<<< orphan*/ uint8_t;
typedef size_t uint32_t;
struct uart {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ uart_tx(struct uart *, int /*<<< orphan*/ const);
scalar_t__ uart_tx_fifo_full(struct uart *);
void uart_tx_array(struct uart *module, const uint8_t *array, uint32_t length) {
  for (uint32_t i = 0; i < length; ++i) {
    while (uart_tx_fifo_full(module))
      ;
    uart_tx(module, array[i]);
  }
}


x86 assembly (clang, -O0):
<uart_tx_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118c <uart_tx_array+0x6c>
jmp    114f <uart_tx_array+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <uart_tx_fifo_full@plt>
cmp    $0x0,%rax
je     1167 <uart_tx_array+0x47>
jmp    114f <uart_tx_array+0x2f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1040 <uart_tx@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <uart_tx_array+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_tx_array>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     1162 <uart_tx_array+0x42>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r12d,%r12d
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <uart_tx_fifo_full@plt>
test   %rax,%rax
jne    1140 <uart_tx_array+0x20>
mov    (%r14,%r12,4),%esi
mov    %rbx,%rdi
call   1040 <uart_tx@plt>
add    $0x1,%r12
cmp    %r15,%r12
jne    1140 <uart_tx_array+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.uart = type { i32 }
define void @uart_tx_array(%struct.uart* %0, i32* %1, i64 %2) {
%4 = alloca %struct.uart*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i64
store %struct.uart* %0, %struct.uart** %4
store i32* %1, i32** %5
store i64 %2, i64* %6
store i64 0, i64* %7
br label %8
8: ; preds = %25, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %28
12: ; preds = %8
br label %13
13: ; preds = %17, %12
%14 = load %struct.uart*, %struct.uart** %4
%15 = call i64 @uart_tx_fifo_full(%struct.uart* %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = load %struct.uart*, %struct.uart** %4
%20 = load i32*, i32** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i32, i32* %20, i64 %21
%23 = load i32, i32* %22
%24 = call i32 @uart_tx(%struct.uart* %19, i32 %23)
br label %25
25: ; preds = %18
%26 = load i64, i64* %7
%27 = add i64 %26, 1
store i64 %27, i64* %7
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.uart = type { i32 }
define void @uart_tx_array(%struct.uart* %0, i32* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %7, label %5
5: ; preds = %3, %11
%6 = phi i64 [ %15, %11 ], [ 0, %3 ]
br label %8
7: ; preds = %11, %3
ret void
8: ; preds = %5, %8
%9 = tail call i64 @uart_tx_fifo_full(%struct.uart* %0)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %8
11: ; preds = %8
%12 = getelementptr inbounds i32, i32* %1, i64 %6
%13 = load i32, i32* %12
%14 = tail call i32 @uart_tx(%struct.uart* %0, i32 %13)
%15 = add nuw i64 %6, 1
%16 = icmp eq i64 %15, %2
br i1 %16, label %7, label %5
}