#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct simple_stats {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long, char *);
int /*<<< orphan*/ simple_stats_to_string(struct simple_stats *, char *, size_t,
                                          int /*<<< orphan*/ *);
void _display_stats(FILE *out, struct simple_stats **stats, size_t len,
                    char *line_buf, size_t line_buf_len) {
  size_t i;
  for (i = 0; i < len; i++) {
    simple_stats_to_string(stats[i], line_buf, line_buf_len, NULL);
    fprintf(out, "%lu: %s\n", (unsigned long)i, line_buf);
  }
}


x86 assembly (clang, -O0):
<_display_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1198 <_display_stats+0x78>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1040 <simple_stats_to_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe7e(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1144 <_display_stats+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_display_stats>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %rdx,%rdx
je     117f <_display_stats+0x5f>
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <simple_stats_to_string@plt>
mov    %r13,%rdi
lea    0xe95(%rip),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1030 <fprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1150 <_display_stats+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.simple_stats = type { i32 }
@.str = [9 x i8] c"%lu: %s\0A\00"
define void @_display_stats(i32* %0, %struct.simple_stats** %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i32*
%7 = alloca %struct.simple_stats**
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i32* %0, i32** %6
store %struct.simple_stats** %1, %struct.simple_stats*** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
store i64 0, i64* %11
br label %12
12: ; preds = %28, %5
%13 = load i64, i64* %11
%14 = load i64, i64* %8
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %31
16: ; preds = %12
%17 = load %struct.simple_stats**, %struct.simple_stats*** %7
%18 = load i64, i64* %11
%19 = getelementptr inbounds %struct.simple_stats*, %struct.simple_stats** %17, i64 %18
%20 = load %struct.simple_stats*, %struct.simple_stats** %19
%21 = load i8*, i8** %9
%22 = load i64, i64* %10
%23 = call i32 @simple_stats_to_string(%struct.simple_stats* %20, i8* %21, i64 %22, i32* null)
%24 = load i32*, i32** %6
%25 = load i64, i64* %11
%26 = load i8*, i8** %9
%27 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %25, i8* %26)
br label %28
28: ; preds = %16
%29 = load i64, i64* %11
%30 = add i64 %29, 1
store i64 %30, i64* %11
br label %12
31: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.simple_stats = type { i32 }
@.str = [9 x i8] c"%lu: %s\0A\00"
define void @_display_stats(i32* nocapture %0, %struct.simple_stats** nocapture %1, i64 %2, i8* %3, i64 %4) {
%6 = icmp eq i64 %2, 0
br i1 %6, label %15, label %7
7: ; preds = %5, %7
%8 = phi i64 [ %13, %7 ], [ 0, %5 ]
%9 = getelementptr inbounds %struct.simple_stats*, %struct.simple_stats** %1, i64 %8
%10 = load %struct.simple_stats*, %struct.simple_stats** %9
%11 = tail call i32 @simple_stats_to_string(%struct.simple_stats* %10, i8* %3, i64 %4, i32* null)
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i64 %8, i8* %3)
%13 = add nuw i64 %8, 1
%14 = icmp eq i64 %13, %2
br i1 %14, label %15, label %7
15: ; preds = %7, %5
ret void
}