#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*/ values;
typedef int /*<<< orphan*/ __u64;
typedef int __u32;

/* Variables and functions */
int /*<<< orphan*/ BPF_ANY;
int /*<<< orphan*/ _SC_NPROCESSORS_CONF;
int /*<<< orphan*/ bpf_update_elem(int, int *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
unsigned int sysconf(int /*<<< orphan*/);
void clear_stats(int fd) {
  unsigned int nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
  __u64 values[nr_cpus];
  __u32 key;
  memset(values, 0, sizeof(values));
  for (key = 0; key < 100; key++)
    bpf_update_elem(fd, &key, values, BPF_ANY);
}


x86 assembly (clang, -O0):
<clear_stats>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x28(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x64,-0x1c(%rbp)
jge    11b8 <clear_stats+0x88>
mov    -0x28(%rbp),%rdx
mov    -0x4(%rbp),%edi
mov    0x2e41(%rip),%rax
mov    (%rax),%ecx
lea    -0x1c(%rbp),%rsi
call   1040 <bpf_update_elem@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1187 <clear_stats+0x57>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clear_stats>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%r14d
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
call   1050 <sysconf@plt>
mov    %eax,%ecx
mov    %rsp,%rbx
lea    0xf(,%rcx,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
lea    0x0(,%rax,4),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
movl   $0x0,-0x24(%rbp)
mov    0x2e5a(%rip),%r12
lea    -0x24(%rbp),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r12),%ecx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1040 <bpf_update_elem@plt>
mov    -0x24(%rbp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x63,%eax
jl     1190 <clear_stats+0x60>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@_SC_NPROCESSORS_CONF = global i32 0
@BPF_ANY = global i32 0
define void @clear_stats(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
store i32 %0, i32* %2
%7 = load i32, i32* @_SC_NPROCESSORS_CONF
%8 = call i32 @sysconf(i32 %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %4
%12 = alloca i32, i64 %10
store i64 %10, i64* %5
%13 = mul nuw i64 4, %10
%14 = trunc i64 %13 to i32
%15 = call i32 @memset(i32* %12, i32 0, i32 %14)
store i32 0, i32* %6
br label %16
16: ; preds = %23, %1
%17 = load i32, i32* %6
%18 = icmp slt i32 %17, 100
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = load i32, i32* %2
%21 = load i32, i32* @BPF_ANY
%22 = call i32 @bpf_update_elem(i32 %20, i32* %6, i32* %12, i32 %21)
br label %23
23: ; preds = %19
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %16
26: ; preds = %16
%27 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@_SC_NPROCESSORS_CONF = global i32 0
@BPF_ANY = global i32 0
define void @clear_stats(i32 %0) {
%2 = alloca i32
%3 = load i32, i32* @_SC_NPROCESSORS_CONF
%4 = tail call i32 @sysconf(i32 %3)
%5 = zext i32 %4 to i64
%6 = alloca i32, i64 %5
%7 = bitcast i32* %2 to i8*
%8 = shl i32 %4, 2
%9 = call i32 @memset(i32* %6, i32 0, i32 %8)
store i32 0, i32* %2
br label %10
10: ; preds = %1, %10
%11 = load i32, i32* @BPF_ANY
%12 = call i32 @bpf_update_elem(i32 %0, i32* %2, i32* %6, i32 %11)
%13 = load i32, i32* %2
%14 = add nsw i32 %13, 1
store i32 %14, i32* %2
%15 = icmp slt i32 %13, 99
br i1 %15, label %10, label %16
16: ; preds = %10
ret void
}