#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 */
typedef int /*<<< orphan*/ SSL;

/* Variables and functions */
int serverinfo_find_extension(unsigned char const *, size_t, unsigned int,
                              unsigned char const **, size_t *);
scalar_t__ ssl_get_server_cert_serverinfo(int /*<<< orphan*/ *,
                                          unsigned char const **, size_t *);
int serverinfo_srv_add_cb(SSL *s, unsigned int ext_type,
                          const unsigned char **out, size_t *outlen, int *al,
                          void *arg) {
  const unsigned char *serverinfo = NULL;
  size_t serverinfo_length = 0;
  if ((ssl_get_server_cert_serverinfo(s, &serverinfo, &serverinfo_length)) !=
      0) {
    int retval = serverinfo_find_extension(serverinfo, serverinfo_length,
                                           ext_type, out, outlen);
    if (retval == 0)
      return 0;
    if (retval == -1)
      return -1;
    return 1;
  }
  return -1;
}


x86 assembly (clang, -O0):
<serverinfo_srv_add_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   1030 <ssl_get_server_cert_serverinfo@plt>
cmp    $0x0,%rax
je     11bd <serverinfo_srv_add_cb+0x9d>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
call   1040 <serverinfo_find_extension@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jne    119b <serverinfo_srv_add_cb+0x7b>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <serverinfo_srv_add_cb+0xa4>
cmpl   $0xffffffff,-0x4c(%rbp)
jne    11b1 <serverinfo_srv_add_cb+0x91>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c4 <serverinfo_srv_add_cb+0xa4>
movl   $0x1,-0x4(%rbp)
jmp    11c4 <serverinfo_srv_add_cb+0xa4>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serverinfo_srv_add_cb>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %esi,%ebp
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
lea    0x8(%rsp),%rsi
mov    %rsp,%rdx
call   1030 <ssl_get_server_cert_serverinfo@plt>
test   %rax,%rax
je     117f <serverinfo_srv_add_cb+0x5f>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
mov    %ebp,%edx
mov    %rbx,%rcx
mov    %r14,%r8
call   1040 <serverinfo_find_extension@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
setne  %al
add    %eax,%eax
add    $0xffffffff,%eax
test   %ecx,%ecx
cmove  %ecx,%eax
jmp    1184 <serverinfo_srv_add_cb+0x64>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @serverinfo_srv_add_cb(i32* %0, i32 %1, i8** %2, i64* %3, i32* nocapture readnone %4, i8* nocapture readnone %5) {
%7 = alloca i8*
%8 = alloca i64
%9 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%10 = bitcast i64* %8 to i8*
store i64 0, i64* %8
%11 = call i64 @ssl_get_server_cert_serverinfo(i32* %0, i8** %7, i64* %8)
%12 = icmp eq i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %6
%14 = load i8*, i8** %7
%15 = load i64, i64* %8
%16 = call i32 @serverinfo_find_extension(i8* %14, i64 %15, i32 %1, i8** %2, i64* %3)
%17 = icmp eq i32 %16, -1
%18 = select i1 %17, i32 -1, i32 1
%19 = icmp eq i32 %16, 0
%20 = select i1 %19, i32 0, i32 %18
br label %21
21: ; preds = %13, %6
%22 = phi i32 [ -1, %6 ], [ %20, %13 ]
ret i32 %22
}