#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*/ tcp_mem_name;
struct bpf_sysctl {
  int dummy;
};
typedef int /*<<< orphan*/ name;

/* Variables and functions */
int bpf_sysctl_get_name(struct bpf_sysctl *, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
__attribute__((no)) int is_tcp_mem(struct bpf_sysctl *ctx) {
  volatile char tcp_mem_name[] =
      "net/ipv4/tcp_mem/"
      "very_very_very_very_long_pointless_string_to_stress_byte_loop";
  unsigned char i;
  char name[64];
  int ret;
  memset(name, 0, sizeof(name));
  ret = bpf_sysctl_get_name(ctx, name, sizeof(name), 0);
  if (ret < 0 || ret != sizeof(tcp_mem_name) - 1)
    return 0;
#pragma clang loop unroll(disable)
  for (i = 0; i < sizeof(tcp_mem_name); ++i)
    if (name[i] != tcp_mem_name[i])
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_tcp_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    0xf0e(%rip),%cl
mov    %cl,0x4e(%rax)
mov    0xf02(%rip),%cx
mov    %cx,0x4c(%rax)
mov    0xef4(%rip),%ecx
mov    %ecx,0x48(%rax)
mov    0xee2(%rip),%rcx
mov    %rcx,0x40(%rax)
movaps 0xec7(%rip),%xmm0
movaps %xmm0,0x30(%rax)
movaps 0xeac(%rip),%xmm0
movaps %xmm0,0x20(%rax)
movaps 0xe91(%rip),%xmm0
movaps %xmm0,0x10(%rax)
movaps 0xe76(%rip),%xmm0
movaps %xmm0,(%rax)
lea    -0xb0(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    -0x10(%rbp),%rdi
lea    -0xb0(%rbp),%rsi
mov    $0x40,%edx
xor    %ecx,%ecx
call   1040 <bpf_sysctl_get_name@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     11db <is_tcp_mem+0xbb>
movslq -0xb4(%rbp),%rax
cmp    $0x4e,%rax
je     11e7 <is_tcp_mem+0xc7>
movl   $0x0,-0x4(%rbp)
jmp    123d <is_tcp_mem+0x11d>
movb   $0x0,-0x61(%rbp)
movzbl -0x61(%rbp),%eax
cmp    $0x4f,%rax
jae    1236 <is_tcp_mem+0x116>
movzbl -0x61(%rbp),%eax
movsbl -0xb0(%rbp,%rax,1),%eax
ff
movzbl -0x61(%rbp),%ecx
mov    -0x60(%rbp,%rcx,1),%cl
movsbl %cl,%ecx
cmp    %ecx,%eax
je     1224 <is_tcp_mem+0x104>
movl   $0x0,-0x4(%rbp)
jmp    123d <is_tcp_mem+0x11d>
jmp    1229 <is_tcp_mem+0x109>
mov    -0x61(%rbp),%al
add    $0x1,%al
mov    %al,-0x61(%rbp)
jmp    11eb <is_tcp_mem+0xcb>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_tcp_mem>:
push   %r15
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %rdi,%r14
mov    0xf19(%rip),%al
mov    %al,0x4e(%rsp)
movzwl 0xf0c(%rip),%eax
mov    %ax,0x4c(%rsp)
mov    0xefd(%rip),%eax
mov    %eax,0x48(%rsp)
mov    0xeea(%rip),%rax
mov    %rax,0x40(%rsp)
movaps 0xece(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7a(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%rbx
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
xor    %ecx,%ecx
call   1040 <bpf_sysctl_get_name@plt>
cmp    $0x4e,%eax
jne    11da <is_tcp_mem+0xba>
xor    %r15d,%r15d
xor    %eax,%eax
nopl   (%rax)
movzbl 0x50(%rsp,%rax,1),%ecx
cmp    (%rsp,%rax,1),%cl
jne    11da <is_tcp_mem+0xba>
add    $0x1,%rax
cmp    $0x4f,%rax
jne    11c0 <is_tcp_mem+0xa0>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.bpf_sysctl = type { i32 }
@__const.is_tcp_mem.tcp_mem_name = [79 x i8] c"net/ipv4/tcp_mem/very_very_very_very_long_pointless_string_to_stress_byte_loop\00"
define i32 @is_tcp_mem(%struct.bpf_sysctl* %0) {
%2 = alloca i32
%3 = alloca %struct.bpf_sysctl*
%4 = alloca [79 x i8]
%5 = alloca i8
%6 = alloca [64 x i8]
%7 = alloca i32
store %struct.bpf_sysctl* %0, %struct.bpf_sysctl** %3
%8 = bitcast [79 x i8]* %4 to i8*
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%10 = call i32 @memset(i8* %9, i32 0, i32 64)
%11 = load %struct.bpf_sysctl*, %struct.bpf_sysctl** %3
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%13 = call i32 @bpf_sysctl_get_name(%struct.bpf_sysctl* %11, i8* %12, i32 64, i32 0)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %1
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = icmp ne i64 %18, 78
br i1 %19, label %20, label %21
20: ; preds = %16, %1
store i32 0, i32* %2
br label %44
21: ; preds = %16
store i8 0, i8* %5
br label %22
22: ; preds = %40, %21
%23 = load i8, i8* %5
%24 = zext i8 %23 to i64
%25 = icmp ult i64 %24, 79
br i1 %25, label %26, label %43
26: ; preds = %22
%27 = load i8, i8* %5
%28 = zext i8 %27 to i64
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = load i8, i8* %5
%33 = zext i8 %32 to i64
%34 = getelementptr inbounds [79 x i8], [79 x i8]* %4, i64 0, i64 %33
%35 = load volatile i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %31, %36
br i1 %37, label %38, label %39
38: ; preds = %26
store i32 0, i32* %2
br label %44
39: ; preds = %26
br label %40
40: ; preds = %39
%41 = load i8, i8* %5
%42 = add i8 %41, 1
store i8 %42, i8* %5
br label %22
43: ; preds = %22
store i32 1, i32* %2
br label %44
44: ; preds = %43, %38, %20
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
%struct.bpf_sysctl = type { i32 }
@__const.is_tcp_mem.tcp_mem_name = [79 x i8] c"net/ipv4/tcp_mem/very_very_very_very_long_pointless_string_to_stress_byte_loop\00"
define i32 @is_tcp_mem(%struct.bpf_sysctl* %0) {
%2 = alloca [79 x i8]
%3 = alloca [64 x i8]
%4 = getelementptr inbounds [79 x i8], [79 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 64)
%7 = call i32 @bpf_sysctl_get_name(%struct.bpf_sysctl* %0, i8* %5, i32 64, i32 0)
%8 = icmp eq i32 %7, 78
br i1 %8, label %11, label %19
9: ; preds = %11
%10 = icmp eq i64 %18, 79
br i1 %10, label %19, label %11
11: ; preds = %1, %9
%12 = phi i64 [ %18, %9 ], [ 0, %1 ]
%13 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = getelementptr inbounds [79 x i8], [79 x i8]* %2, i64 0, i64 %12
%16 = load volatile i8, i8* %15
%17 = icmp eq i8 %14, %16
%18 = add nuw nsw i64 %12, 1
br i1 %17, label %9, label %19
19: ; preds = %9, %11, %1
%20 = phi i32 [ 0, %1 ], [ 1, %9 ], [ 0, %11 ]
ret i32 %20
}