#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*/ printf(char *, int, ...);
void printStatistics(int numrcv, int packetnum, int *stat) {
  int j = 0, i = 1;
  for (i = 1; i < numrcv; ++i) {
    if (!(*(stat + j) == i)) {
      j--;
      printf("Packet number %d missing\n", i);
    }
    ++j;
  }
  printf("Packets recived: %d\nPackets lost: %d\n", numrcv, packetnum - numrcv);
}


x86 assembly (clang, -O0):
<printStatistics>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1188 <printStatistics+0x78>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x18(%rbp),%eax
je     1171 <printStatistics+0x61>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <printStatistics+0x27>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    -0x4(%rbp),%edx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStatistics>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r13d
cmp    $0x2,%edi
jl     1165 <printStatistics+0x55>
mov    %rdx,%r15
mov    $0x1,%ebx
lea    0xecb(%rip),%r12
xor    %ebp,%ebp
jmp    114b <printStatistics+0x3b>
nopl   0x0(%rax)
add    $0x1,%ebp
add    $0x1,%ebx
cmp    %ebx,%r13d
je     1165 <printStatistics+0x55>
movslq %ebp,%rax
cmp    (%r15,%rax,4),%ebx
je     1140 <printStatistics+0x30>
add    $0xffffffff,%ebp
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1140 <printStatistics+0x30>
sub    %r13d,%r14d
lea    0xeab(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"Packet number %d missing\0A\00"
@.str.1 = [38 x i8] c"Packets recived: %d\0APackets lost: %d\0A\00"
define void @printStatistics(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
store i32 0, i32* %7
store i32 1, i32* %8
store i32 1, i32* %8
br label %9
9: ; preds = %29, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %32
13: ; preds = %9
%14 = load i32*, i32** %6
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = load i32, i32* %8
%20 = icmp eq i32 %18, %19
br i1 %20, label %26, label %21
21: ; preds = %13
%22 = load i32, i32* %7
%23 = add nsw i32 %22, -1
store i32 %23, i32* %7
%24 = load i32, i32* %8
%25 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %13
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %29
29: ; preds = %26
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %9
32: ; preds = %9
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = sub nsw i32 %34, %35
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %33, i32 %36)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Packet number %d missing\0A\00"
@.str.1 = [38 x i8] c"Packets recived: %d\0APackets lost: %d\0A\00"
define void @printStatistics(i32 %0, i32 %1, i32* nocapture %2) {
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %20
5: ; preds = %3, %15
%6 = phi i32 [ %18, %15 ], [ 1, %3 ]
%7 = phi i32 [ %17, %15 ], [ 0, %3 ]
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %2, i64 %8
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, %6
br i1 %11, label %15, label %12
12: ; preds = %5
%13 = add nsw i32 %7, -1
%14 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %15
15: ; preds = %12, %5
%16 = phi i32 [ %7, %5 ], [ %13, %12 ]
%17 = add nsw i32 %16, 1
%18 = add nuw nsw i32 %6, 1
%19 = icmp eq i32 %18, %0
br i1 %19, label %20, label %5
20: ; preds = %15, %3
%21 = sub nsw i32 %1, %0
%22 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %21)
ret void
}