int xputc(char c) {
  static char CHR_pending = 0;
  bwx_DEBUG(__FUNCTION__);
  if (prn_getwidth() == 0) {
    xxxputc(c);
    return 0;
  }
  if (CHR_pending == 0x01) {
    int i;
    for (i = 0; i < c; i++) {
      xxputc(' ');
    }
    CHR_pending = 0;
    return -1;
  }
  if (CHR_pending == 0x02) {
    while (c > prn_getwidth()) {
      c -= prn_getwidth();
    }
    if (c == 0) {
      c = 1;
    }
    if ((int)c < prn_getcol()) {
      xxputc('\n');
    }
    while (prn_getcol() < (int)c) {
      xxputc(' ');
    }
    CHR_pending = 0;
    return -1;
  }
  switch (c) {
  case 0x01:
  case 0x02:
    CHR_pending = c;
    break;
  case '\t': {
    int LastZoneColumn;
    LastZoneColumn = 1;
    while (LastZoneColumn < prn_getwidth()) {
      LastZoneColumn += (6 + 3 + 6);
    }
    LastZoneColumn -= (6 + 3 + 6);
    if (prn_getcol() >= LastZoneColumn) {
      xxputc('\n');
    } else {
      if ((prn_getcol() % (6 + 3 + 6)) == 1) {
        xxputc(' ');
      }
      while ((prn_getcol() % (6 + 3 + 6)) != 1) {
        xxputc(' ');
      }
    }
  } break;
  default:
    xxputc(c);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<xputc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <bwx_DEBUG@plt>
mov    $0x0,%al
call   1070 <prn_getwidth@plt>
cmp    $0x0,%eax
jne    1193 <xputc+0x43>
movsbl -0x5(%rbp),%edi
mov    $0x0,%al
call   1050 <xxxputc@plt>
movl   $0x0,-0x4(%rbp)
jmp    139f <xputc+0x24f>
movsbl 0x2eaf(%rip),%eax
cmp    $0x1,%eax
jne    11e6 <xputc+0x96>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jge    11d3 <xputc+0x83>
mov    $0x20,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11aa <xputc+0x5a>
movb   $0x0,0x2e6f(%rip)
movl   $0xffffffff,-0x4(%rbp)
jmp    139f <xputc+0x24f>
movsbl 0x2e5c(%rip),%eax
cmp    $0x2,%eax
jne    12a1 <xputc+0x151>
jmp    11fb <xputc+0xab>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1070 <prn_getwidth@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jle    122d <xputc+0xdd>
mov    $0x0,%al
call   1070 <prn_getwidth@plt>
mov    %eax,%ecx
movsbl -0x5(%rbp),%eax
sub    %ecx,%eax
mov    %al,-0x5(%rbp)
jmp    11fb <xputc+0xab>
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
jne    123e <xputc+0xee>
movb   $0x1,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <prn_getcol@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    1265 <xputc+0x115>
mov    $0xa,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    126a <xputc+0x11a>
mov    $0x0,%al
call   1060 <prn_getcol@plt>
movsbl -0x5(%rbp),%ecx
cmp    %ecx,%eax
jge    128e <xputc+0x13e>
mov    $0x20,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    126a <xputc+0x11a>
movb   $0x0,0x2db4(%rip)
movl   $0xffffffff,-0x4(%rbp)
jmp    139f <xputc+0x24f>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x1c(%rbp)
add    $0xffffffff,%eax
sub    $0x2,%eax
jb     12ca <xputc+0x17a>
jmp    12b9 <xputc+0x169>
mov    -0x1c(%rbp),%eax
sub    $0x9,%eax
je     12d8 <xputc+0x188>
jmp    138d <xputc+0x23d>
mov    -0x5(%rbp),%al
mov    %al,0x2d76(%rip)
jmp    1398 <xputc+0x248>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <prn_getwidth@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    1307 <xputc+0x1b7>
mov    -0x10(%rbp),%eax
add    $0xf,%eax
mov    %eax,-0x10(%rbp)
jmp    12df <xputc+0x18f>
mov    -0x10(%rbp),%eax
sub    $0xf,%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <prn_getcol@plt>
cmp    -0x10(%rbp),%eax
jl     1331 <xputc+0x1e1>
mov    $0xa,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    1388 <xputc+0x238>
mov    $0x0,%al
call   1060 <prn_getcol@plt>
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1355 <xputc+0x205>
mov    $0x20,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    135a <xputc+0x20a>
mov    $0x0,%al
call   1060 <prn_getcol@plt>
mov    $0xf,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
je     1383 <xputc+0x233>
mov    $0x20,%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
jmp    135a <xputc+0x20a>
jmp    1388 <xputc+0x238>
jmp    1398 <xputc+0x248>
movsbl -0x5(%rbp),%edi
mov    $0x0,%al
call   1030 <xxputc@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xputc>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xea4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <bwx_DEBUG@plt>
xor    %eax,%eax
call   1070 <prn_getwidth@plt>
test   %eax,%eax
je     11ab <xputc+0x5b>
mov    0x2ed3(%rip),%al
cmp    $0x1,%al
je     11bb <xputc+0x6b>
cmp    $0x2,%al
jne    1211 <xputc+0xc1>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %bpl,%ebx
xor    %eax,%eax
call   1070 <prn_getwidth@plt>
cmp    %ebx,%eax
jge    11e6 <xputc+0x96>
xor    %eax,%eax
call   1070 <prn_getwidth@plt>
sub    %al,%bpl
jmp    1190 <xputc+0x40>
movsbl %bpl,%edi
xor    %eax,%eax
call   1050 <xxxputc@plt>
jmp    1342 <xputc+0x1f2>
test   %bpl,%bpl
jle    1336 <xputc+0x1e6>
movsbl %bpl,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x20,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
add    $0xffffffff,%ebx
jne    11d0 <xputc+0x80>
jmp    1336 <xputc+0x1e6>
test   %bpl,%bpl
movzbl %bpl,%eax
mov    $0x1,%ecx
cmovne %eax,%ecx
movsbl %cl,%ebx
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cmp    %ebx,%eax
jle    1324 <xputc+0x1d4>
mov    $0xa,%edi
jmp    131d <xputc+0x1cd>
movsbl %bpl,%edi
lea    -0x1(%rdi),%eax
cmp    $0x2,%eax
jae    122b <xputc+0xdb>
mov    %bpl,0x2e25(%rip)
xor    %ebx,%ebx
jmp    1342 <xputc+0x1f2>
cmp    $0x9,%edi
jne    130b <xputc+0x1bb>
mov    $0xffffffe3,%ebp
nopl   0x0(%rax)
mov    %ebp,%ebx
xor    %eax,%eax
call   1070 <prn_getwidth@plt>
lea    0xf(%rbx),%ebp
add    $0x1e,%ebx
cmp    %eax,%ebx
jl     1240 <xputc+0xf0>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cmp    %ebp,%eax
jge    130f <xputc+0x1bf>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
jne    129f <xputc+0x14f>
mov    $0x20,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     1342 <xputc+0x1f2>
xor    %ebx,%ebx
xchg   %ax,%ax
mov    $0x20,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cltq
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x3,%ecx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
jne    12d0 <xputc+0x180>
jmp    1342 <xputc+0x1f2>
xor    %ebx,%ebx
jmp    1314 <xputc+0x1c4>
mov    $0xa,%edi
xor    %eax,%eax
call   1030 <xxputc@plt>
jmp    1342 <xputc+0x1f2>
xor    %eax,%eax
call   1030 <xxputc@plt>
xor    %eax,%eax
call   1060 <prn_getcol@plt>
cmp    %ebx,%eax
jge    1336 <xputc+0x1e6>
mov    $0x20,%edi
jmp    131d <xputc+0x1cd>
movb   $0x0,0x2d0c(%rip)
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@xputc.CHR_pending = internal global i8 0
@__FUNCTION__.xputc = [6 x i8] c"xputc\00"
define i32 @xputc(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i8 %0, i8* %3
%6 = call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__FUNCTION__.xputc, i64 0, i64 0))
%7 = call i32 (...) @prn_getwidth()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = load i8, i8* %3
%11 = sext i8 %10 to i32
%12 = call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %11)
store i32 0, i32* %2
br label %107
13: ; preds = %1
%14 = load i8, i8* @xputc.CHR_pending
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %29
17: ; preds = %13
store i32 0, i32* %4
br label %18
18: ; preds = %25, %17
%19 = load i32, i32* %4
%20 = load i8, i8* %3
%21 = sext i8 %20 to i32
%22 = icmp slt i32 %19, %21
br i1 %22, label %23, label %28
23: ; preds = %18
%24 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
br label %25
25: ; preds = %23
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 1
store i32 %27, i32* %4
br label %18
28: ; preds = %18
store i8 0, i8* @xputc.CHR_pending
store i32 -1, i32* %2
br label %107
29: ; preds = %13
%30 = load i8, i8* @xputc.CHR_pending
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %66
33: ; preds = %29
br label %34
34: ; preds = %39, %33
%35 = load i8, i8* %3
%36 = sext i8 %35 to i32
%37 = call i32 (...) @prn_getwidth()
%38 = icmp sgt i32 %36, %37
br i1 %38, label %39, label %45
39: ; preds = %34
%40 = call i32 (...) @prn_getwidth()
%41 = load i8, i8* %3
%42 = sext i8 %41 to i32
%43 = sub nsw i32 %42, %40
%44 = trunc i32 %43 to i8
store i8 %44, i8* %3
br label %34
45: ; preds = %34
%46 = load i8, i8* %3
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i8 1, i8* %3
br label %50
50: ; preds = %49, %45
%51 = load i8, i8* %3
%52 = sext i8 %51 to i32
%53 = call i32 (...) @prn_getcol()
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %57
57: ; preds = %55, %50
br label %58
58: ; preds = %63, %57
%59 = call i32 (...) @prn_getcol()
%60 = load i8, i8* %3
%61 = sext i8 %60 to i32
%62 = icmp slt i32 %59, %61
br i1 %62, label %63, label %65
63: ; preds = %58
%64 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
br label %58
65: ; preds = %58
store i8 0, i8* @xputc.CHR_pending
store i32 -1, i32* %2
br label %107
66: ; preds = %29
%67 = load i8, i8* %3
%68 = sext i8 %67 to i32
switch i32 %68, label %102 [
i32 1, label %69
i32 2, label %69
i32 9, label %71
]
69: ; preds = %66, %66
%70 = load i8, i8* %3
store i8 %70, i8* @xputc.CHR_pending
br label %106
71: ; preds = %66
store i32 1, i32* %5
br label %72
72: ; preds = %76, %71
%73 = load i32, i32* %5
%74 = call i32 (...) @prn_getwidth()
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i32, i32* %5
%78 = add nsw i32 %77, 15
store i32 %78, i32* %5
br label %72
79: ; preds = %72
%80 = load i32, i32* %5
%81 = sub nsw i32 %80, 15
store i32 %81, i32* %5
%82 = call i32 (...) @prn_getcol()
%83 = load i32, i32* %5
%84 = icmp sge i32 %82, %83
br i1 %84, label %85, label %87
85: ; preds = %79
%86 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %101
87: ; preds = %79
%88 = call i32 (...) @prn_getcol()
%89 = srem i32 %88, 15
%90 = icmp eq i32 %89, 1
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
br label %93
93: ; preds = %91, %87
br label %94
94: ; preds = %98, %93
%95 = call i32 (...) @prn_getcol()
%96 = srem i32 %95, 15
%97 = icmp ne i32 %96, 1
br i1 %97, label %98, label %100
98: ; preds = %94
%99 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
br label %94
100: ; preds = %94
br label %101
101: ; preds = %100, %85
br label %106
102: ; preds = %66
%103 = load i8, i8* %3
%104 = sext i8 %103 to i32
%105 = call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 %104)
br label %106
106: ; preds = %102, %101, %69
store i32 0, i32* %2
br label %107
107: ; preds = %106, %65, %28, %9
%108 = load i32, i32* %2
ret i32 %108
}

LLVM IR (-O2):
@xputc.CHR_pending = internal unnamed_addr global i8 0
@__FUNCTION__.xputc = [6 x i8] c"xputc\00"
define i32 @xputc(i8 signext %0) {
%2 = tail call i32 (i8*, ...) bitcast (i32 (...)* @bwx_DEBUG to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__FUNCTION__.xputc, i64 0, i64 0))
%3 = tail call i32 (...) @prn_getwidth()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = sext i8 %0 to i32
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxxputc to i32 (i32, ...)*)(i32 %6)
br label %79
8: ; preds = %1
%9 = load i8, i8* @xputc.CHR_pending
switch i8 %9, label %48 [
i8 1, label %14
i8 2, label %10
]
10: ; preds = %8
%11 = sext i8 %0 to i32
%12 = tail call i32 (...) @prn_getwidth()
%13 = icmp slt i32 %12, %11
br i1 %13, label %23, label %31
14: ; preds = %8
%15 = sext i8 %0 to i32
%16 = icmp sgt i8 %0, 0
br i1 %16, label %17, label %22
17: ; preds = %14, %17
%18 = phi i32 [ %20, %17 ], [ 0, %14 ]
%19 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
%20 = add nuw nsw i32 %18, 1
%21 = icmp eq i32 %20, %15
br i1 %21, label %22, label %17
22: ; preds = %17, %14
store i8 0, i8* @xputc.CHR_pending
br label %79
23: ; preds = %10, %23
%24 = phi i8 [ %27, %23 ], [ %0, %10 ]
%25 = tail call i32 (...) @prn_getwidth()
%26 = trunc i32 %25 to i8
%27 = sub i8 %24, %26
%28 = sext i8 %27 to i32
%29 = tail call i32 (...) @prn_getwidth()
%30 = icmp slt i32 %29, %28
br i1 %30, label %23, label %31
31: ; preds = %23, %10
%32 = phi i8 [ %0, %10 ], [ %27, %23 ]
%33 = icmp eq i8 %32, 0
%34 = select i1 %33, i8 1, i8 %32
%35 = sext i8 %34 to i32
%36 = tail call i32 (...) @prn_getcol()
%37 = icmp sgt i32 %36, %35
br i1 %37, label %38, label %40
38: ; preds = %31
%39 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %40
40: ; preds = %38, %31
%41 = tail call i32 (...) @prn_getcol()
%42 = icmp slt i32 %41, %35
br i1 %42, label %43, label %47
43: ; preds = %40, %43
%44 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
%45 = tail call i32 (...) @prn_getcol()
%46 = icmp slt i32 %45, %35
br i1 %46, label %43, label %47
47: ; preds = %43, %40
store i8 0, i8* @xputc.CHR_pending
br label %79
48: ; preds = %8
%49 = sext i8 %0 to i32
switch i32 %49, label %77 [
i32 1, label %50
i32 2, label %50
i32 9, label %51
]
50: ; preds = %48, %48
store i8 %0, i8* @xputc.CHR_pending
br label %79
51: ; preds = %48, %51
%52 = phi i32 [ %55, %51 ], [ 1, %48 ]
%53 = tail call i32 (...) @prn_getwidth()
%54 = icmp slt i32 %52, %53
%55 = add nuw nsw i32 %52, 15
br i1 %54, label %51, label %56
56: ; preds = %51
%57 = add nsw i32 %52, -15
%58 = tail call i32 (...) @prn_getcol()
%59 = icmp slt i32 %58, %57
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 10)
br label %79
62: ; preds = %56
%63 = tail call i32 (...) @prn_getcol()
%64 = srem i32 %63, 15
%65 = icmp eq i32 %64, 1
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
br label %68
68: ; preds = %66, %62
%69 = tail call i32 (...) @prn_getcol()
%70 = srem i32 %69, 15
%71 = icmp eq i32 %70, 1
br i1 %71, label %79, label %72
72: ; preds = %68, %72
%73 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 32)
%74 = tail call i32 (...) @prn_getcol()
%75 = srem i32 %74, 15
%76 = icmp eq i32 %75, 1
br i1 %76, label %79, label %72
77: ; preds = %48
%78 = tail call i32 (i32, ...) bitcast (i32 (...)* @xxputc to i32 (i32, ...)*)(i32 %49)
br label %79
79: ; preds = %72, %68, %50, %77, %60, %47, %22, %5
%80 = phi i32 [ 0, %5 ], [ -1, %22 ], [ -1, %47 ], [ 0, %60 ], [ 0, %77 ], [ 0, %50 ], [ 0, %68 ], [ 0, %72 ]
ret i32 %80
}