#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*/ F_RDLCK;
int /*<<< orphan*/ F_WRLCK;
int /*<<< orphan*/ lock(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ unlock(int, int);
void test_ranges() {
  printf("testing ranges...\n");
  unlock(0, 0);
  lock(F_RDLCK, 10, 10);
  lock(F_RDLCK, 30, 10);
  lock(F_RDLCK, 20, 10);
  lock(F_RDLCK, 1000, 0);
  unlock(5, 10);
  unlock(20, 5);
  unlock(35, 10);
  unlock(950, 100);
  lock(F_WRLCK, 0, 30);
  lock(F_WRLCK, 30, 30);
}


x86 assembly (clang, -O0):
<test_ranges>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rdi
call   1050 <printf@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1030 <unlock@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    $0xa,%edx
mov    %edx,%esi
call   1040 <lock@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    $0x1e,%esi
mov    $0xa,%edx
call   1040 <lock@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    $0x14,%esi
mov    $0xa,%edx
call   1040 <lock@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
mov    $0x3e8,%esi
xor    %edx,%edx
call   1040 <lock@plt>
mov    $0x5,%edi
mov    $0xa,%esi
call   1030 <unlock@plt>
mov    $0x14,%edi
mov    $0x5,%esi
call   1030 <unlock@plt>
mov    $0x23,%edi
mov    $0xa,%esi
call   1030 <unlock@plt>
mov    $0x3b6,%edi
mov    $0x64,%esi
call   1030 <unlock@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
mov    $0x1e,%edx
call   1040 <lock@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    $0x1e,%edx
mov    %edx,%esi
call   1040 <lock@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ranges>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <unlock@plt>
mov    0x2e83(%rip),%rbx
mov    (%rbx),%edi
mov    $0xa,%esi
mov    $0xa,%edx
call   1050 <lock@plt>
mov    (%rbx),%edi
mov    $0x1e,%esi
mov    $0xa,%edx
call   1050 <lock@plt>
mov    (%rbx),%edi
mov    $0x14,%esi
mov    $0xa,%edx
call   1050 <lock@plt>
mov    (%rbx),%edi
mov    $0x3e8,%esi
xor    %edx,%edx
call   1050 <lock@plt>
mov    $0x5,%edi
mov    $0xa,%esi
call   1030 <unlock@plt>
mov    $0x14,%edi
mov    $0x5,%esi
call   1030 <unlock@plt>
mov    $0x23,%edi
mov    $0xa,%esi
call   1030 <unlock@plt>
mov    $0x3b6,%edi
mov    $0x64,%esi
call   1030 <unlock@plt>
mov    0x2e0f(%rip),%rbx
mov    (%rbx),%edi
xor    %esi,%esi
mov    $0x1e,%edx
call   1050 <lock@plt>
mov    (%rbx),%edi
mov    $0x1e,%esi
mov    $0x1e,%edx
pop    %rbx
jmp    1050 <lock@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"testing ranges...\0A\00"
@F_RDLCK = global i32 0
@F_WRLCK = global i32 0
define void @test_ranges() {
%1 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @unlock(i32 0, i32 0)
%3 = load i32, i32* @F_RDLCK
%4 = call i32 @lock(i32 %3, i32 10, i32 10)
%5 = load i32, i32* @F_RDLCK
%6 = call i32 @lock(i32 %5, i32 30, i32 10)
%7 = load i32, i32* @F_RDLCK
%8 = call i32 @lock(i32 %7, i32 20, i32 10)
%9 = load i32, i32* @F_RDLCK
%10 = call i32 @lock(i32 %9, i32 1000, i32 0)
%11 = call i32 @unlock(i32 5, i32 10)
%12 = call i32 @unlock(i32 20, i32 5)
%13 = call i32 @unlock(i32 35, i32 10)
%14 = call i32 @unlock(i32 950, i32 100)
%15 = load i32, i32* @F_WRLCK
%16 = call i32 @lock(i32 %15, i32 0, i32 30)
%17 = load i32, i32* @F_WRLCK
%18 = call i32 @lock(i32 %17, i32 30, i32 30)
ret void
}

LLVM IR (-O2):
@F_RDLCK = global i32 0
@F_WRLCK = global i32 0
@str = [18 x i8] c"testing ranges...\00"
define void @test_ranges() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @unlock(i32 0, i32 0)
%3 = load i32, i32* @F_RDLCK
%4 = tail call i32 @lock(i32 %3, i32 10, i32 10)
%5 = load i32, i32* @F_RDLCK
%6 = tail call i32 @lock(i32 %5, i32 30, i32 10)
%7 = load i32, i32* @F_RDLCK
%8 = tail call i32 @lock(i32 %7, i32 20, i32 10)
%9 = load i32, i32* @F_RDLCK
%10 = tail call i32 @lock(i32 %9, i32 1000, i32 0)
%11 = tail call i32 @unlock(i32 5, i32 10)
%12 = tail call i32 @unlock(i32 20, i32 5)
%13 = tail call i32 @unlock(i32 35, i32 10)
%14 = tail call i32 @unlock(i32 950, i32 100)
%15 = load i32, i32* @F_WRLCK
%16 = tail call i32 @lock(i32 %15, i32 0, i32 30)
%17 = load i32, i32* @F_WRLCK
%18 = tail call i32 @lock(i32 %17, i32 30, i32 30)
ret void
}