int hputs(hstring, keyword, cval)
char *hstring;
char *keyword;
char *cval;
{
  char squot = 39;
  char value[80];
  int lcval, i, lkeyword;
  lkeyword = strlen(keyword);
  if (lkeyword == 7 && (strncmp(keyword, "COMMENT", 7) == 0 ||
                        strncmp(keyword, "HISTORY", 7) == 0))
    return (hputc(hstring, keyword, cval));
  lcval = strlen(cval);
  if (lcval > 67)
    lcval = 67;
  value[0] = squot;
  strncpy(&value[1], cval, lcval);
  if (lcval < 8) {
    for (i = lcval; i < 8; i++) {
      value[i + 1] = ' ';
    }
    lcval = 8;
  }
  value[lcval + 1] = squot;
  value[lcval + 2] = (char)0;
  return (hputc(hstring, keyword, value));
}


x86 assembly (clang, -O0):
<hputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movb   $0x27,-0x21(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x8c(%rbp)
cmpl   $0x7,-0x8c(%rbp)
jne    11ce <hputs+0x8e>
mov    -0x18(%rbp),%rdi
lea    0xe7e(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
je     11b3 <hputs+0x73>
mov    -0x18(%rbp),%rdi
lea    0xe68(%rip),%rsi
mov    $0x7,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%eax
jne    11ce <hputs+0x8e>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1060 <hputc@plt>
mov    %eax,-0x4(%rbp)
jmp    129e <hputs+0x15e>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x43,-0x84(%rbp)
jle    11f4 <hputs+0xb4>
movl   $0x43,-0x84(%rbp)
mov    -0x21(%rbp),%al
mov    %al,-0x80(%rbp)
lea    -0x80(%rbp),%rdi
add    $0x1,%rdi
mov    -0x20(%rbp),%rsi
movslq -0x84(%rbp),%rdx
call   1030 <strncpy@plt>
cmpl   $0x8,-0x84(%rbp)
jge    1266 <hputs+0x126>
mov    -0x84(%rbp),%eax
mov    %eax,-0x88(%rbp)
cmpl   $0x8,-0x88(%rbp)
jge    125c <hputs+0x11c>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x20,-0x80(%rbp,%rax,1)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    122b <hputs+0xeb>
movl   $0x8,-0x84(%rbp)
mov    -0x21(%rbp),%cl
mov    -0x84(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x84(%rbp),%eax
add    $0x2,%eax
cltq
movb   $0x0,-0x80(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x80(%rbp),%rdx
mov    $0x0,%al
call   1060 <hputc@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hputs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <strlen@plt>
cmp    $0x7,%eax
jne    11ac <hputs+0x5c>
lea    0xe85(%rip),%rsi
mov    $0x7,%edx
mov    %r15,%rdi
call   1040 <strncmp@plt>
test   %eax,%eax
je     1236 <hputs+0xe6>
lea    0xe71(%rip),%rsi
mov    $0x7,%edx
mov    %r15,%rdi
call   1040 <strncmp@plt>
test   %eax,%eax
je     1236 <hputs+0xe6>
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %rax,%r13
cmp    $0x43,%r13d
mov    $0x43,%ebp
cmovl  %r13d,%ebp
movb   $0x27,(%rsp)
lea    0x1(%rsp),%rdi
movslq %ebp,%rbx
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <strncpy@plt>
cmp    $0x7,%ebx
jg     120e <hputs+0xbe>
mov    $0x8,%ebp
cmp    $0x7,%r13d
jg     120e <hputs+0xbe>
movslq %r13d,%rax
mov    %rsp,%rcx
lea    (%rax,%rcx,1),%rdi
add    $0x1,%rdi
mov    $0x7,%edx
sub    %eax,%edx
add    $0x1,%rdx
mov    $0x20,%esi
call   1060 <memset@plt>
mov    %ebp,%eax
mov    %rsp,%rdx
movw   $0x27,0x1(%rax,%rdx,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <hputc@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <hputc@plt>

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

LLVM IR (-O2):
@.str = [8 x i8] c"COMMENT\00"
@.str.1 = [8 x i8] c"HISTORY\00"
define i32 @hputs(i8* %0, i8* %1, i8* %2) {
%4 = alloca [80 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = trunc i64 %6 to i32
%8 = icmp eq i32 %7, 7
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @strncmp(i8* dereferenceable(1) %1, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64 7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12, %9
%16 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @hputc to i32 (i8*, i8*, i8*, ...)*)(i8* %0, i8* %1, i8* %2)
br label %45
17: ; preds = %12, %3
%18 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%19 = trunc i64 %18 to i32
%20 = icmp slt i32 %19, 67
%21 = select i1 %20, i32 %19, i32 67
store i8 39, i8* %5
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 1
%23 = sext i32 %21 to i64
%24 = call i8* @strncpy(i8* %22, i8* %2, i64 %23)
%25 = icmp slt i32 %21, 8
br i1 %25, label %26, label %36
26: ; preds = %17
%27 = icmp slt i32 %19, 8
br i1 %27, label %28, label %36
28: ; preds = %26
%29 = shl i64 %18, 32
%30 = ashr exact i64 %29, 32
%31 = add nsw i64 %30, 1
%32 = getelementptr [80 x i8], [80 x i8]* %4, i64 0, i64 %31
%33 = sub i64 7, %18
%34 = and i64 %33, 4294967295
%35 = add nuw nsw i64 %34, 1
br label %36
36: ; preds = %28, %26, %17
%37 = phi i32 [ %21, %17 ], [ 8, %26 ], [ 8, %28 ]
%38 = add nuw nsw i32 %37, 1
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %39
store i8 39, i8* %40
%41 = add nuw nsw i32 %37, 2
%42 = zext i32 %41 to i64
%43 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 %42
store i8 0, i8* %43
%44 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @hputc to i32 (i8*, i8*, i8*, ...)*)(i8* %0, i8* %1, i8* %5)
br label %45
45: ; preds = %36, %15
%46 = phi i32 [ %16, %15 ], [ %44, %36 ]
ret i32 %46
}