#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*/ __kern_rs232_putc(unsigned int, int /*<<< orphan*/);
void __kern_rs232_write(unsigned int __uartreg, unsigned char *__ptr,
                        unsigned int __size, unsigned int __nblk) {
  unsigned int s, n;
  for (n = 0; n < __nblk; n++) {
    for (s = 0; s < __size; s++) {
      __kern_rs232_putc(__uartreg, *__ptr++);
    }
  }
}


x86 assembly (clang, -O0):
<__kern_rs232_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jae    1186 <__kern_rs232_write+0x76>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1173 <__kern_rs232_write+0x63>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%esi
call   1030 <__kern_rs232_putc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <__kern_rs232_write+0x2f>
jmp    1178 <__kern_rs232_write+0x68>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112c <__kern_rs232_write+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__kern_rs232_write>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %ecx,%ecx
je     1166 <__kern_rs232_write+0x56>
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %edi,%r13d
xor    %r12d,%r12d
jmp    1139 <__kern_rs232_write+0x29>
add    $0x1,%r12d
cmp    %r14d,%r12d
je     1166 <__kern_rs232_write+0x56>
test   %r15d,%r15d
je     1130 <__kern_rs232_write+0x20>
mov    %r15d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%esi
add    $0x1,%rbx
mov    %r13d,%edi
call   1030 <__kern_rs232_putc@plt>
add    $0xffffffff,%ebp
jne    1150 <__kern_rs232_write+0x40>
jmp    1130 <__kern_rs232_write+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @__kern_rs232_write(i32 %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %10
br label %11
11: ; preds = %31, %4
%12 = load i32, i32* %10
%13 = load i32, i32* %8
%14 = icmp ult i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
store i32 0, i32* %9
br label %16
16: ; preds = %27, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i32, i32* %5
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %6
%24 = load i8, i8* %22
%25 = zext i8 %24 to i32
%26 = call i32 @__kern_rs232_putc(i32 %21, i32 %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %9
%29 = add i32 %28, 1
store i32 %29, i32* %9
br label %16
30: ; preds = %16
br label %31
31: ; preds = %30
%32 = load i32, i32* %10
%33 = add i32 %32, 1
store i32 %33, i32* %10
br label %11
34: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @__kern_rs232_write(i32 %0, i8* nocapture %1, i32 %2, i32 %3) {
%5 = icmp eq i32 %3, 0
br i1 %5, label %24, label %6
6: ; preds = %4
%7 = icmp eq i32 %2, 0
br label %8
8: ; preds = %6, %20
%9 = phi i32 [ 0, %6 ], [ %22, %20 ]
%10 = phi i8* [ %1, %6 ], [ %21, %20 ]
br i1 %7, label %20, label %11
11: ; preds = %8, %11
%12 = phi i32 [ %18, %11 ], [ 0, %8 ]
%13 = phi i8* [ %14, %11 ], [ %10, %8 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %13
%16 = zext i8 %15 to i32
%17 = tail call i32 @__kern_rs232_putc(i32 %0, i32 %16)
%18 = add nuw i32 %12, 1
%19 = icmp eq i32 %18, %2
br i1 %19, label %20, label %11
20: ; preds = %11, %8
%21 = phi i8* [ %10, %8 ], [ %14, %11 ]
%22 = add nuw i32 %9, 1
%23 = icmp eq i32 %22, %3
br i1 %23, label %24, label %8
24: ; preds = %20, %4
ret void
}