#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*/ scores;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int removeZeroElements(int *, int);
int main(int argc, const char *argv[]) {
  int scores[] = {65, 0, 95, 0, 0, 79, 82, 0, 84, 94, 86, 90, 0};
  int nScores = sizeof(scores) / sizeof(scores[0]);
  int leftNScores = removeZeroElements(scores, nScores);
  printf("Scores table is :\n");
  for (int i = 0; i < leftNScores; i++) {
    printf("%d ", scores[i]);
  }
  printf("\n");
  printf("nScores is %d.\n", leftNScores);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeaf(%rip),%rsi
mov    $0x34,%edx
call   1050 <memcpy@plt>
movl   $0xd,-0x54(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1030 <removeZeroElements@plt>
mov    %eax,-0x58(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jge    11b6 <main+0x86>
movslq -0x5c(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1186 <main+0x56>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x58(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xee0(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xec5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xea9(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe8d(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rdi
mov    $0xd,%esi
call   1040 <removeZeroElements@plt>
mov    %eax,%r14d
lea    0xeba(%rip),%rdi
call   1050 <puts@plt>
test   %r14d,%r14d
jle    11c6 <main+0x86>
mov    %r14d,%ebp
lea    0xe92(%rip),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rsp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11b0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe61(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.scores = [13 x i32] [i32 65, i32 0, i32 95, i32 0, i32 0, i32 79, i32 82, i32 0, i32 84, i32 94, i32 86, i32 90, i32 0]
@.str = [19 x i8] c"Scores table is :\0A\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [16 x i8] c"nScores is %d.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [13 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [13 x i32]* %6 to i8*
store i32 13, i32* %7
%11 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 0
%12 = load i32, i32* %7
%13 = call i32 @removeZeroElements(i32* %11, i32 %12)
store i32 %13, i32* %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %15
15: ; preds = %25, %2
%16 = load i32, i32* %9
%17 = load i32, i32* %8
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [13 x i32], [13 x i32]* %6, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %19
%26 = load i32, i32* %9
%27 = add nsw i32 %26, 1
store i32 %27, i32* %9
br label %15
28: ; preds = %15
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = load i32, i32* %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %30)
ret i32 0
}

LLVM IR (-O2):
@__const.main.scores = [13 x i32] [i32 65, i32 0, i32 95, i32 0, i32 0, i32 79, i32 82, i32 0, i32 84, i32 94, i32 86, i32 90, i32 0]
@.str.1 = [4 x i8] c"%d \00"
@.str.3 = [16 x i8] c"nScores is %d.\0A\00"
@str = [18 x i8] c"Scores table is :\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [13 x i32]
%4 = bitcast [13 x i32]* %3 to i8*
%5 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 0
%6 = call i32 @removeZeroElements(i32* %5, i32 13)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = zext i32 %6 to i64
br label %14
11: ; preds = %14, %2
%12 = call i32 @putchar(i32 10)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %6)
ret i32 0
14: ; preds = %9, %14
%15 = phi i64 [ 0, %9 ], [ %19, %14 ]
%16 = getelementptr inbounds [13 x i32], [13 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = add nuw nsw i64 %15, 1
%20 = icmp eq i64 %19, %10
br i1 %20, label %11, label %14
}