#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void print_keyroots(int *keyroots) {
  int i;
  printf("--->  key roots  <---\n\n");
  printf("entries: %d\n", keyroots[0]);
  printf("{");
  for (i = 1; i <= keyroots[0]; i++)
    printf(" %d", keyroots[i]);
  printf(" }\n\n");
}


x86 assembly (clang, -O0):
<print_keyroots>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jg     1189 <print_keyroots+0x79>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <print_keyroots+0x43>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_keyroots>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
lea    0xed2(%rip),%rdi
call   1040 <puts@plt>
mov    (%r15),%esi
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7b,%edi
call   1030 <putchar@plt>
cmpl   $0x0,(%r15)
jle    118b <print_keyroots+0x5b>
lea    0xea1(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    0x4(%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movslq (%r15),%rax
add    $0x1,%rbx
cmp    %rax,%rbx
jl     1170 <print_keyroots+0x40>
lea    0xe96(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"---> key roots <---\0A\0A\00"
@.str.1 = [13 x i8] c"entries: %d\0A\00"
@.str.2 = [2 x i8] c"{\00"
@.str.3 = [4 x i8] c" %d\00"
@.str.4 = [5 x i8] c" }\0A\0A\00"
define void @print_keyroots(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = load i32*, i32** %2
%6 = getelementptr inbounds i32, i32* %5, i64 0
%7 = load i32, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %10
10: ; preds = %23, %1
%11 = load i32, i32* %3
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 0
%14 = load i32, i32* %13
%15 = icmp sle i32 %11, %14
br i1 %15, label %16, label %26
16: ; preds = %10
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %10
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"entries: %d\0A\00"
@.str.3 = [4 x i8] c" %d\00"
@str = [23 x i8] c"---> key roots <---\0A\00"
@str.5 = [4 x i8] c" }\0A\00"
define void @print_keyroots(i32* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%3 = load i32, i32* %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = tail call i32 @putchar(i32 123)
%6 = load i32, i32* %0
%7 = icmp slt i32 %6, 1
br i1 %7, label %17, label %8
8: ; preds = %1, %8
%9 = phi i64 [ %13, %8 ], [ 1, %1 ]
%10 = getelementptr inbounds i32, i32* %0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = add nuw nsw i64 %9, 1
%14 = load i32, i32* %0
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %9, %15
br i1 %16, label %8, label %17
17: ; preds = %8, %1
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.5, i64 0, i64 0))
ret void
}