#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 size_t uint32_t;
struct uart {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ uart_tx(struct uart *, char const);
scalar_t__ uart_tx_fifo_full(struct uart *);
void uart_tx_string(struct uart *module, const char *string) {
  for (uint32_t i = 0; string[i] != 0; ++i) {
    while (uart_tx_fifo_full(module))
      ;
    uart_tx(module, string[i]);
  }
}


x86 assembly (clang, -O0):
<uart_tx_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1190 <uart_tx_string+0x70>
jmp    1152 <uart_tx_string+0x32>
mov    -0x8(%rbp),%rdi
call   1030 <uart_tx_fifo_full@plt>
cmp    $0x0,%rax
je     116a <uart_tx_string+0x4a>
jmp    1152 <uart_tx_string+0x32>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1040 <uart_tx@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1138 <uart_tx_string+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_tx_string>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
cmpb   $0x0,(%rsi)
je     116e <uart_tx_string+0x4e>
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %r15d,%r15d
mov    %rsi,%r12
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1030 <uart_tx_fifo_full@plt>
test   %rax,%rax
jne    1140 <uart_tx_string+0x20>
movsbl (%r12),%esi
mov    %rbx,%rdi
call   1040 <uart_tx@plt>
lea    (%r14,%r15,1),%r12
add    $0x1,%r12
cmpb   $0x0,0x1(%r14,%r15,1)
lea    0x1(%r15),%r15
jne    1140 <uart_tx_string+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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