#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 */

/* Variables and functions */
int /*<<< orphan*/ drv_generic_serial_write(char *, int);
void drv_FW8888_send_text(const char *text, const unsigned int len) {
  unsigned int i;
  char cmd_str[2];
  cmd_str[0] = 0x12;
  for (i = 0; i < len; i++) {
    cmd_str[1] = text[i];
    drv_generic_serial_write(cmd_str, 2);
  }
}


x86 assembly (clang, -O0):
<drv_FW8888_send_text>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x12,-0x12(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    115f <drv_FW8888_send_text+0x4f>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
lea    -0x12(%rbp),%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112a <drv_FW8888_send_text+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drv_FW8888_send_text>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movb   $0x12,0x6(%rsp)
test   %esi,%esi
je     114f <drv_FW8888_send_text+0x3f>
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0x6(%rsp),%r14
xchg   %ax,%ax
movzbl (%r15,%rbx,1),%eax
mov    %al,0x7(%rsp)
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <drv_generic_serial_write@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <drv_FW8888_send_text+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @drv_FW8888_send_text(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
store i8 18, i8* %7
store i32 0, i32* %5
br label %8
8: ; preds = %21, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i32, i32* %5
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 1
store i8 %17, i8* %18
%19 = getelementptr inbounds [2 x i8], [2 x i8]* %6, i64 0, i64 0
%20 = call i32 @drv_generic_serial_write(i8* %19, i32 2)
br label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = add i32 %22, 1
store i32 %23, i32* %5
br label %8
24: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @drv_FW8888_send_text(i8* nocapture %0, i32 %1) {
%3 = alloca [2 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 0
store i8 18, i8* %4
%5 = icmp eq i32 %1, 0
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = getelementptr inbounds [2 x i8], [2 x i8]* %3, i64 0, i64 1
%8 = zext i32 %1 to i64
br label %9
9: ; preds = %6, %9
%10 = phi i64 [ 0, %6 ], [ %14, %9 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
store i8 %12, i8* %7
%13 = call i32 @drv_generic_serial_write(i8* %4, i32 2)
%14 = add nuw nsw i64 %10, 1
%15 = icmp eq i64 %14, %8
br i1 %15, label %16, label %9
16: ; preds = %9, %2
ret void
}