#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*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
void printCode(unsigned short *code) {
  int i, j, codePosition;
  int nv = code[0];
  codePosition = 1;
  fprintf(stdout, "%d\n", nv);
  for (i = 0; i < nv; i++) {
    fprintf(stdout, "%d ", code[codePosition]);
    codePosition++;
    for (j = 1; code[codePosition]; j++, codePosition++) {
      fprintf(stdout, "%d ", code[codePosition]);
    }
    fprintf(stdout, "0\n");
    codePosition++;
  }
}


x86 assembly (clang, -O0):
<printCode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzwl (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1208 <printCode+0xf8>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzwl (%rax,%rcx,2),%edx
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpw   $0x0,(%rax,%rcx,2)
je     11da <printCode+0xca>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movzwl (%rax,%rcx,2),%edx
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118d <printCode+0x7d>
mov    0x2dff(%rip),%rax
mov    (%rax),%edi
lea    0xe1e(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114e <printCode+0x3e>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printCode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,0x8(%rsp)
movzwl (%rdi),%ebx
mov    0x2eb3(%rip),%r12
mov    (%r12),%edi
lea    0xec8(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %ebx,0x4(%rsp)
test   %ebx,%ebx
je     11f7 <printCode+0xe7>
mov    0x8(%rsp),%rax
add    $0x2,%rax
mov    %rax,0x10(%rsp)
mov    $0x1,%r15d
lea    0xe9c(%rip),%rbp
xor    %r13d,%r13d
jmp    1191 <printCode+0x81>
nopl   (%rax)
mov    (%r12),%edi
lea    0xe8d(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
add    $0x2,%r15d
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
je     11f7 <printCode+0xe7>
mov    (%r12),%edi
movslq %r15d,%rbx
mov    0x8(%rsp),%r14
movzwl (%r14,%rbx,2),%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
movzwl 0x2(%r14,%rbx,2),%eax
test   %ax,%ax
je     1170 <printCode+0x60>
add    $0x1,%rbx
mov    0x10(%rsp),%rcx
lea    (%rcx,%rbx,2),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r12),%edi
movzwl %ax,%edx
mov    %rbp,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
movzwl (%r14),%eax
add    $0x1,%r15d
add    $0x2,%r14
test   %ax,%ax
jne    11d0 <printCode+0xc0>
jmp    1170 <printCode+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdout = global i32 0
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [3 x i8] c"0\0A\00"
define void @printCode(i16* nocapture %0) {
%2 = load i16, i16* %0
%3 = zext i16 %2 to i32
%4 = load i32, i32* @stdout
%5 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %3)
%6 = icmp eq i16 %2, 0
br i1 %6, label %40, label %7
7: ; preds = %1, %33
%8 = phi i32 [ %38, %33 ], [ 0, %1 ]
%9 = phi i32 [ %37, %33 ], [ 1, %1 ]
%10 = load i32, i32* @stdout
%11 = sext i32 %9 to i64
%12 = getelementptr inbounds i16, i16* %0, i64 %11
%13 = load i16, i16* %12
%14 = zext i16 %13 to i32
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = add nsw i32 %9, 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i16, i16* %0, i64 %17
%19 = load i16, i16* %18
%20 = icmp eq i16 %19, 0
br i1 %20, label %33, label %21
21: ; preds = %7, %21
%22 = phi i64 [ %27, %21 ], [ %17, %7 ]
%23 = phi i16 [ %29, %21 ], [ %19, %7 ]
%24 = load i32, i32* @stdout
%25 = zext i16 %23 to i32
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = add i64 %22, 1
%28 = getelementptr inbounds i16, i16* %0, i64 %27
%29 = load i16, i16* %28
%30 = icmp eq i16 %29, 0
br i1 %30, label %31, label %21
31: ; preds = %21
%32 = trunc i64 %22 to i32
br label %33
33: ; preds = %31, %7
%34 = phi i32 [ %9, %7 ], [ %32, %31 ]
%35 = load i32, i32* @stdout
%36 = tail call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%37 = add nsw i32 %34, 2
%38 = add nuw nsw i32 %8, 1
%39 = icmp eq i32 %38, %3
br i1 %39, label %40, label %7
40: ; preds = %33, %1
ret void
}