int xxputc(char c) {
  bwx_DEBUG(__FUNCTION__);
  if (prn_getwidth() == 0) {
    xxxputc(c);
    return 0;
  }
  if (c != '\n') {
    if (prn_getcol() > prn_getwidth()) {
      xxxputc('\n');
    }
  }
  xxxputc(c);
  return 0;
}


x86 assembly (clang, -O0):
<xxputc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <bwx_DEBUG@plt>
mov    $0x0,%al
call   1060 <prn_getwidth@plt>
cmp    $0x0,%eax
jne    1183 <xxputc+0x43>
movsbl -0x5(%rbp),%edi
mov    $0x0,%al
call   1040 <xxxputc@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <xxputc+0x91>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
je     11bf <xxputc+0x7f>
mov    $0x0,%al
call   1050 <prn_getcol@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <prn_getwidth@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jle    11ba <xxputc+0x7a>
mov    $0xa,%edi
mov    $0x0,%al
call   1040 <xxxputc@plt>
jmp    11bf <xxputc+0x7f>
movsbl -0x5(%rbp),%edi
mov    $0x0,%al
call   1040 <xxxputc@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xxputc>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1030 <bwx_DEBUG@plt>
xor    %eax,%eax
call   1060 <prn_getwidth@plt>
test   %eax,%eax
je     1183 <xxputc+0x43>
cmp    $0xa,%bl
je     1183 <xxputc+0x43>
xor    %eax,%eax
call   1050 <prn_getcol@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1060 <prn_getwidth@plt>
cmp    %eax,%ebp
jle    1183 <xxputc+0x43>
mov    $0xa,%edi
xor    %eax,%eax
call   1040 <xxxputc@plt>
movsbl %bl,%edi
xor    %eax,%eax
call   1040 <xxxputc@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__FUNCTION__.xxputc = [7 x i8] c"xxputc\00"
define i32 @xxputc(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__FUNCTION__.xxputc, i64 0, i64 0))
%5 = call i32 (...) @prn_getwidth()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
%10 = call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %9)
store i32 0, i32* %2
br label %26
11: ; preds = %1
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 10
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = call i32 (...) @prn_getcol()
%17 = call i32 (...) @prn_getwidth()
%18 = icmp sgt i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 10)
br label %21
21: ; preds = %19, %15
br label %22
22: ; preds = %21, %11
%23 = load i8, i8* %3
%24 = sext i8 %23 to i32
%25 = call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %24)
store i32 0, i32* %2
br label %26
26: ; preds = %22, %7
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
@__FUNCTION__.xxputc = [7 x i8] c"xxputc\00"
define i32 @xxputc(i8 signext %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @__FUNCTION__.xxputc, i64 0, i64 0))
%3 = tail call i32 (...) @prn_getwidth()
%4 = icmp eq i32 %3, 0
%5 = icmp eq i8 %0, 10
%6 = or i1 %4, %5
br i1 %6, label %13, label %7
7: ; preds = %1
%8 = tail call i32 (...) @prn_getcol()
%9 = tail call i32 (...) @prn_getwidth()
%10 = icmp sgt i32 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 10)
br label %13
13: ; preds = %11, %7, %1
%14 = sext i8 %0 to i32
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %14)
ret i32 0
}