#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*/ max_command(int, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
void show(int msec, const unsigned short *sequence) {
  const unsigned short *data = sequence;
  for (;;) {
    max_command(0x01, *data++);
    max_command(0x02, *data++);
    max_command(0x03, *data++);
    max_command(0x04, *data++);
    max_command(0x05, *data++);
    max_command(0x06, *data++);
    max_command(0x07, *data++);
    max_command(0x08, *data++);
    usleep(125000);
    msec -= 125;
    if (*data == 0xffff) {
      if (msec < 0)
        break;
      data = sequence;
    }
  }
}


x86 assembly (clang, -O0):
<show>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x1,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x2,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x3,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x4,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x5,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x6,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x7,%edi
call   1030 <max_command@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x2,%rcx
mov    %rcx,-0x18(%rbp)
movzwl (%rax),%esi
mov    $0x8,%edi
call   1030 <max_command@plt>
mov    $0x1e848,%edi
call   1040 <usleep@plt>
mov    -0x4(%rbp),%eax
sub    $0x7d,%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
movzwl (%rax),%eax
cmp    $0xffff,%eax
jne    1253 <show+0x133>
cmpl   $0x0,-0x4(%rbp)
jge    124b <show+0x12b>
jmp    1258 <show+0x138>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <show+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    %rsi,%rbx
jmp    1137 <show+0x17>
xchg   %ax,%ax
add    $0x10,%rbx
add    $0xffffff83,%ebp
movzwl (%rbx),%esi
mov    $0x1,%edi
call   1030 <max_command@plt>
movzwl 0x2(%rbx),%esi
mov    $0x2,%edi
call   1030 <max_command@plt>
movzwl 0x4(%rbx),%esi
mov    $0x3,%edi
call   1030 <max_command@plt>
movzwl 0x6(%rbx),%esi
mov    $0x4,%edi
call   1030 <max_command@plt>
movzwl 0x8(%rbx),%esi
mov    $0x5,%edi
call   1030 <max_command@plt>
movzwl 0xa(%rbx),%esi
mov    $0x6,%edi
call   1030 <max_command@plt>
movzwl 0xc(%rbx),%esi
mov    $0x7,%edi
call   1030 <max_command@plt>
movzwl 0xe(%rbx),%esi
mov    $0x8,%edi
call   1030 <max_command@plt>
mov    $0x1e848,%edi
call   1040 <usleep@plt>
cmpw   $0xffff,0x10(%rbx)
jne    1130 <show+0x10>
mov    %r14,%rbx
cmp    $0x7d,%ebp
jl     11cb <show+0xab>
add    $0xffffff83,%ebp
jmp    1137 <show+0x17>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @show(i32 %0, i16* %1) {
%3 = alloca i32
%4 = alloca i16*
%5 = alloca i16*
store i32 %0, i32* %3
store i16* %1, i16** %4
%6 = load i16*, i16** %4
store i16* %6, i16** %5
br label %7
7: ; preds = %61, %2
%8 = load i16*, i16** %5
%9 = getelementptr inbounds i16, i16* %8, i32 1
store i16* %9, i16** %5
%10 = load i16, i16* %8
%11 = zext i16 %10 to i32
%12 = call i32 @max_command(i32 1, i32 %11)
%13 = load i16*, i16** %5
%14 = getelementptr inbounds i16, i16* %13, i32 1
store i16* %14, i16** %5
%15 = load i16, i16* %13
%16 = zext i16 %15 to i32
%17 = call i32 @max_command(i32 2, i32 %16)
%18 = load i16*, i16** %5
%19 = getelementptr inbounds i16, i16* %18, i32 1
store i16* %19, i16** %5
%20 = load i16, i16* %18
%21 = zext i16 %20 to i32
%22 = call i32 @max_command(i32 3, i32 %21)
%23 = load i16*, i16** %5
%24 = getelementptr inbounds i16, i16* %23, i32 1
store i16* %24, i16** %5
%25 = load i16, i16* %23
%26 = zext i16 %25 to i32
%27 = call i32 @max_command(i32 4, i32 %26)
%28 = load i16*, i16** %5
%29 = getelementptr inbounds i16, i16* %28, i32 1
store i16* %29, i16** %5
%30 = load i16, i16* %28
%31 = zext i16 %30 to i32
%32 = call i32 @max_command(i32 5, i32 %31)
%33 = load i16*, i16** %5
%34 = getelementptr inbounds i16, i16* %33, i32 1
store i16* %34, i16** %5
%35 = load i16, i16* %33
%36 = zext i16 %35 to i32
%37 = call i32 @max_command(i32 6, i32 %36)
%38 = load i16*, i16** %5
%39 = getelementptr inbounds i16, i16* %38, i32 1
store i16* %39, i16** %5
%40 = load i16, i16* %38
%41 = zext i16 %40 to i32
%42 = call i32 @max_command(i32 7, i32 %41)
%43 = load i16*, i16** %5
%44 = getelementptr inbounds i16, i16* %43, i32 1
store i16* %44, i16** %5
%45 = load i16, i16* %43
%46 = zext i16 %45 to i32
%47 = call i32 @max_command(i32 8, i32 %46)
%48 = call i32 @usleep(i32 125000)
%49 = load i32, i32* %3
%50 = sub nsw i32 %49, 125
store i32 %50, i32* %3
%51 = load i16*, i16** %5
%52 = load i16, i16* %51
%53 = zext i16 %52 to i32
%54 = icmp eq i32 %53, 65535
br i1 %54, label %55, label %61
55: ; preds = %7
%56 = load i32, i32* %3
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %55
br label %62
59: ; preds = %55
%60 = load i16*, i16** %4
store i16* %60, i16** %5
br label %61
61: ; preds = %59, %7
br label %7
62: ; preds = %58
ret void
}

LLVM IR (-O2):
define void @show(i32 %0, i16* nocapture %1) {
br label %3
3: ; preds = %44, %2
%4 = phi i32 [ %0, %2 ], [ %39, %44 ]
%5 = phi i16* [ %1, %2 ], [ %45, %44 ]
%6 = getelementptr inbounds i16, i16* %5, i64 1
%7 = load i16, i16* %5
%8 = zext i16 %7 to i32
%9 = tail call i32 @max_command(i32 1, i32 %8)
%10 = getelementptr inbounds i16, i16* %5, i64 2
%11 = load i16, i16* %6
%12 = zext i16 %11 to i32
%13 = tail call i32 @max_command(i32 2, i32 %12)
%14 = getelementptr inbounds i16, i16* %5, i64 3
%15 = load i16, i16* %10
%16 = zext i16 %15 to i32
%17 = tail call i32 @max_command(i32 3, i32 %16)
%18 = getelementptr inbounds i16, i16* %5, i64 4
%19 = load i16, i16* %14
%20 = zext i16 %19 to i32
%21 = tail call i32 @max_command(i32 4, i32 %20)
%22 = getelementptr inbounds i16, i16* %5, i64 5
%23 = load i16, i16* %18
%24 = zext i16 %23 to i32
%25 = tail call i32 @max_command(i32 5, i32 %24)
%26 = getelementptr inbounds i16, i16* %5, i64 6
%27 = load i16, i16* %22
%28 = zext i16 %27 to i32
%29 = tail call i32 @max_command(i32 6, i32 %28)
%30 = getelementptr inbounds i16, i16* %5, i64 7
%31 = load i16, i16* %26
%32 = zext i16 %31 to i32
%33 = tail call i32 @max_command(i32 7, i32 %32)
%34 = getelementptr inbounds i16, i16* %5, i64 8
%35 = load i16, i16* %30
%36 = zext i16 %35 to i32
%37 = tail call i32 @max_command(i32 8, i32 %36)
%38 = tail call i32 @usleep(i32 125000)
%39 = add nsw i32 %4, -125
%40 = load i16, i16* %34
%41 = icmp eq i16 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %3
%43 = icmp slt i32 %4, 125
br i1 %43, label %46, label %44
44: ; preds = %42, %3
%45 = phi i16* [ %1, %42 ], [ %34, %3 ]
br label %3
46: ; preds = %42
ret void
}