void do_prompt(op, tp) struct options *op;
struct termios *tp;
{
  (void)write(1, "\r\n", 2);
  {
    char hn[64 + 1];
    if (gethostname(hn, sizeof(hn)) == 0)
      write(1, hn, strlen(hn));
  }
  (void)write(1, " login: ", sizeof(" login: ") - 1);
}


x86 assembly (clang, -O0):
<do_prompt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
lea    0xeb4(%rip),%rsi
mov    $0x2,%edx
mov    $0x0,%al
call   1030 <write@plt>
lea    -0x60(%rbp),%rdi
mov    $0x41,%esi
mov    $0x0,%al
call   1050 <gethostname@plt>
cmp    $0x0,%eax
jne    1195 <do_prompt+0x65>
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x68(%rbp),%rsi
mov    %rax,%rdx
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <write@plt>
mov    $0x1,%edi
lea    0xe62(%rip),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1030 <write@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_prompt>:
push   %rbx
sub    $0x50,%rsp
lea    0xec4(%rip),%rsi
mov    $0x1,%edi
mov    $0x2,%edx
xor    %eax,%eax
call   1030 <write@plt>
mov    %rsp,%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1050 <gethostname@plt>
test   %eax,%eax
jne    117d <do_prompt+0x4d>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <write@plt>
lea    0xe7f(%rip),%rsi
mov    $0x8,%edx
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <write@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.options = type opaque
%struct.termios = type opaque
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [9 x i8] c" login: \00"
define void @do_prompt(%struct.options* %0, %struct.termios* %1) {
%3 = alloca %struct.options*
%4 = alloca %struct.termios*
%5 = alloca [65 x i8]
store %struct.options* %0, %struct.options** %3
store %struct.termios* %1, %struct.termios** %4
%6 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%8 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @gethostname to i32 (i8*, i64, ...)*)(i8* %7, i64 65)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [65 x i8], [65 x i8]* %5, i64 0, i64 0
%13 = call i64 @strlen(i8* %12)
%14 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i64, ...)*)(i32 1, i8* %11, i64 %13)
br label %15
15: ; preds = %10, %2
%16 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i64, ...)*)(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8)
ret void
}

LLVM IR (-O2):
%struct.options = type opaque
%struct.termios = type opaque
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [9 x i8] c" login: \00"
define void @do_prompt(%struct.options* nocapture readnone %0, %struct.termios* nocapture readnone %1) {
%3 = alloca [65 x i8]
%4 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i32, ...)*)(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = getelementptr inbounds [65 x i8], [65 x i8]* %3, i64 0, i64 0
%6 = call i32 (i8*, i64, ...) bitcast (i32 (...)* @gethostname to i32 (i8*, i64, ...)*)(i8* %5, i64 65)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i64 @strlen(i8* %5)
%10 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i64, ...)*)(i32 1, i8* %5, i64 %9)
br label %11
11: ; preds = %8, %2
%12 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @write to i32 (i32, i8*, i64, ...)*)(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i64 8)
ret void
}