#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 */
typedef int ssize_t;

/* Variables and functions */
int /*<<< orphan*/ EINTR;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ errno;
size_t strlen(char const *);
int write(int /*<<< orphan*/, char const *, size_t);
void print_nobuf(const char *string) {
  size_t len = strlen(string);
  while (len > 0) {
    ssize_t count = write(STDOUT_FILENO, string, len);
    if (count == -1 && errno == -EINTR) {
      continue;
    }
    if (count <= 0) {
      break;
    }
    string += count;
    len -= (size_t)count;
  }
}


x86 assembly (clang, -O0):
<print_nobuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jbe    11bc <print_nobuf+0x9c>
mov    0x2ea5(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1188 <print_nobuf+0x68>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
xor    %ecx,%ecx
mov    0x2e57(%rip),%rdx
sub    (%rdx),%ecx
cmp    %ecx,%eax
jne    1188 <print_nobuf+0x68>
jmp    1139 <print_nobuf+0x19>
cmpl   $0x0,-0x14(%rbp)
jg     1197 <print_nobuf+0x77>
jmp    11bc <print_nobuf+0x9c>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1139 <print_nobuf+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_nobuf>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
call   1040 <strlen@plt>
test   %rax,%rax
je     1183 <print_nobuf+0x63>
mov    %rax,%rbx
mov    0x2eb0(%rip),%r15
mov    0x2e91(%rip),%r12
mov    0x2e82(%rip),%r13
jmp    115f <print_nobuf+0x3f>
mov    (%r12),%eax
add    0x0(%r13),%eax
jne    1183 <print_nobuf+0x63>
test   %rbx,%rbx
je     1183 <print_nobuf+0x63>
mov    (%r15),%edi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1030 <write@plt>
cmp    $0xffffffff,%eax
je     1150 <print_nobuf+0x30>
test   %eax,%eax
jle    1183 <print_nobuf+0x63>
mov    %eax,%eax
add    %rax,%r14
sub    %rax,%rbx
test   %rbx,%rbx
jne    115f <print_nobuf+0x3f>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@errno = global i32 0
@EINTR = global i32 0
define void @print_nobuf(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @strlen(i8* %5)
store i64 %6, i64* %3
br label %7
7: ; preds = %27, %22, %1
%8 = load i64, i64* %3
%9 = icmp ugt i64 %8, 0
br i1 %9, label %10, label %36
10: ; preds = %7
%11 = load i32, i32* @STDOUT_FILENO
%12 = load i8*, i8** %2
%13 = load i64, i64* %3
%14 = call i32 @write(i32 %11, i8* %12, i64 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %23
17: ; preds = %10
%18 = load i32, i32* @errno
%19 = load i32, i32* @EINTR
%20 = sub nsw i32 0, %19
%21 = icmp eq i32 %18, %20
br i1 %21, label %22, label %23
22: ; preds = %17
br label %7
23: ; preds = %17, %10
%24 = load i32, i32* %4
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
br label %36
27: ; preds = %23
%28 = load i32, i32* %4
%29 = load i8*, i8** %2
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %2
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = load i64, i64* %3
%35 = sub i64 %34, %33
store i64 %35, i64* %3
br label %7
36: ; preds = %26, %7
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@errno = global i32 0
@EINTR = global i32 0
define void @print_nobuf(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %25, label %4
4: ; preds = %1, %21
%5 = phi i8* [ %23, %21 ], [ %0, %1 ]
%6 = phi i64 [ %22, %21 ], [ %2, %1 ]
%7 = load i32, i32* @STDOUT_FILENO
%8 = tail call i32 @write(i32 %7, i8* %5, i64 %6)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = load i32, i32* @errno
%12 = load i32, i32* @EINTR
%13 = sub nsw i32 0, %12
%14 = icmp eq i32 %11, %13
br i1 %14, label %21, label %25
15: ; preds = %4
%16 = icmp slt i32 %8, 1
br i1 %16, label %25, label %17
17: ; preds = %15
%18 = zext i32 %8 to i64
%19 = getelementptr inbounds i8, i8* %5, i64 %18
%20 = sub i64 %6, %18
br label %21
21: ; preds = %10, %17
%22 = phi i64 [ %20, %17 ], [ %6, %10 ]
%23 = phi i8* [ %19, %17 ], [ %5, %10 ]
%24 = icmp eq i64 %22, 0
br i1 %24, label %25, label %4
25: ; preds = %21, %15, %10, %1
ret void
}