#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*/ Uart16550Put(char);
void myoutput(void *arg, char *s, int l) {
  int i;
  if ((l == 1) && (s[0] == '\0'))
    return;
  for (i = 0; i < l; i++) {
    Uart16550Put(s[i]);
    if (s[i] == '\n')
      Uart16550Put('\r');
  }
}


x86 assembly (clang, -O0):
<myoutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1142 <myoutput+0x32>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1142 <myoutput+0x32>
jmp    1198 <myoutput+0x88>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1198 <myoutput+0x88>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <Uart16550Put@plt>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    1185 <myoutput+0x75>
mov    $0xd,%edi
call   1030 <Uart16550Put@plt>
jmp    118a <myoutput+0x7a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1149 <myoutput+0x39>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myoutput>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
cmp    $0x1,%edx
jne    1125 <myoutput+0x15>
cmpb   $0x0,(%r15)
jne    1127 <myoutput+0x17>
jmp    1156 <myoutput+0x46>
jl     1156 <myoutput+0x46>
mov    %edx,%r14d
xor    %ebx,%ebx
jmp    1139 <myoutput+0x29>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r14
je     1156 <myoutput+0x46>
movsbl (%r15,%rbx,1),%edi
call   1030 <Uart16550Put@plt>
cmpb   $0xa,(%r15,%rbx,1)
jne    1130 <myoutput+0x20>
mov    $0xd,%edi
call   1030 <Uart16550Put@plt>
jmp    1130 <myoutput+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @myoutput(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %17
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10
br label %42
17: ; preds = %10, %3
store i32 0, i32* %7
br label %18
18: ; preds = %39, %17
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %42
22: ; preds = %18
%23 = load i8*, i8** %5
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = call i32 @Uart16550Put(i8 signext %27)
%29 = load i8*, i8** %5
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %38
36: ; preds = %22
%37 = call i32 @Uart16550Put(i8 signext 13)
br label %38
38: ; preds = %36, %22
br label %39
39: ; preds = %38
%40 = load i32, i32* %7
%41 = add nsw i32 %40, 1
store i32 %41, i32* %7
br label %18
42: ; preds = %16, %18
ret void
}

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