#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printArray(int a[]) {
  int i = 0;
  int len = sizeof(a);
  int f = 0;
  for (i = 0; i < len; i++) {
    if (a[i] == 0) {
      continue;
    }
    printf(f == 0 ? "" : " ");
    printf("%d", a[i]);
    f = 1;
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x8,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11a8 <printArray+0x98>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    115b <printArray+0x4b>
jmp    119a <printArray+0x8a>
mov    -0x14(%rbp),%ecx
lea    0xe9b(%rip),%rdi
lea    0xe9a(%rip),%rax
cmp    $0x0,%ecx
cmove  %rax,%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1138 <printArray+0x28>
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printArray>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%ebp
test   %ebp,%ebp
je     12d1 <printArray+0x1b1>
mov    (%rbx),%esi
lea    0xec9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x4(%rbx)
je     117c <printArray+0x5c>
test   %ebp,%ebp
lea    0xead(%rip),%rax
lea    0xea5(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x8(%rbx)
je     11b3 <printArray+0x93>
test   %eax,%eax
lea    0xe76(%rip),%rax
lea    0xe6e(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0xc(%rbx)
je     11ea <printArray+0xca>
test   %eax,%eax
lea    0xe3f(%rip),%rax
lea    0xe37(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rbx),%esi
lea    0xe24(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x10(%rbx)
je     1221 <printArray+0x101>
test   %eax,%eax
lea    0xe08(%rip),%rax
lea    0xe00(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rbx),%esi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x14(%rbx)
je     1258 <printArray+0x138>
test   %eax,%eax
lea    0xdd1(%rip),%rax
lea    0xdc9(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x14(%rbx),%esi
lea    0xdb6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x18(%rbx)
je     128f <printArray+0x16f>
test   %eax,%eax
lea    0xd9a(%rip),%rax
lea    0xd92(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rbx),%esi
lea    0xd7f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
cmpl   $0x0,0x1c(%rbx)
je     12c1 <printArray+0x1a1>
test   %eax,%eax
lea    0xd63(%rip),%rax
lea    0xd5b(%rip),%rdi
cmove  %rax,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x1c(%rbx),%esi
lea    0xd48(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <putchar@plt>
xor    %eax,%eax
cmpl   $0x0,0x4(%rbx)
jne    114b <printArray+0x2b>
jmp    117c <printArray+0x5c>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @printArray(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 8, i32* %4
store i32 0, i32* %5
store i32 0, i32* %3
br label %6
6: ; preds = %30, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = icmp slt i32 %7, %8
br i1 %9, label %10, label %33
10: ; preds = %6
%11 = load i32*, i32** %2
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %10
br label %30
18: ; preds = %10
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%23 = call i32 (i8*, ...) @printf(i8* %22)
%24 = load i32*, i32** %2
%25 = load i32, i32* %3
%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 ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %28)
store i32 1, i32* %5
br label %30
30: ; preds = %18, %17
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %6
33: ; preds = %6
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c" \00"
@.str.2 = [3 x i8] c"%d\00"
define void @printArray(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i32, i32* %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %1, %4
%8 = phi i32 [ 0, %1 ], [ 1, %4 ]
%9 = getelementptr inbounds i32, i32* %0, i64 1
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = select i1 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %13)
%15 = load i32, i32* %9
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %12, %7
%18 = phi i32 [ %8, %7 ], [ 1, %12 ]
%19 = getelementptr inbounds i32, i32* %0, i64 2
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %17
%23 = icmp eq i32 %18, 0
%24 = select i1 %23, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %24)
%26 = load i32, i32* %19
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %22, %17
%29 = phi i32 [ %18, %17 ], [ 1, %22 ]
%30 = getelementptr inbounds i32, i32* %0, i64 3
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %28
%34 = icmp eq i32 %29, 0
%35 = select i1 %34, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %35)
%37 = load i32, i32* %30
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %33, %28
%40 = phi i32 [ %29, %28 ], [ 1, %33 ]
%41 = getelementptr inbounds i32, i32* %0, i64 4
%42 = load i32, i32* %41
%43 = icmp eq i32 %42, 0
br i1 %43, label %50, label %44
44: ; preds = %39
%45 = icmp eq i32 %40, 0
%46 = select i1 %45, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %46)
%48 = load i32, i32* %41
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %44, %39
%51 = phi i32 [ %40, %39 ], [ 1, %44 ]
%52 = getelementptr inbounds i32, i32* %0, i64 5
%53 = load i32, i32* %52
%54 = icmp eq i32 %53, 0
br i1 %54, label %61, label %55
55: ; preds = %50
%56 = icmp eq i32 %51, 0
%57 = select i1 %56, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %57)
%59 = load i32, i32* %52
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %59)
br label %61
61: ; preds = %55, %50
%62 = phi i32 [ %51, %50 ], [ 1, %55 ]
%63 = getelementptr inbounds i32, i32* %0, i64 6
%64 = load i32, i32* %63
%65 = icmp eq i32 %64, 0
br i1 %65, label %72, label %66
66: ; preds = %61
%67 = icmp eq i32 %62, 0
%68 = select i1 %67, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%69 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %68)
%70 = load i32, i32* %63
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %70)
br label %72
72: ; preds = %66, %61
%73 = phi i32 [ %62, %61 ], [ 1, %66 ]
%74 = getelementptr inbounds i32, i32* %0, i64 7
%75 = load i32, i32* %74
%76 = icmp eq i32 %75, 0
br i1 %76, label %83, label %77
77: ; preds = %72
%78 = icmp eq i32 %73, 0
%79 = select i1 %78, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0)
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %79)
%81 = load i32, i32* %74
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %77, %72
%84 = tail call i32 @putchar(i32 10)
ret void
}