#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int /*<<< orphan*/ y;
  int /*<<< orphan*/ x;
  int /*<<< orphan*/ time;
};
typedef TYPE_1__ XTimeCoord;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printhistory(XTimeCoord *mh, int mhlen, int level) {
  int i;
  if (level == 0)
    return;
  printf("[%d]", mhlen);
  for (i = 0; i < mhlen; i++)
    switch (level) {
    case 2:
      printf(" %hd", mh[i].x);
      break;
    case 3:
      printf(" %lu:%hd", mh[i].time, mh[i].x);
      break;
    case 4:
      printf(" %lu:%hd,%hd", mh[i].time, mh[i].x, mh[i].y);
      break;
    }
  printf("\n");
}


x86 assembly (clang, -O0):
<printhistory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1131 <printhistory+0x21>
jmp    124b <printhistory+0x13b>
mov    -0xc(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123d <printhistory+0x12d>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2,%eax
je     118b <printhistory+0x7b>
jmp    1169 <printhistory+0x59>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     11b0 <printhistory+0xa0>
jmp    117a <printhistory+0x6a>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
je     11e7 <printhistory+0xd7>
jmp    122a <printhistory+0x11a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%esi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <printhistory+0x11a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122a <printhistory+0x11a>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x8(%rax),%esi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
mov    (%rax),%ecx
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122f <printhistory+0x11f>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <printhistory+0x39>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printhistory>:
test   %edx,%edx
je     11ee <printhistory+0xce>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11d6 <printhistory+0xb6>
mov    %ebp,%eax
shl    $0x2,%rax
lea    (%rax,%rax,2),%rbp
lea    0xea9(%rip),%r12
lea    0xe9d(%rip),%r13
xor    %r15d,%r15d
jmp    1195 <printhistory+0x75>
nopl   (%rax)
mov    0x8(%r14,%r15,1),%esi
mov    (%r14,%r15,1),%ecx
mov    0x4(%r14,%r15,1),%edx
lea    0xe8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xc,%r15
cmp    %r15,%rbp
je     11d6 <printhistory+0xb6>
cmp    $0x4,%ebx
je     1170 <printhistory+0x50>
cmp    $0x3,%ebx
je     11c0 <printhistory+0xa0>
cmp    $0x2,%ebx
jne    118c <printhistory+0x6c>
mov    0x4(%r14,%r15,1),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118c <printhistory+0x6c>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x4(%r14,%r15,1),%edx
mov    0x8(%r14,%r15,1),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118c <printhistory+0x6c>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
ret

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

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