#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 history(char *hist[10][20], int *hist_index, int *hist_args,
             int hist_big_cnt) {
  int index;
  if (hist_big_cnt <= 10)
    index = hist_big_cnt - 1;
  else
    index = 10;
  for (int i = 0; i < index; i++) {
    printf("%d \t", hist_index[i]);
    for (int j = 0; j < hist_args[i]; j++)
      printf("%s ", hist[i][j]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<history>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jg     113f <history+0x2f>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1146 <history+0x36>
movl   $0xa,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    11df <history+0xcf>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11c3 <history+0xb3>
mov    -0x8(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1179 <history+0x69>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    114d <history+0x3d>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<history>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,(%rsp)
lea    -0x1(%rcx),%edx
cmp    $0xb,%ecx
mov    $0xa,%eax
cmovl  %edx,%eax
test   %eax,%eax
jle    11bd <history+0x9d>
mov    %rdi,%rbx
mov    %eax,%ebp
lea    0xeb5(%rip),%r13
xor    %r12d,%r12d
jmp    117a <history+0x5a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
add    $0xa0,%rbx
cmp    %rbp,%r12
je     11bd <history+0x9d>
mov    (%rsp),%rax
mov    (%rax,%r12,4),%esi
lea    0xe77(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,(%r15,%r12,4)
jle    1160 <history+0x40>
xor    %r14d,%r14d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r14,8),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14
movslq (%r15,%r12,4),%rax
cmp    %rax,%r14
jl     11a0 <history+0x80>
jmp    1160 <history+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d \09\00"
@.str.1 = [4 x i8] c"%s \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @history([20 x i8*]* %0, i32* %1, i32* %2, i32 %3) {
%5 = alloca [20 x i8*]*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store [20 x i8*]* %0, [20 x i8*]** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%12 = load i32, i32* %8
%13 = icmp sle i32 %12, 10
br i1 %13, label %14, label %17
14: ; preds = %4
%15 = load i32, i32* %8
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %9
br label %18
17: ; preds = %4
store i32 10, i32* %9
br label %18
18: ; preds = %17, %14
store i32 0, i32* %10
br label %19
19: ; preds = %53, %18
%20 = load i32, i32* %10
%21 = load i32, i32* %9
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %56
23: ; preds = %19
%24 = load i32*, i32** %6
%25 = load i32, i32* %10
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %28)
store i32 0, i32* %11
br label %30
30: ; preds = %48, %23
%31 = load i32, i32* %11
%32 = load i32*, i32** %7
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = icmp slt i32 %31, %36
br i1 %37, label %38, label %51
38: ; preds = %30
%39 = load [20 x i8*]*, [20 x i8*]** %5
%40 = load i32, i32* %10
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [20 x i8*], [20 x i8*]* %39, i64 %41
%43 = load i32, i32* %11
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [20 x i8*], [20 x i8*]* %42, i64 0, i64 %44
%46 = load i8*, i8** %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %38
%49 = load i32, i32* %11
%50 = add nsw i32 %49, 1
store i32 %50, i32* %11
br label %30
51: ; preds = %30
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %53
53: ; preds = %51
%54 = load i32, i32* %10
%55 = add nsw i32 %54, 1
store i32 %55, i32* %10
br label %19
56: ; preds = %19
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d \09\00"
@.str.1 = [4 x i8] c"%s \00"
define void @history([20 x i8*]* nocapture %0, i32* nocapture %1, i32* nocapture %2, i32 %3) {
%5 = add nsw i32 %3, -1
%6 = icmp sgt i32 %3, 10
%7 = select i1 %6, i32 10, i32 %5
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = zext i32 %7 to i64
br label %12
11: ; preds = %20, %4
ret void
12: ; preds = %9, %20
%13 = phi i64 [ 0, %9 ], [ %22, %20 ]
%14 = getelementptr inbounds i32, i32* %1, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds i32, i32* %2, i64 %13
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %24, %12
%21 = tail call i32 @putchar(i32 10)
%22 = add nuw nsw i64 %13, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %11, label %12
24: ; preds = %12, %24
%25 = phi i64 [ %29, %24 ], [ 0, %12 ]
%26 = getelementptr inbounds [20 x i8*], [20 x i8*]* %0, i64 %13, i64 %25
%27 = load i8*, i8** %26
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = add nuw nsw i64 %25, 1
%30 = load i32, i32* %17
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %24, label %20
}