#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 */
struct slist {
  int dummy;
};
typedef int /*<<< orphan*/ n;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int htonl(int);
int /*<<< orphan*/ printf(char *, int);
int slist_find(struct slist *, char const *, int, int /*<<< orphan*/ *);
void find_invalid_range(struct slist *slist, int range) {
  int i;
  for (i = range; i < range * 2; ++i) {
    int n = htonl(i);
    assert(slist_find(slist, (const char *)&n, sizeof(n), NULL) == -1);
    printf("find_invalid_range=%d\n", i);
  }
}


x86 assembly (clang, -O0):
<find_invalid_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11b4 <find_invalid_range+0x74>
mov    -0x10(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x4,%edx
xor    %eax,%eax
mov    %eax,%ecx
call   1060 <slist_find@plt>
cmp    $0xffffffff,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x10(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1155 <find_invalid_range+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_invalid_range>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r13d
lea    0x0(%r13,%r13,1),%eax
cmp    %esi,%eax
jle    11b1 <find_invalid_range+0x71>
mov    %rdi,%r14
xor    %ebx,%ebx
lea    0x4(%rsp),%r15
lea    0xe98(%rip),%r12
nopl   0x0(%rax,%rax,1)
lea    (%rbx,%r13,1),%ebp
mov    %ebp,%edi
call   1040 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
xor    %ecx,%ecx
call   1060 <slist_find@plt>
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1050 <assert@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r13d
jne    1170 <find_invalid_range+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.slist = type { i32 }
@.str = [23 x i8] c"find_invalid_range=%d\0A\00"
define void @find_invalid_range(%struct.slist* %0, i32 %1) {
%3 = alloca %struct.slist*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store %struct.slist* %0, %struct.slist** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
store i32 %7, i32* %5
br label %8
8: ; preds = %24, %2
%9 = load i32, i32* %5
%10 = load i32, i32* %4
%11 = mul nsw i32 %10, 2
%12 = icmp slt i32 %9, %11
br i1 %12, label %13, label %27
13: ; preds = %8
%14 = load i32, i32* %5
%15 = call i32 @htonl(i32 %14)
store i32 %15, i32* %6
%16 = load %struct.slist*, %struct.slist** %3
%17 = bitcast i32* %6 to i8*
%18 = call i32 @slist_find(%struct.slist* %16, i8* %17, i32 4, i32* null)
%19 = icmp eq i32 %18, -1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %5
%23 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %13
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %8
27: ; preds = %8
ret void
}

LLVM IR (-O2):
%struct.slist = type { i32 }
@.str = [23 x i8] c"find_invalid_range=%d\0A\00"
define void @find_invalid_range(%struct.slist* %0, i32 %1) {
%3 = alloca i32
%4 = shl i32 %1, 1
%5 = icmp sgt i32 %4, %1
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = bitcast i32* %3 to i8*
br label %8
8: ; preds = %6, %8
%9 = phi i32 [ %1, %6 ], [ %16, %8 ]
%10 = call i32 @htonl(i32 %9)
store i32 %10, i32* %3
%11 = call i32 @slist_find(%struct.slist* %0, i8* %7, i32 4, i32* null)
%12 = icmp eq i32 %11, -1
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %9)
%16 = add i32 %9, 1
%17 = icmp eq i32 %16, %4
br i1 %17, label %18, label %8
18: ; preds = %8, %2
ret void
}