#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*/ strncmp(char const *, char const *, int);
const char *extract_tlsmajor(const char *token) {
  const char *lookfor;
  if ((lookfor = "SSLv3", !strncmp(token, lookfor, 5)) ||
      (lookfor = "TLSv1.1", !strncmp(token, lookfor, 7)) ||
      (lookfor = "TLSv1.2", !strncmp(token, lookfor, 7)) ||
      (lookfor = "TLSv1.3", !strncmp(token, lookfor, 7)) ||
      (lookfor = "TLS1.1", !strncmp(token, lookfor, 6)) ||
      (lookfor = "TLS1.2", !strncmp(token, lookfor, 6)) ||
      (lookfor = "TLS1.3", !strncmp(token, lookfor, 6)) ||
      (lookfor = "TLSv1", !strncmp(token, lookfor, 5)) ||
      (lookfor = "TLS1", !strncmp(token, lookfor, 4)))
    return lookfor;
  return NULL;
}


x86 assembly (clang, -O0):
<extract_tlsmajor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xedd(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xeb6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xe91(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xe6c(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xe47(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xe21(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xdfb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xdd5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
lea    0xdae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12b6 <extract_tlsmajor+0x1a6>
jmp    12c3 <extract_tlsmajor+0x1b3>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12cb <extract_tlsmajor+0x1bb>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<extract_tlsmajor>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
lea    0xee1(%rip),%rbx
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xecb(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xeb4(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe9d(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe86(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe72(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe5e(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe4a(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     121c <extract_tlsmajor+0x10c>
lea    0xe35(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
cmove  %r15,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [6 x i8] c"SSLv3\00"
@.str.1 = [8 x i8] c"TLSv1.1\00"
@.str.2 = [8 x i8] c"TLSv1.2\00"
@.str.3 = [8 x i8] c"TLSv1.3\00"
@.str.4 = [7 x i8] c"TLS1.1\00"
@.str.5 = [7 x i8] c"TLS1.2\00"
@.str.6 = [7 x i8] c"TLS1.3\00"
@.str.7 = [6 x i8] c"TLSv1\00"
@.str.8 = [5 x i8] c"TLS1\00"
define i8* @extract_tlsmajor(i8* %0) {
%2 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%3 = icmp eq i32 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1
%5 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 7)
%6 = icmp eq i32 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %4
%8 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %7
%11 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%12 = icmp eq i32 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %10
%14 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%15 = icmp eq i32 %14, 0
br i1 %15, label %29, label %16
16: ; preds = %13
%17 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i32 6)
%18 = icmp eq i32 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %16
%20 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 6)
%21 = icmp eq i32 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %19
%23 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %22
%26 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i32 4)
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* null
br label %29
29: ; preds = %25, %1, %4, %7, %10, %13, %16, %19, %22
%30 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %10 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), %13 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %19 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), %22 ], [ %28, %25 ]
ret i8* %30
}