#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 stun_get_method_str(unsigned char const *, size_t);
scalar_t__ stun_is_command_message_str(unsigned char const *, size_t);
scalar_t__ stun_is_request_str(unsigned char const *, size_t);
int stun_is_binding_request_str(const unsigned char *buf, size_t len,
                                size_t offset) {
  if (offset < len) {
    buf += offset;
    len -= offset;
    if (stun_is_command_message_str(buf, len)) {
      if (stun_is_request_str(buf, len) &&
          (stun_get_method_str(buf, len) == (0x0001))) {
        return 1;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<stun_is_binding_request_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11c7 <stun_is_binding_request_str+0x97>
mov    -0x20(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <stun_is_command_message_str@plt>
cmp    $0x0,%rax
je     11c2 <stun_is_binding_request_str+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <stun_is_request_str@plt>
cmp    $0x0,%rax
je     11bd <stun_is_binding_request_str+0x8d>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <stun_get_method_str@plt>
cmp    $0x1,%eax
jne    11bd <stun_is_binding_request_str+0x8d>
movl   $0x1,-0x4(%rbp)
jmp    11ce <stun_is_binding_request_str+0x9e>
jmp    11c2 <stun_is_binding_request_str+0x92>
jmp    11c7 <stun_is_binding_request_str+0x97>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stun_is_binding_request_str>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
sub    %rdx,%rbx
jbe    1179 <stun_is_binding_request_str+0x49>
mov    %rdi,%r14
add    %rdx,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <stun_is_command_message_str@plt>
test   %rax,%rax
je     1179 <stun_is_binding_request_str+0x49>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <stun_is_request_str@plt>
test   %rax,%rax
je     1179 <stun_is_binding_request_str+0x49>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <stun_get_method_str@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x1,%ecx
je     117b <stun_is_binding_request_str+0x4b>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @stun_is_binding_request_str(i8* %0, i64 %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%8 = load i64, i64* %7
%9 = load i64, i64* %6
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %35
11: ; preds = %3
%12 = load i64, i64* %7
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 %12
store i8* %14, i8** %5
%15 = load i64, i64* %7
%16 = load i64, i64* %6
%17 = sub i64 %16, %15
store i64 %17, i64* %6
%18 = load i8*, i8** %5
%19 = load i64, i64* %6
%20 = call i64 @stun_is_command_message_str(i8* %18, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %34
22: ; preds = %11
%23 = load i8*, i8** %5
%24 = load i64, i64* %6
%25 = call i64 @stun_is_request_str(i8* %23, i64 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = load i64, i64* %6
%30 = call i32 @stun_get_method_str(i8* %28, i64 %29)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %33
32: ; preds = %27
store i32 1, i32* %4
br label %36
33: ; preds = %27, %22
br label %34
34: ; preds = %33, %11
br label %35
35: ; preds = %34, %3
store i32 0, i32* %4
br label %36
36: ; preds = %35, %32
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @stun_is_binding_request_str(i8* %0, i64 %1, i64 %2) {
%4 = icmp ugt i64 %1, %2
br i1 %4, label %5, label %16
5: ; preds = %3
%6 = getelementptr inbounds i8, i8* %0, i64 %2
%7 = sub i64 %1, %2
%8 = tail call i64 @stun_is_command_message_str(i8* %6, i64 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = tail call i64 @stun_is_request_str(i8* %6, i64 %7)
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @stun_get_method_str(i8* %6, i64 %7)
%15 = icmp eq i32 %14, 1
br i1 %15, label %17, label %16
16: ; preds = %5, %13, %10, %3
br label %17
17: ; preds = %13, %16
%18 = phi i32 [ 0, %16 ], [ 1, %13 ]
ret i32 %18
}