cat_jobs_output(f, w, out, pt) int f;
int w;
char *out;
char *pt;
{
  char *output;
  output = out + strlen(out);
  if (out != output) {
    *output++ = ' ';
    *output = '\0';
  }
  switch (f) {
  case 'c':
    sprintf(output, "%s", pt);
    break;
  case 'C':
    if (w < 20)
      sprintf(output, "%-*s", w, pt);
    else
      sprintf(output, "%-20.20s", pt);
    break;
  case 'D':
    if (w < 20)
      sprintf(output, "%-*s", w, pt);
    else {
      int len;
      len = strlen(pt) - 20;
      if (len < 0)
        len = 0;
      sprintf(output, "%-20.20s", pt + len);
    }
    break;
  case 'd':
  case 'a':
    sprintf(output, "%-*s", w, pt);
    break;
  default:
    sprintf(output, "%*s", w, pt);
    break;
  }
}


x86 assembly (clang, -O0):
<cat_jobs_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     117c <cat_jobs_output+0x5c>
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
movb   $0x20,(%rax)
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%eax
add    $0xffffffbd,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x21,%eax
ja     128c <cat_jobs_output+0x16c>
mov    -0x40(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xed4(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    12a5 <cat_jobs_output+0x185>
cmpl   $0x14,-0xc(%rbp)
jge    11e8 <cat_jobs_output+0xc8>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xeaf(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    11fe <cat_jobs_output+0xde>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    12a5 <cat_jobs_output+0x185>
cmpl   $0x14,-0xc(%rbp)
jge    122b <cat_jobs_output+0x10b>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe6c(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    1269 <cat_jobs_output+0x149>
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x14,%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    124c <cat_jobs_output+0x12c>
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x2c(%rbp),%rax
add    %rax,%rdx
lea    0xe2e(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    12a5 <cat_jobs_output+0x185>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe0b(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    12a5 <cat_jobs_output+0x185>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cat_jobs_output>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%r15d
mov    %edi,%ebp
mov    %rdx,%rdi
call   1040 <strlen@plt>
add    %rax,%rbx
test   %rax,%rax
je     115b <cat_jobs_output+0x2b>
movw   $0x20,(%rbx)
add    $0x1,%rbx
add    $0xffffffbd,%ebp
cmp    $0x21,%ebp
ja     117b <cat_jobs_output+0x4b>
lea    0xe96(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cmp    $0x13,%r15d
jle    118a <cat_jobs_output+0x5a>
jmp    11c3 <cat_jobs_output+0x93>
lea    0xf14(%rip),%rsi
jmp    1191 <cat_jobs_output+0x61>
cmp    $0x13,%r15d
jg     11b0 <cat_jobs_output+0x80>
lea    0xef7(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    11d7 <cat_jobs_output+0xa7>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
jmp    11d7 <cat_jobs_output+0xa7>
mov    %r14,%rdi
call   1040 <strlen@plt>
xor    %ecx,%ecx
add    $0xffffffec,%eax
cmovs  %ecx,%eax
add    %rax,%r14
lea    0xec3(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"%-*s\00"
@.str.2 = [9 x i8] c"%-20.20s\00"
@.str.3 = [4 x i8] c"%*s\00"
define i32 @cat_jobs_output(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%12 = load i8*, i8** %8
%13 = load i8*, i8** %8
%14 = call i64 @strlen(i8* %13)
%15 = getelementptr inbounds i8, i8* %12, i64 %14
store i8* %15, i8** %10
%16 = load i8*, i8** %8
%17 = load i8*, i8** %10
%18 = icmp ne i8* %16, %17
br i1 %18, label %19, label %23
19: ; preds = %4
%20 = load i8*, i8** %10
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %10
store i8 32, i8* %20
%22 = load i8*, i8** %10
store i8 0, i8* %22
br label %23
23: ; preds = %19, %4
%24 = load i32, i32* %6
switch i32 %24, label %71 [
i32 99, label %25
i32 67, label %29
i32 68, label %42
i32 100, label %66
i32 97, label %66
]
25: ; preds = %23
%26 = load i8*, i8** %10
%27 = load i8*, i8** %9
%28 = call i32 (i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %76
29: ; preds = %23
%30 = load i32, i32* %7
%31 = icmp slt i32 %30, 20
br i1 %31, label %32, label %37
32: ; preds = %29
%33 = load i8*, i8** %10
%34 = load i32, i32* %7
%35 = load i8*, i8** %9
%36 = call i32 (i8*, i8*, ...) @sprintf(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %34, i8* %35)
br label %41
37: ; preds = %29
%38 = load i8*, i8** %10
%39 = load i8*, i8** %9
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %39)
br label %41
41: ; preds = %37, %32
br label %76
42: ; preds = %23
%43 = load i32, i32* %7
%44 = icmp slt i32 %43, 20
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load i8*, i8** %10
%47 = load i32, i32* %7
%48 = load i8*, i8** %9
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %46, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %47, i8* %48)
br label %65
50: ; preds = %42
%51 = load i8*, i8** %9
%52 = call i64 @strlen(i8* %51)
%53 = sub i64 %52, 20
%54 = trunc i64 %53 to i32
store i32 %54, i32* %11
%55 = load i32, i32* %11
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %50
store i32 0, i32* %11
br label %58
58: ; preds = %57, %50
%59 = load i8*, i8** %10
%60 = load i8*, i8** %9
%61 = load i32, i32* %11
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %63)
br label %65
65: ; preds = %58, %45
br label %76
66: ; preds = %23, %23
%67 = load i8*, i8** %10
%68 = load i32, i32* %7
%69 = load i8*, i8** %9
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %68, i8* %69)
br label %76
71: ; preds = %23
%72 = load i8*, i8** %10
%73 = load i32, i32* %7
%74 = load i8*, i8** %9
%75 = call i32 (i8*, i8*, ...) @sprintf(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %73, i8* %74)
br label %76
76: ; preds = %71, %66, %65, %41, %25
%77 = load i32, i32* %5
ret i32 %77
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%-*s\00"
@.str.2 = [9 x i8] c"%-20.20s\00"
@.str.3 = [4 x i8] c"%*s\00"
define i32 @cat_jobs_output(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = getelementptr inbounds i8, i8* %2, i64 %5
%7 = icmp eq i64 %5, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = getelementptr inbounds i8, i8* %6, i64 1
store i8 32, i8* %6
store i8 0, i8* %9
br label %10
10: ; preds = %8, %4
%11 = phi i8* [ %9, %8 ], [ %6, %4 ]
switch i32 %0, label %35 [
i32 99, label %12
i32 67, label %14
i32 68, label %20
i32 100, label %33
i32 97, label %33
]
12: ; preds = %10
%13 = tail call i8* @strcpy(i8* dereferenceable(1) %11, i8* dereferenceable(1) %3)
br label %37
14: ; preds = %10
%15 = icmp slt i32 %1, 20
br i1 %15, label %16, label %18
16: ; preds = %14
%17 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %3)
br label %37
18: ; preds = %14
%19 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %37
20: ; preds = %10
%21 = icmp slt i32 %1, 20
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %3)
br label %37
24: ; preds = %20
%25 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%26 = trunc i64 %25 to i32
%27 = add i32 %26, -20
%28 = icmp sgt i32 %27, 0
%29 = select i1 %28, i32 %27, i32 0
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %3, i64 %30
%32 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %31)
br label %37
33: ; preds = %10, %10
%34 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %1, i8* %3)
br label %37
35: ; preds = %10
%36 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %1, i8* %3)
br label %37
37: ; preds = %22, %24, %16, %18, %35, %33, %12
ret i32 undef
}