#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*/ token_names;
struct libwebsocket {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ lws_hdr_copy(struct libwebsocket *, char *, int, int);
int /*<<< orphan*/ lws_hdr_total_length(struct libwebsocket *, int);
int /*<<< orphan*/ stderr;
void dump_handshake_info(struct libwebsocket *wsi) {
  int n;
  static const char *token_names[] = {
      "GET URI",
      "POST URI",
      "Host",
      "Connection",
      "key 1",
      "key 2",
      "Protocol",
      "Upgrade",
      "Origin",
      "Draft",
      "Challenge",
      "Key",
      "Version",
      "Sworigin",
      "Extensions",
      "Accept",
      "Nonce",
      "Http",
      "Accept:",
      "If-Modified-Since:",
      "Accept-Encoding:",
      "Accept-Language:",
      "Pragma:",
      "Cache-Control:",
      "Authorization:",
      "Cookie:",
      "Content-Length:",
      "Content-Type:",
      "Date:",
      "Range:",
      "Referer:",
      "Uri-Args:",
      "MuxURL",
  };
  char buf[256];
  for (n = 0; n < sizeof(token_names) / sizeof(token_names[0]); n++) {
    if (!lws_hdr_total_length(wsi, n))
      continue;
    lws_hdr_copy(wsi, buf, sizeof buf, n);
    fprintf(stderr, "    %s = %s\n", token_names[n], buf);
  }
}


x86 assembly (clang, -O0):
<dump_handshake_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rax
cmp    $0x21,%rax
jae    11bf <dump_handshake_info+0x8f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <lws_hdr_total_length@plt>
cmp    $0x0,%eax
jne    116e <dump_handshake_info+0x3e>
jmp    11b1 <dump_handshake_info+0x81>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0xc(%rbp),%ecx
mov    $0x100,%edx
call   1050 <lws_hdr_copy@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
movslq -0xc(%rbp),%rcx
lea    0x2ea6(%rip),%rax
mov    (%rax,%rcx,8),%rdx
lea    -0x110(%rbp),%rcx
lea    0xf8b(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <dump_handshake_info+0x16>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_handshake_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%r14
lea    0xeb5(%rip),%r13
xor    %ebx,%ebx
mov    %rsp,%r15
lea    0x1064(%rip),%r12
mov    %r13,%rbp
jmp    116e <dump_handshake_info+0x3e>
nopl   0x0(%rax)
add    $0x1,%rbx
add    $0x4,%r13
cmp    $0x21,%rbx
je     11ab <dump_handshake_info+0x7b>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <lws_hdr_total_length@plt>
test   %eax,%eax
je     1160 <dump_handshake_info+0x30>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x100,%edx
mov    %ebx,%ecx
call   1050 <lws_hdr_copy@plt>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
movslq 0x0(%r13),%rdx
add    %rbp,%rdx
mov    %r12,%rsi
mov    %r15,%rcx
call   1040 <fprintf@plt>
jmp    1160 <dump_handshake_info+0x30>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.libwebsocket = type { i32 }
@dump_handshake_info.token_names = internal global [33 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.15, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.16, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.18, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.19, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.20, i32 0, i32 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.21, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.22, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.23, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.24, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.25, i32 0, i32 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.27, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.30, i32 0, i32 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.31, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i32 0, i32 0)]
@.str = [8 x i8] c"GET URI\00"
@.str.1 = [9 x i8] c"POST URI\00"
@.str.2 = [5 x i8] c"Host\00"
@.str.3 = [11 x i8] c"Connection\00"
@.str.4 = [6 x i8] c"key 1\00"
@.str.5 = [6 x i8] c"key 2\00"
@.str.6 = [9 x i8] c"Protocol\00"
@.str.7 = [8 x i8] c"Upgrade\00"
@.str.8 = [7 x i8] c"Origin\00"
@.str.9 = [6 x i8] c"Draft\00"
@.str.10 = [10 x i8] c"Challenge\00"
@.str.11 = [4 x i8] c"Key\00"
@.str.12 = [8 x i8] c"Version\00"
@.str.13 = [9 x i8] c"Sworigin\00"
@.str.14 = [11 x i8] c"Extensions\00"
@.str.15 = [7 x i8] c"Accept\00"
@.str.16 = [6 x i8] c"Nonce\00"
@.str.17 = [5 x i8] c"Http\00"
@.str.18 = [8 x i8] c"Accept:\00"
@.str.19 = [19 x i8] c"If-Modified-Since:\00"
@.str.20 = [17 x i8] c"Accept-Encoding:\00"
@.str.21 = [17 x i8] c"Accept-Language:\00"
@.str.22 = [8 x i8] c"Pragma:\00"
@.str.23 = [15 x i8] c"Cache-Control:\00"
@.str.24 = [15 x i8] c"Authorization:\00"
@.str.25 = [8 x i8] c"Cookie:\00"
@.str.26 = [16 x i8] c"Content-Length:\00"
@.str.27 = [14 x i8] c"Content-Type:\00"
@.str.28 = [6 x i8] c"Date:\00"
@.str.29 = [7 x i8] c"Range:\00"
@.str.30 = [9 x i8] c"Referer:\00"
@.str.31 = [10 x i8] c"Uri-Args:\00"
@.str.32 = [7 x i8] c"MuxURL\00"
@stderr = global i32 0
@.str.33 = [13 x i8] c" %s = %s\0A\00"
define void @dump_handshake_info(%struct.libwebsocket* %0) {
%2 = alloca %struct.libwebsocket*
%3 = alloca i32
%4 = alloca [256 x i8]
store %struct.libwebsocket* %0, %struct.libwebsocket** %2
store i32 0, i32* %3
br label %5
5: ; preds = %27, %1
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = icmp ult i64 %7, 33
br i1 %8, label %9, label %30
9: ; preds = %5
%10 = load %struct.libwebsocket*, %struct.libwebsocket** %2
%11 = load i32, i32* %3
%12 = call i32 @lws_hdr_total_length(%struct.libwebsocket* %10, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %9
br label %27
15: ; preds = %9
%16 = load %struct.libwebsocket*, %struct.libwebsocket** %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%18 = load i32, i32* %3
%19 = call i32 @lws_hdr_copy(%struct.libwebsocket* %16, i8* %17, i32 256, i32 %18)
%20 = load i32, i32* @stderr
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [33 x i8*], [33 x i8*]* @dump_handshake_info.token_names, i64 0, i64 %22
%24 = load i8*, i8** %23
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%26 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.33, i64 0, i64 0), i8* %24, i8* %25)
br label %27
27: ; preds = %15, %14
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %5
30: ; preds = %5
ret void
}

LLVM IR (-O2):
%struct.libwebsocket = type { i32 }
@reltable.dump_handshake_info = internal unnamed_addr constant [33 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.1 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.3 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.4 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.5 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.8 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.9 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.10 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.11 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.13 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.14 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.15 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.16 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.17 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.18 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.19 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.20 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.21 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.22 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.23 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.24 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.25 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([16 x i8]* @.str.26 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.27 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.28 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.29 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.30 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.31 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.32 to i64), i64 ptrtoint ([33 x i32]* @reltable.dump_handshake_info to i64)) to i32)]
@.str = [8 x i8] c"GET URI\00"
@.str.1 = [9 x i8] c"POST URI\00"
@.str.2 = [5 x i8] c"Host\00"
@.str.3 = [11 x i8] c"Connection\00"
@.str.4 = [6 x i8] c"key 1\00"
@.str.5 = [6 x i8] c"key 2\00"
@.str.6 = [9 x i8] c"Protocol\00"
@.str.7 = [8 x i8] c"Upgrade\00"
@.str.8 = [7 x i8] c"Origin\00"
@.str.9 = [6 x i8] c"Draft\00"
@.str.10 = [10 x i8] c"Challenge\00"
@.str.11 = [4 x i8] c"Key\00"
@.str.12 = [8 x i8] c"Version\00"
@.str.13 = [9 x i8] c"Sworigin\00"
@.str.14 = [11 x i8] c"Extensions\00"
@.str.15 = [7 x i8] c"Accept\00"
@.str.16 = [6 x i8] c"Nonce\00"
@.str.17 = [5 x i8] c"Http\00"
@.str.18 = [8 x i8] c"Accept:\00"
@.str.19 = [19 x i8] c"If-Modified-Since:\00"
@.str.20 = [17 x i8] c"Accept-Encoding:\00"
@.str.21 = [17 x i8] c"Accept-Language:\00"
@.str.22 = [8 x i8] c"Pragma:\00"
@.str.23 = [15 x i8] c"Cache-Control:\00"
@.str.24 = [15 x i8] c"Authorization:\00"
@.str.25 = [8 x i8] c"Cookie:\00"
@.str.26 = [16 x i8] c"Content-Length:\00"
@.str.27 = [14 x i8] c"Content-Type:\00"
@.str.28 = [6 x i8] c"Date:\00"
@.str.29 = [7 x i8] c"Range:\00"
@.str.30 = [9 x i8] c"Referer:\00"
@.str.31 = [10 x i8] c"Uri-Args:\00"
@.str.32 = [7 x i8] c"MuxURL\00"
@stderr = global i32 0
@.str.33 = [13 x i8] c" %s = %s\0A\00"
define void @dump_handshake_info(%struct.libwebsocket* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %1, %15
%5 = phi i64 [ 0, %1 ], [ %16, %15 ]
%6 = trunc i64 %5 to i32
%7 = call i32 @lws_hdr_total_length(%struct.libwebsocket* %0, i32 %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = call i32 @lws_hdr_copy(%struct.libwebsocket* %0, i8* %3, i32 256, i32 %6)
%11 = load i32, i32* @stderr
%12 = shl i64 %5, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([33 x i32]* @reltable.dump_handshake_info to i8*), i64 %12)
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.33, i64 0, i64 0), i8* %13, i8* %3)
br label %15
15: ; preds = %4, %9
%16 = add nuw nsw i64 %5, 1
%17 = icmp eq i64 %16, 33
br i1 %17, label %18, label %4
18: ; preds = %15
ret void
}