int read_log(int oftIndex, char *buffer, int count) {
  const int status = read(oftIndex, buffer, count);
  printf("READ FILE %d: %s\n", oftIndex, getStatusText(status));
  if (status >= 0)
    printf("READ DATA: \"%.*s\"\n", count, buffer);
  return status;
}


x86 assembly (clang, -O0):
<read_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1040 <read@plt>
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%edi
mov    $0x0,%al
call   1050 <getStatusText@plt>
mov    -0x1c(%rbp),%esi
mov    %eax,%edx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x18(%rbp)
jl     1198 <read_log+0x68>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_log>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <read@plt>
mov    %eax,%ebx
mov    %eax,%edi
xor    %eax,%eax
call   1050 <getStatusText@plt>
lea    0xea8(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   %ebx,%ebx
js     117b <read_log+0x4b>
lea    0xea4(%rip),%rdi
mov    %r15d,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"READ FILE %d: %s\0A\00"
@.str.1 = [19 x i8] c"READ DATA: \22%.*s\22\0A\00"
define i32 @read_log(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %8, i8* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %4
%13 = load i32, i32* %7
%14 = call i32 (i32, ...) bitcast (i32 (...)* @getStatusText to i32 (i32, ...)*)(i32 %13)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14)
%16 = load i32, i32* %7
%17 = icmp sge i32 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %3
%19 = load i32, i32* %6
%20 = load i8*, i8** %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %19, i8* %20)
br label %22
22: ; preds = %18, %3
%23 = load i32, i32* %7
ret i32 %23
}

LLVM IR (-O2):
@.str = [18 x i8] c"READ FILE %d: %s\0A\00"
@.str.1 = [19 x i8] c"READ DATA: \22%.*s\22\0A\00"
define i32 @read_log(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %1, i32 %2)
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @getStatusText to i32 (i32, ...)*)(i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %5)
%7 = icmp sgt i32 %4, -1
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* %1)
br label %10
10: ; preds = %8, %3
ret i32 %4
}