#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*/ v_putchar(int, int, unsigned int, unsigned int, char);
void v_putcad(int x, int y, unsigned color, unsigned textback, char *cad) {
  while (cad[0] != 0) {
    v_putchar(x, y, color, textback, cad[0]);
    cad++;
    x++;
  }
}


x86 assembly (clang, -O0):
<v_putcad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     116b <v_putcad+0x5b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x18(%rbp),%rax
movsbl (%rax),%r8d
call   1030 <v_putchar@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1128 <v_putcad+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v_putcad>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    (%r8),%al
test   %al,%al
je     1162 <v_putcad+0x52>
mov    %r8,%rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebp
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%r8d
mov    %ebp,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14d,%ecx
call   1030 <v_putchar@plt>
add    $0x1,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <v_putcad+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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