#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*/ abort_crypto_lib(char *);
void check_tag(char *buffer, char tag) {
  int offset = 0;
  while (offset < 10) {
    if (tag != *(buffer + offset))
      abort_crypto_lib("Checking tag failed");
    offset = offset + 1;
  }
}


x86 assembly (clang, -O0):
<check_tag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    1165 <check_tag+0x55>
movsbl -0x9(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x10(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1157 <check_tag+0x47>
lea    0xeae(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1129 <check_tag+0x19>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_tag>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
cmp    %bpl,(%rdi)
jne    1172 <check_tag+0x62>
cmp    %bpl,0x1(%rbx)
jne    1184 <check_tag+0x74>
cmp    %bpl,0x2(%rbx)
jne    1196 <check_tag+0x86>
cmp    %bpl,0x3(%rbx)
jne    11a8 <check_tag+0x98>
cmp    %bpl,0x4(%rbx)
jne    11be <check_tag+0xae>
cmp    %bpl,0x5(%rbx)
jne    11d4 <check_tag+0xc4>
cmp    %bpl,0x6(%rbx)
jne    11ea <check_tag+0xda>
cmp    %bpl,0x7(%rbx)
jne    1200 <check_tag+0xf0>
cmp    %bpl,0x8(%rbx)
jne    1216 <check_tag+0x106>
cmp    %bpl,0x9(%rbx)
jne    122c <check_tag+0x11c>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe87(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x1(%rbx)
je     1123 <check_tag+0x13>
lea    0xe75(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x2(%rbx)
je     1129 <check_tag+0x19>
lea    0xe63(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x3(%rbx)
je     112f <check_tag+0x1f>
lea    0xe51(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x4(%rbx)
je     1139 <check_tag+0x29>
lea    0xe3b(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x5(%rbx)
je     1143 <check_tag+0x33>
lea    0xe25(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x6(%rbx)
je     114d <check_tag+0x3d>
lea    0xe0f(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x7(%rbx)
je     1157 <check_tag+0x47>
lea    0xdf9(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x8(%rbx)
je     1161 <check_tag+0x51>
lea    0xde3(%rip),%rdi
call   1030 <abort_crypto_lib@plt>
cmp    %bpl,0x9(%rbx)
je     116b <check_tag+0x5b>
lea    0xdcd(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <abort_crypto_lib@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Checking tag failed\00"
define void @check_tag(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i8 %1, i8* %4
store i32 0, i32* %5
br label %6
6: ; preds = %21, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = load i8, i8* %4
%11 = sext i8 %10 to i32
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %11, %17
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %9
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %6
24: ; preds = %6
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Checking tag failed\00"
define void @check_tag(i8* nocapture %0, i8 signext %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, %1
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, %1
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = getelementptr inbounds i8, i8* %0, i64 2
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, %1
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = getelementptr inbounds i8, i8* %0, i64 3
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, %1
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = getelementptr inbounds i8, i8* %0, i64 4
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, %1
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = getelementptr inbounds i8, i8* %0, i64 5
%33 = load i8, i8* %32
%34 = icmp eq i8 %33, %1
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %35, %31
%38 = getelementptr inbounds i8, i8* %0, i64 6
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, %1
br i1 %40, label %43, label %41
41: ; preds = %37
%42 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = getelementptr inbounds i8, i8* %0, i64 7
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, %1
br i1 %46, label %49, label %47
47: ; preds = %43
%48 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %49
49: ; preds = %47, %43
%50 = getelementptr inbounds i8, i8* %0, i64 8
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, %1
br i1 %52, label %55, label %53
53: ; preds = %49
%54 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = getelementptr inbounds i8, i8* %0, i64 9
%57 = load i8, i8* %56
%58 = icmp eq i8 %57, %1
br i1 %58, label %61, label %59
59: ; preds = %55
%60 = tail call i32 @abort_crypto_lib(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %61
61: ; preds = %59, %55
ret void
}