#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*/ txtPrintC(int /*<<< orphan*/, short, char const);
void txtPrintS(short x, short y, const char *str, short len) {
  short i;
  for (i = 0; i < len; i++)
    txtPrintC(x++, y, *(str + i));
}


x86 assembly (clang, -O0):
<txtPrintS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %si,%cx
mov    %di,%si
mov    %si,-0x2(%rbp)
mov    %cx,-0x4(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
movswl -0x14(%rbp),%eax
movswl -0x12(%rbp),%ecx
cmp    %ecx,%eax
jge    1185 <txtPrintS+0x75>
mov    -0x2(%rbp),%ax
mov    %ax,%cx
add    $0x1,%cx
mov    %cx,-0x2(%rbp)
movswl %ax,%edi
mov    -0x4(%rbp),%dx
mov    -0x10(%rbp),%rax
movswl -0x14(%rbp),%ecx
movslq %ecx,%rcx
movswl %dx,%esi
movsbl (%rax,%rcx,1),%edx
call   1030 <txtPrintC@plt>
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
jmp    1137 <txtPrintS+0x27>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<txtPrintS>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %cx,%cx
jle    114c <txtPrintS+0x3c>
mov    %rdx,%r14
movzwl %cx,%r15d
movzwl %di,%r12d
xor    %ebx,%ebx
movswl %si,%ebp
nopl   (%rax)
lea    (%r12,%rbx,1),%eax
movswl %ax,%edi
movsbl (%r14,%rbx,1),%edx
mov    %ebp,%esi
call   1030 <txtPrintC@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <txtPrintS+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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