#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 strlen(char const *);
int scpdu_check_id(const unsigned char *pdu, const char *id, int pduSize) {
  int index;
  if (pduSize < strlen(id) + 3) {
    return 0;
  }
  index = 0;
  while (index < strlen(id) + 1) {
    if ((pdu + 2)[index] != id[index++]) {
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<scpdu_check_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    $0x3,%ecx
cmp    %ecx,%eax
jge    114e <scpdu_check_id+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <scpdu_check_id+0xa7>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11b0 <scpdu_check_id+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movzbl 0x2(%rax,%rcx,1),%eax
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%edx
mov    %edx,%esi
add    $0x1,%esi
mov    %esi,-0x20(%rbp)
movslq %edx,%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11ab <scpdu_check_id+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    11b7 <scpdu_check_id+0xa7>
jmp    1155 <scpdu_check_id+0x45>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scpdu_check_id>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
add    $0x3,%ecx
xor    %eax,%eax
cmp    %ebp,%ecx
jg     116a <scpdu_check_id+0x5a>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jg     1165 <scpdu_check_id+0x55>
movzbl 0x2(%r14,%rbp,1),%eax
movsbl (%rbx,%rbp,1),%ecx
add    $0x1,%rbp
cmp    %ecx,%eax
je     1140 <scpdu_check_id+0x30>
xor    %eax,%eax
jmp    116a <scpdu_check_id+0x5a>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @scpdu_check_id(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i32, i32* %7
%10 = load i8*, i8** %6
%11 = call i32 @strlen(i8* %10)
%12 = add nsw i32 %11, 3
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %15
14: ; preds = %3
store i32 0, i32* %4
br label %41
15: ; preds = %3
store i32 0, i32* %8
br label %16
16: ; preds = %39, %15
%17 = load i32, i32* %8
%18 = load i8*, i8** %6
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = icmp slt i32 %17, %20
br i1 %21, label %22, label %40
22: ; preds = %16
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i8*, i8** %6
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
%33 = sext i32 %31 to i64
%34 = getelementptr inbounds i8, i8* %30, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %29, %36
br i1 %37, label %38, label %39
38: ; preds = %22
store i32 0, i32* %4
br label %41
39: ; preds = %22
br label %16
40: ; preds = %16
store i32 1, i32* %4
br label %41
41: ; preds = %40, %38, %14
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @scpdu_check_id(i8* nocapture %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, 3
%6 = icmp sgt i32 %5, %2
br i1 %6, label %23, label %7
7: ; preds = %3
%8 = getelementptr inbounds i8, i8* %0, i64 2
br label %9
9: ; preds = %7, %14
%10 = phi i64 [ 0, %7 ], [ %18, %14 ]
%11 = tail call i32 @strlen(i8* %1)
%12 = sext i32 %11 to i64
%13 = icmp sgt i64 %10, %12
br i1 %13, label %23, label %14
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %8, i64 %10
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = add nuw nsw i64 %10, 1
%19 = getelementptr inbounds i8, i8* %1, i64 %10
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %17, %21
br i1 %22, label %9, label %23
23: ; preds = %9, %14, %3
%24 = phi i32 [ 0, %3 ], [ 1, %9 ], [ 0, %14 ]
ret i32 %24
}