#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
scalar_t__ fwrite(char const *, int, int, int /*<<< orphan*/ *);
void default_printer(const char *s, int len, void *out) {
  while (len > 0) {
    int p = (int)fwrite(s, 1, len, (FILE *)out);
    if (p <= 0) {
      fputs("[ABORTED]", (FILE *)out);
      break;
    }
    len -= p;
    s += p;
  }
  fflush((FILE *)out);
}


x86 assembly (clang, -O0):
<default_printer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11a5 <default_printer+0x75>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fwrite@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jg     1184 <default_printer+0x54>
mov    -0x18(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1030 <fputs@plt>
jmp    11a5 <default_printer+0x75>
mov    -0x1c(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1143 <default_printer+0x13>
mov    -0x18(%rbp),%rdi
call   1040 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<default_printer>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
test   %esi,%esi
jle    116b <default_printer+0x4b>
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
test   %eax,%eax
jle    1152 <default_printer+0x32>
movslq %eax,%rcx
add    %rcx,%rbx
sub    %eax,%ebp
jg     1130 <default_printer+0x10>
jmp    116b <default_printer+0x4b>
lea    0xea7(%rip),%rdi
mov    $0x9,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fflush@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"[ABORTED]\00"
define void @default_printer(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
br label %8
8: ; preds = %24, %3
%9 = load i32, i32* %5
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = load i8*, i8** %6
%15 = bitcast i8* %14 to i32*
%16 = call i64 @fwrite(i8* %12, i32 1, i32 %13, i32* %15)
%17 = trunc i64 %16 to i32
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = icmp sle i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %11
%21 = load i8*, i8** %6
%22 = bitcast i8* %21 to i32*
%23 = call i32 @fputs(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %22)
br label %32
24: ; preds = %11
%25 = load i32, i32* %7
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, %25
store i32 %27, i32* %5
%28 = load i32, i32* %7
%29 = load i8*, i8** %4
%30 = sext i32 %28 to i64
%31 = getelementptr inbounds i8, i8* %29, i64 %30
store i8* %31, i8** %4
br label %8
32: ; preds = %20, %8
%33 = load i8*, i8** %6
%34 = bitcast i8* %33 to i32*
%35 = call i32 @fflush(i32* %34)
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"[ABORTED]\00"
define void @default_printer(i8* nocapture %0, i32 %1, i8* %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %21
5: ; preds = %3
%6 = bitcast i8* %2 to i32*
br label %7
7: ; preds = %5, %15
%8 = phi i8* [ %0, %5 ], [ %19, %15 ]
%9 = phi i32 [ %1, %5 ], [ %16, %15 ]
%10 = tail call i64 @fwrite(i8* %8, i32 1, i32 %9, i32* %6)
%11 = trunc i64 %10 to i32
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = tail call i64 bitcast (i64 (i8*, i32, i32, i32*)* @fwrite to i64 (i8*, i64, i64, i32*)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 9, i64 1, i32* %6)
br label %21
15: ; preds = %7
%16 = sub nsw i32 %9, %11
%17 = shl i64 %10, 32
%18 = ashr exact i64 %17, 32
%19 = getelementptr inbounds i8, i8* %8, i64 %18
%20 = icmp sgt i32 %16, 0
br i1 %20, label %7, label %21
21: ; preds = %15, %3, %13
%22 = bitcast i8* %2 to i32*
%23 = tail call i32 @fflush(i32* %22)
ret void
}