#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*/ assert(int);
int sscanf(char *, char *, long *, long *);
int check(void *key, size_t keylen, void *data, size_t dlen, void *cbdata) {
  assert(keylen == sizeof(int));
  assert(!cbdata);
  int i = *(int *)key;
  long l, a;
  int nfields = sscanf((char *)data, "%ld %ld", &a, &l);
  assert(i == l);
  return 0;
}


x86 assembly (clang, -O0):
<check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
cmpq   $0x4,-0x10(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpq   $0x0,-0x28(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8a(%rip),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1040 <sscanf@plt>
mov    %eax,-0x44(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x38(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%rbx
mov    %rdx,%r14
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x4,%rsi
sete   %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
sete   %dil
call   1030 <assert@plt>
movslq (%r15),%rbx
lea    0xea7(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rsp,%rcx
mov    %r14,%rdi
call   1040 <sscanf@plt>
xor    %edi,%edi
cmp    %rbx,(%rsp)
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%ld %ld\00"
define i32 @check(i8* %0, i64 %1, i8* %2, i64 %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i64
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
store i8* %4, i8** %10
%15 = load i64, i64* %7
%16 = icmp eq i64 %15, 4
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i8*, i8** %10
%20 = icmp ne i8* %19, null
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i8*, i8** %6
%25 = bitcast i8* %24 to i32*
%26 = load i32, i32* %25
store i32 %26, i32* %11
%27 = load i8*, i8** %8
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %13, i64* %12)
store i32 %28, i32* %14
%29 = load i32, i32* %11
%30 = sext i32 %29 to i64
%31 = load i64, i64* %12
%32 = icmp eq i64 %30, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%ld %ld\00"
define i32 @check(i8* nocapture %0, i64 %1, i8* nocapture %2, i64 %3, i8* readnone %4) {
%6 = alloca i64
%7 = alloca i64
%8 = icmp eq i64 %1, 4
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = icmp eq i8* %4, null
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = bitcast i8* %0 to i32*
%15 = load i32, i32* %14
%16 = bitcast i64* %6 to i8*
%17 = bitcast i64* %7 to i8*
%18 = call i32 @sscanf(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %7, i64* %6)
%19 = sext i32 %15 to i64
%20 = load i64, i64* %6
%21 = icmp eq i64 %20, %19
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
ret i32 0
}