int prn_xxprintf(char *buffer) {
  int n;
  bwx_DEBUG(__FUNCTION__);
  if (prn_getwidth() == 0) {
    while (*buffer) {
      xxxputc(*buffer);
      buffer++;
    }
    return 0;
  }
  n = prn_getcol() + strlen(buffer) - 1;
  if (n > prn_getwidth()) {
    xxputc('\n');
  }
  while (*buffer) {
    xxputc(*buffer);
    buffer++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<prn_xxprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <bwx_DEBUG@plt>
mov    $0x0,%al
call   1080 <prn_getwidth@plt>
cmp    $0x0,%eax
jne    11c7 <prn_xxprintf+0x67>
jmp    118f <prn_xxprintf+0x2f>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bb <prn_xxprintf+0x5b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1060 <xxxputc@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118f <prn_xxprintf+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    124c <prn_xxprintf+0xec>
mov    $0x0,%al
call   1070 <prn_getcol@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
sub    $0x1,%rax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1080 <prn_getwidth@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jle    1214 <prn_xxprintf+0xb4>
mov    $0xa,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    1219 <prn_xxprintf+0xb9>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     1245 <prn_xxprintf+0xe5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1219 <prn_xxprintf+0xb9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prn_xxprintf>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1050 <bwx_DEBUG@plt>
xor    %eax,%eax
call   1080 <prn_getwidth@plt>
test   %eax,%eax
je     11d7 <prn_xxprintf+0x77>
xor    %eax,%eax
call   1070 <prn_getcol@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    (%r14,%rax,1),%ebp
add    $0xffffffff,%ebp
xor    %eax,%eax
call   1080 <prn_getwidth@plt>
cmp    %eax,%ebp
jle    11b0 <prn_xxprintf+0x50>
mov    $0xa,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
mov    (%rbx),%al
test   %al,%al
je     1205 <prn_xxprintf+0xa5>
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11c0 <prn_xxprintf+0x60>
jmp    1205 <prn_xxprintf+0xa5>
mov    (%rbx),%al
test   %al,%al
je     1205 <prn_xxprintf+0xa5>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
xor    %eax,%eax
call   1060 <xxxputc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11f0 <prn_xxprintf+0x90>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__FUNCTION__.prn_xxprintf = [13 x i8] c"prn_xxprintf\00"
define i32 @prn_xxprintf(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.prn_xxprintf, i64 0, i64 0))
%6 = call i32 (...) @prn_getwidth()
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %1
br label %9
9: ; preds = %13, %8
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %16)
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %9
20: ; preds = %9
store i32 0, i32* %2
br label %47
21: ; preds = %1
%22 = call i32 (...) @prn_getcol()
%23 = sext i32 %22 to i64
%24 = load i8*, i8** %3
%25 = call i64 @strlen(i8* %24)
%26 = add i64 %23, %25
%27 = sub i64 %26, 1
%28 = trunc i64 %27 to i32
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = call i32 (...) @prn_getwidth()
%31 = icmp sgt i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %21
%33 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %34
34: ; preds = %32, %21
br label %35
35: ; preds = %39, %34
%36 = load i8*, i8** %3
%37 = load i8, i8* %36
%38 = icmp ne i8 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load i8*, i8** %3
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 %42)
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %3
br label %35
46: ; preds = %35
store i32 0, i32* %2
br label %47
47: ; preds = %46, %20
%48 = load i32, i32* %2
ret i32 %48
}

LLVM IR (-O2):
@__FUNCTION__.prn_xxprintf = [13 x i8] c"prn_xxprintf\00"
define i32 @prn_xxprintf(i8* nocapture %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.prn_xxprintf, i64 0, i64 0))
%3 = tail call i32 (...) @prn_getwidth()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = load i8, i8* %0
%7 = icmp eq i8 %6, 0
br i1 %7, label %37, label %8
8: ; preds = %5, %8
%9 = phi i8 [ %14, %8 ], [ %6, %5 ]
%10 = phi i8* [ %13, %8 ], [ %0, %5 ]
%11 = sext i8 %9 to i32
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %11)
%13 = getelementptr inbounds i8, i8* %10, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %37, label %8
16: ; preds = %1
%17 = tail call i32 (...) @prn_getcol()
%18 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%19 = trunc i64 %18 to i32
%20 = add i32 %17, -1
%21 = add i32 %20, %19
%22 = tail call i32 (...) @prn_getwidth()
%23 = icmp sgt i32 %21, %22
br i1 %23, label %24, label %26
24: ; preds = %16
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %26
26: ; preds = %24, %16
%27 = load i8, i8* %0
%28 = icmp eq i8 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26, %29
%30 = phi i8 [ %35, %29 ], [ %27, %26 ]
%31 = phi i8* [ %34, %29 ], [ %0, %26 ]
%32 = sext i8 %30 to i32
%33 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 %32)
%34 = getelementptr inbounds i8, i8* %31, i64 1
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 0
br i1 %36, label %37, label %29
37: ; preds = %29, %8, %26, %5
ret i32 0
}