#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 *, int);
int /*<<< orphan*/ putchar(char);
void print_counts(char *buf, int start, int end, int nsyls) {
  for (int j = start; j <= end; j++)
    putchar(buf[j]);
  printf(": %d\n", nsyls);
}


x86 assembly (clang, -O0):
<print_counts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1166 <print_counts+0x46>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113b <print_counts+0x1b>
mov    -0x14(%rbp),%esi
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_counts>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
cmp    %edx,%esi
jg     1152 <print_counts+0x32>
mov    %edx,%ebx
mov    %rdi,%r15
movslq %esi,%rax
add    %rax,%r15
sub    %esi,%ebx
add    $0x1,%ebx
xor    %ebp,%ebp
movsbl (%r15,%rbp,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    1140 <print_counts+0x20>
lea    0xea7(%rip),%rdi
mov    %r14d,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

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