#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 */
scalar_t__ EOF;
scalar_t__ putchar(unsigned char const);
bool print(const char *data, size_t length) {
  const unsigned char *bytes = (const unsigned char *)data;
  for (size_t i = 0; i < length; i++) {
    if (putchar(bytes[i]) == EOF) {
      return false;
    }
  }
  return true;
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1181 <print+0x71>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%rax
jne    116b <print+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    1188 <print+0x78>
jmp    1170 <print+0x60>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1130 <print+0x20>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rsi,%rsi
je     1175 <print+0x65>
mov    %rsi,%r12
mov    %rdi,%r14
movzbl (%rdi),%edi
call   1030 <putchar@plt>
mov    %rax,%rcx
mov    0x2eb3(%rip),%r15
xor    %eax,%eax
cmp    (%r15),%rcx
je     117a <print+0x6a>
mov    $0x1,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %rcx,%r12
je     116b <print+0x5b>
movzbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
lea    0x1(%rbx),%rcx
cmp    (%r15),%rax
jne    1150 <print+0x40>
xor    %eax,%eax
cmp    %r12,%rbx
setae  %al
jmp    117a <print+0x6a>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EOF = global i64 0
define i32 @print(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%8 = load i8*, i8** %4
store i8* %8, i8** %6
store i64 0, i64* %7
br label %9
9: ; preds = %23, %2
%10 = load i64, i64* %7
%11 = load i64, i64* %5
%12 = icmp ult i64 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = load i64, i64* %7
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @putchar(i8 zeroext %17)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %13
store i32 0, i32* %3
br label %27
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load i64, i64* %7
%25 = add i64 %24, 1
store i64 %25, i64* %7
br label %9
26: ; preds = %9
store i32 1, i32* %3
br label %27
27: ; preds = %26, %21
%28 = load i32, i32* %3
ret i32 %28
}

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