#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 stub1(int, int, char *, int);
int displayhiststr(int i_fh, int (*getProc)(int, int, char *, int), char *name,
                   int nh) {
  char str[64];
  int j;
  for (j = 1; j <= nh; j++) {
    if ((*getProc)(i_fh, j, str, 64) == 0)
      return 0;
    if (j == 1)
      printf("%-12s %s", name, str);
    else
      printf(",%s", str);
  }
  printf("\n");
  return 1;
}


x86 assembly (clang, -O0):
<displayhiststr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     11ad <displayhiststr+0x9d>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%edi
mov    -0x64(%rbp),%esi
lea    -0x60(%rbp),%rdx
mov    $0x40,%ecx
call   *%rax
cmp    $0x0,%eax
jne    1163 <displayhiststr+0x53>
movl   $0x0,-0x4(%rbp)
jmp    11c2 <displayhiststr+0xb2>
cmpl   $0x1,-0x64(%rbp)
jne    1188 <displayhiststr+0x78>
mov    -0x18(%rbp),%rsi
lea    -0x60(%rbp),%rdx
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119a <displayhiststr+0x8a>
lea    -0x60(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <displayhiststr+0x8f>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    112d <displayhiststr+0x1d>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<displayhiststr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %ecx,%ecx
jle    11a7 <displayhiststr+0x87>
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r13d
neg    %ebx
mov    $0x1,%r12d
mov    %rsp,%rbp
jmp    1176 <displayhiststr+0x56>
nopw   0x0(%rax,%rax,1)
lea    0xeb2(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%r12,1),%eax
add    $0x1,%eax
mov    %r12d,%ecx
add    $0x1,%ecx
mov    %ecx,%r12d
cmp    $0x1,%eax
je     11a7 <displayhiststr+0x87>
mov    %r13d,%edi
mov    %r12d,%esi
mov    %rbp,%rdx
mov    $0x40,%ecx
call   *%r15
test   %eax,%eax
je     11b8 <displayhiststr+0x98>
cmp    $0x1,%r12d
jne    1150 <displayhiststr+0x30>
lea    0xe68(%rip),%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1161 <displayhiststr+0x41>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%eax
jmp    11ba <displayhiststr+0x9a>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%-12s %s\00"
@.str.1 = [4 x i8] c",%s\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @displayhiststr(i32 %0, i32 (i32, i32, i8*, i32)* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32 (i32, i32, i8*, i32)*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [64 x i8]
%11 = alloca i32
store i32 %0, i32* %6
store i32 (i32, i32, i8*, i32)* %1, i32 (i32, i32, i8*, i32)** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 1, i32* %11
br label %12
12: ; preds = %35, %4
%13 = load i32, i32* %11
%14 = load i32, i32* %9
%15 = icmp sle i32 %13, %14
br i1 %15, label %16, label %38
16: ; preds = %12
%17 = load i32 (i32, i32, i8*, i32)*, i32 (i32, i32, i8*, i32)** %7
%18 = load i32, i32* %6
%19 = load i32, i32* %11
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%21 = call i32 %17(i32 %18, i32 %19, i8* %20, i32 64)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
store i32 0, i32* %5
br label %40
24: ; preds = %16
%25 = load i32, i32* %11
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i8*, i8** %8
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29)
br label %34
31: ; preds = %24
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %31, %27
br label %35
35: ; preds = %34
%36 = load i32, i32* %11
%37 = add nsw i32 %36, 1
store i32 %37, i32* %11
br label %12
38: ; preds = %12
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %5
br label %40
40: ; preds = %38, %23
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
@.str = [9 x i8] c"%-12s %s\00"
@.str.1 = [4 x i8] c",%s\00"
define i32 @displayhiststr(i32 %0, i32 (i32, i32, i8*, i32)* nocapture %1, i8* %2, i32 %3) {
%5 = alloca [64 x i8]
%6 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%7 = icmp slt i32 %3, 1
br i1 %7, label %21, label %8
8: ; preds = %4, %18
%9 = phi i32 [ %19, %18 ], [ 1, %4 ]
%10 = call i32 %1(i32 %0, i32 %9, i8* %6, i32 64)
%11 = icmp eq i32 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %8
%13 = icmp eq i32 %9, 1
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %6)
br label %18
16: ; preds = %12
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %18
18: ; preds = %14, %16
%19 = add nuw i32 %9, 1
%20 = icmp eq i32 %9, %3
br i1 %20, label %21, label %8
21: ; preds = %18, %4
%22 = call i32 @putchar(i32 10)
br label %23
23: ; preds = %8, %21
%24 = phi i32 [ 1, %21 ], [ 0, %8 ]
ret i32 %24
}