#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*/ mvaddch(int, int, char);
void mvaddstr_displayed(int y, int x, char *str) {
  for (; x < 0; ++x, ++str) {
    if (!*str) {
      return;
    }
  }
  for (; *str; ++str, ++x) {
    mvaddch(y, x, *str);
  }
}


x86 assembly (clang, -O0):
<mvaddstr_displayed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    115d <mvaddstr_displayed+0x4d>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    113e <mvaddstr_displayed+0x2e>
jmp    119b <mvaddstr_displayed+0x8b>
jmp    1143 <mvaddstr_displayed+0x33>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1122 <mvaddstr_displayed+0x12>
jmp    1162 <mvaddstr_displayed+0x52>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119b <mvaddstr_displayed+0x8b>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
call   1030 <mvaddch@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <mvaddstr_displayed+0x52>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvaddstr_displayed>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
test   %esi,%esi
js     1122 <mvaddstr_displayed+0x12>
mov    %rdx,%rbp
jmp    1150 <mvaddstr_displayed+0x40>
mov    %ebx,%eax
not    %eax
lea    (%rax,%rdx,1),%rbp
add    $0x1,%rbp
neg    %ebx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmpb   $0x0,(%rdx,%rax,1)
je     117c <mvaddstr_displayed+0x6c>
add    $0x1,%rax
cmp    %eax,%ebx
jne    1140 <mvaddstr_displayed+0x30>
xor    %ebx,%ebx
mov    0x0(%rbp),%al
test   %al,%al
je     117c <mvaddstr_displayed+0x6c>
add    $0x1,%rbp
nopl   0x0(%rax,%rax,1)
movsbl %al,%edx
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <mvaddch@plt>
add    $0x1,%ebx
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1160 <mvaddstr_displayed+0x50>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define void @mvaddstr_displayed(i32 %0, i32 %1, i8* nocapture %2) {
%4 = icmp slt i32 %1, 0
br i1 %4, label %5, label %10
5: ; preds = %3
%6 = xor i32 %1, -1
%7 = zext i32 %6 to i64
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr i8, i8* %2, i64 %8
br label %15
10: ; preds = %20, %3
%11 = phi i32 [ %1, %3 ], [ 0, %20 ]
%12 = phi i8* [ %2, %3 ], [ %9, %20 ]
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %33, label %24
15: ; preds = %5, %20
%16 = phi i8* [ %22, %20 ], [ %2, %5 ]
%17 = phi i32 [ %21, %20 ], [ %1, %5 ]
%18 = load i8, i8* %16
%19 = icmp eq i8 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %15
%21 = add i32 %17, 1
%22 = getelementptr inbounds i8, i8* %16, i64 1
%23 = icmp eq i32 %21, 0
br i1 %23, label %10, label %15
24: ; preds = %10, %24
%25 = phi i8 [ %31, %24 ], [ %13, %10 ]
%26 = phi i8* [ %29, %24 ], [ %12, %10 ]
%27 = phi i32 [ %30, %24 ], [ %11, %10 ]
%28 = tail call i32 @mvaddch(i32 %0, i32 %27, i8 signext %25)
%29 = getelementptr inbounds i8, i8* %26, i64 1
%30 = add nuw nsw i32 %27, 1
%31 = load i8, i8* %29
%32 = icmp eq i8 %31, 0
br i1 %32, label %33, label %24
33: ; preds = %15, %24, %10
ret void
}