void print_message_line(char *message) {
  char *crlf;
  crlf = strchr(message, '\n');
  if (!crlf) {
    printf("failed to find newline\n");
    exit_code(254, __PRETTY_FUNCTION__, "missing newline in buffer");
  } else if (*(crlf - 1) == '\r')
    crlf--;
  printf("%.*s\n", (int)(crlf - message), message);
}


x86 assembly (clang, -O0):
<print_message_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1186 <print_message_line+0x56>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xfe,%edi
lea    0xea5(%rip),%rsi
lea    0xebe(%rip),%rdx
mov    $0x0,%al
call   1050 <exit_code@plt>
jmp    11a8 <print_message_line+0x78>
mov    -0x10(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0xd,%eax
jne    11a3 <print_message_line+0x73>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    11a8 <print_message_line+0x78>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
mov    -0x8(%rbp),%rdx
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_message_line>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0xa,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1164 <print_message_line+0x24>
lea    -0x1(%rax),%rbx
cmpb   $0xd,-0x1(%rax)
cmovne %rax,%rbx
jmp    118c <print_message_line+0x4c>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rsi
lea    0xea2(%rip),%rdx
xor    %ebx,%ebx
mov    $0xfe,%edi
xor    %eax,%eax
call   1060 <exit_code@plt>
sub    %r14d,%ebx
lea    0xea4(%rip),%rdi
mov    %ebx,%esi
mov    %r14,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"failed to find newline\0A\00"
@__PRETTY_FUNCTION__.print_message_line = [32 x i8] c"void print_message_line(char *)\00"
@.str.1 = [26 x i8] c"missing newline in buffer\00"
@.str.2 = [6 x i8] c"%.*s\0A\00"
define void @print_message_line(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i8* @strchr(i8* %4, i32 10)
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @exit_code to i32 (i32, i8*, i8*, ...)*)(i32 254, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__PRETTY_FUNCTION__.print_message_line, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %21
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 -1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 13
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 -1
store i8* %19, i8** %3
br label %20
20: ; preds = %17, %11
br label %21
21: ; preds = %20, %8
%22 = load i8*, i8** %3
%23 = load i8*, i8** %2
%24 = ptrtoint i8* %22 to i64
%25 = ptrtoint i8* %23 to i64
%26 = sub i64 %24, %25
%27 = trunc i64 %26 to i32
%28 = load i8*, i8** %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %27, i8* %28)
ret void
}

LLVM IR (-O2):
@__PRETTY_FUNCTION__.print_message_line = [32 x i8] c"void print_message_line(char *)\00"
@.str.1 = [26 x i8] c"missing newline in buffer\00"
@.str.2 = [6 x i8] c"%.*s\0A\00"
@str = [23 x i8] c"failed to find newline\00"
define void @print_message_line(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 10)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i32, i8*, i8*, ...) bitcast (i32 (...)* @exit_code to i32 (i32, i8*, i8*, ...)*)(i32 254, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @__PRETTY_FUNCTION__.print_message_line, i64 0, i64 0), i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %13
7: ; preds = %1
%8 = getelementptr inbounds i8, i8* %2, i64 -1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 13
%11 = select i1 %10, i8* %8, i8* %2
%12 = ptrtoint i8* %11 to i64
br label %13
13: ; preds = %7, %4
%14 = phi i64 [ 0, %4 ], [ %12, %7 ]
%15 = ptrtoint i8* %0 to i64
%16 = sub i64 %14, %15
%17 = trunc i64 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %0)
ret void
}