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

/* Variables and functions */
int /*<<< orphan*/ FRAMERR(struct NetFrame *, char *, ...);
int /*<<< orphan*/ isprint(char);
unsigned netbios_copy_name_dns(struct NetFrame *frame, const unsigned char *px,
                               unsigned length, unsigned offset, char *name,
                               unsigned sizeof_name) {
  unsigned j = 0;
  unsigned k = 0;
  name[0] = '\0';
  while (offset < length) {
    unsigned len;
    len = px[offset++];
    if (len == 0)
      break;
    if (len & 0xc0) {
      if (offset >= length) {
        FRAMERR(frame, "netbios: name too short\n");
        break;
      }
      len = (len << 8) || px[offset++];
      break;
    }
    for (j = 0; j < len && offset < length; j++) {
      char c = px[offset++];
      if (c < 'A' || c > 'A' + 15)
        FRAMERR(frame, "netbios: bad netbios name char %c (0x%02x) \n", c, c);
      if (k > sizeof_name - 1) {
        FRAMERR(frame, "netbios: name too long\n");
        break;
      }
      name[k] = (char)((c - 'A') << 4);
      name[k + 1] = '\0';
      j++;
      if (offset >= length) {
        FRAMERR(frame, "netbios: name too short\n");
        break;
      }
      c = px[offset++];
      if (c < 'A' || c > 'A' + 15)
        FRAMERR(frame, "netbios: bad netbios name char %c (0x%02x) \n", c, c);
      name[k] |= (char)((c - 'A') & 0x0F);
      if (!isprint(name[k])) {
        if (k + 3 > sizeof_name - 1) {
          FRAMERR(frame, "netbios: name too long\n");
          break;
        }
        name[k + 1] = "0123456789ABCDEF"[(name[k] >> 4) & 0xF];
        name[k + 2] = "0123456789ABCDEF"[(name[k] >> 0) & 0xF];
        name[k + 3] = '>';
        name[k + 4] = '\0';
        name[k] = '<';
        k += 4;
      } else
        k++;
    }
  }
  return offset;
}


x86 assembly (clang, -O0):
<netbios_copy_name_dns>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1455 <netbios_copy_name_dns+0x335>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    1186 <netbios_copy_name_dns+0x66>
jmp    1455 <netbios_copy_name_dns+0x335>
mov    -0x30(%rbp),%eax
and    $0xc0,%eax
cmp    $0x0,%eax
je     11fc <netbios_copy_name_dns+0xdc>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jb     11ba <netbios_copy_name_dns+0x9a>
mov    -0x8(%rbp),%rdi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
jmp    1455 <netbios_copy_name_dns+0x335>
mov    -0x30(%rbp),%ecx
shl    $0x8,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x32(%rbp)
jne    11ec <netbios_copy_name_dns+0xcc>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    %ecx,%ecx
movzbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x30(%rbp)
jmp    1455 <netbios_copy_name_dns+0x335>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x30(%rbp),%ecx
mov    %al,-0x33(%rbp)
jae    1220 <netbios_copy_name_dns+0x100>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setb   %al
mov    %al,-0x33(%rbp)
mov    -0x33(%rbp),%al
test   $0x1,%al
jne    1230 <netbios_copy_name_dns+0x110>
jmp    1450 <netbios_copy_name_dns+0x330>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
cmp    $0x41,%eax
jl     1261 <netbios_copy_name_dns+0x141>
movsbl -0x31(%rbp),%eax
cmp    $0x50,%eax
jle    127b <netbios_copy_name_dns+0x15b>
mov    -0x8(%rbp),%rdi
movsbl -0x31(%rbp),%edx
movsbl -0x31(%rbp),%ecx
lea    0xda5(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jbe    12a3 <netbios_copy_name_dns+0x183>
mov    -0x8(%rbp),%rdi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
jmp    1450 <netbios_copy_name_dns+0x330>
movsbl -0x31(%rbp),%eax
sub    $0x41,%eax
shl    $0x4,%eax
mov    %al,%dl
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jb     12f5 <netbios_copy_name_dns+0x1d5>
mov    -0x8(%rbp),%rdi
lea    0xd17(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
jmp    1450 <netbios_copy_name_dns+0x330>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
mov    %ecx,%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
cmp    $0x41,%eax
jl     1326 <netbios_copy_name_dns+0x206>
movsbl -0x31(%rbp),%eax
cmp    $0x50,%eax
jle    1340 <netbios_copy_name_dns+0x220>
mov    -0x8(%rbp),%rdi
movsbl -0x31(%rbp),%edx
movsbl -0x31(%rbp),%ecx
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
movsbl -0x31(%rbp),%eax
sub    $0x41,%eax
and    $0xf,%eax
movsbl %al,%esi
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsbl (%rax,%rcx,1),%edx
or     %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1040 <isprint@plt>
cmp    $0x0,%eax
jne    1434 <netbios_copy_name_dns+0x314>
mov    -0x2c(%rbp),%eax
add    $0x3,%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jbe    13a1 <netbios_copy_name_dns+0x281>
mov    -0x8(%rbp),%rdi
lea    0xcb1(%rip),%rsi
mov    $0x0,%al
call   1030 <FRAMERR@plt>
jmp    1450 <netbios_copy_name_dns+0x330>
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
sar    $0x4,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xca2(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
sar    $0x0,%eax
and    $0xf,%eax
movslq %eax,%rcx
lea    0xc75(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x2,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x3,%ecx
mov    %ecx,%ecx
movb   $0x3e,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
add    $0x4,%ecx
mov    %ecx,%ecx
movb   $0x0,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movb   $0x3c,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x2c(%rbp)
jmp    143d <netbios_copy_name_dns+0x31d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1442 <netbios_copy_name_dns+0x322>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1203 <netbios_copy_name_dns+0xe3>
jmp    1153 <netbios_copy_name_dns+0x33>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<netbios_copy_name_dns>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %ecx,%r13d
mov    %rdi,0x10(%rsp)
mov    %r8,0x20(%rsp)
movb   $0x0,(%r8)
cmp    %edx,%ecx
jae    1399 <netbios_copy_name_dns+0x279>
mov    %r9d,%ebp
add    $0xffffffff,%ebp
mov    %edx,%eax
mov    %rax,0x38(%rsp)
lea    0x1(%rsi),%rax
mov    %rax,0x48(%rsp)
xor    %ebx,%ebx
mov    %ebp,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    %rsi,0x18(%rsp)
jmp    117f <netbios_copy_name_dns+0x5f>
xchg   %ax,%ax
mov    %ebx,%r15d
mov    %r15d,%ebx
cmp    %edx,%r13d
jae    1399 <netbios_copy_name_dns+0x279>
mov    %r13d,%eax
add    $0x1,%r13d
movzbl (%rsi,%rax,1),%r8d
test   %r8d,%r8d
je     1399 <netbios_copy_name_dns+0x279>
test   $0xc0,%r8b
jne    1381 <netbios_copy_name_dns+0x261>
cmp    %edx,%r13d
jae    1170 <netbios_copy_name_dns+0x50>
mov    %rax,0x28(%rsp)
mov    %r13d,%r13d
mov    0x48(%rsp),%rax
add    %r13,%rax
mov    %rax,0x40(%rsp)
xor    %r14d,%r14d
mov    %r13,0x50(%rsp)
mov    %r8d,0x34(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x40(%rsp),%rax
movsbl -0x1(%rax,%r14,1),%r12d
lea    -0x51(%r12),%eax
cmp    $0xef,%al
ja     11fd <netbios_copy_name_dns+0xdd>
mov    0x10(%rsp),%rdi
lea    0xe29(%rip),%rsi
mov    %r12d,%edx
mov    %r12d,%ecx
xor    %eax,%eax
call   1030 <FRAMERR@plt>
cmp    %ebp,%ebx
ja     130c <netbios_copy_name_dns+0x1ec>
lea    (%r14,%r13,1),%rax
add    $0x1,%rax
shl    $0x4,%r12b
add    $0xf0,%r12b
mov    %ebx,%ebp
mov    0x20(%rsp),%rcx
mov    %r12b,(%rcx,%rbp,1)
lea    0x1(%rbx),%r15d
movb   $0x0,(%rcx,%r15,1)
cmp    0x38(%rsp),%rax
jae    1331 <netbios_copy_name_dns+0x211>
mov    0x40(%rsp),%rax
movsbl (%rax,%r14,1),%r13d
lea    -0x51(%r13),%eax
cmp    $0xef,%al
ja     1269 <netbios_copy_name_dns+0x149>
mov    0x10(%rsp),%rdi
lea    0xdc7(%rip),%rsi
mov    %r13d,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1030 <FRAMERR@plt>
mov    0x20(%rsp),%rax
movzbl (%rax,%rbp,1),%r12d
add    $0xff,%r13b
and    $0xf,%r13b
or     %r12b,%r13b
mov    0x20(%rsp),%rax
mov    %r13b,(%rax,%rbp,1)
movsbl %r13b,%edi
call   1040 <isprint@plt>
test   %eax,%eax
mov    0x50(%rsp),%r13
mov    0x34(%rsp),%r8d
jne    12e1 <netbios_copy_name_dns+0x1c1>
lea    0x3(%rbx),%eax
cmp    0xc(%rsp),%eax
ja     134c <netbios_copy_name_dns+0x22c>
mov    0x20(%rsp),%rsi
movzbl (%rsi,%rbp,1),%ecx
mov    %rcx,%rdx
shr    $0x4,%rdx
lea    0xda6(%rip),%rdi
movzbl (%rdx,%rdi,1),%edx
mov    %dl,(%rsi,%r15,1)
and    $0xf,%ecx
movzbl (%rcx,%rdi,1),%ecx
lea    0x2(%rbx),%edx
mov    %cl,(%rsi,%rdx,1)
mov    %eax,%eax
movb   $0x3e,(%rsi,%rax,1)
add    $0x4,%ebx
movb   $0x0,(%rsi,%rbx,1)
movb   $0x3c,(%rsi,%rbp,1)
mov    %ebx,%r15d
lea    0x2(%r14),%rax
cmp    %r8d,%eax
mov    0xc(%rsp),%ebp
jae    1307 <netbios_copy_name_dns+0x1e7>
lea    (%r14,%r13,1),%rcx
add    $0x2,%rcx
mov    %rax,%r14
mov    %r15d,%ebx
cmp    0x38(%rsp),%rcx
jb     11d0 <netbios_copy_name_dns+0xb0>
add    %eax,%r13d
jmp    1373 <netbios_copy_name_dns+0x253>
mov    0x28(%rsp),%rax
lea    (%rax,%r14,1),%r13d
add    $0x2,%r13d
mov    0x10(%rsp),%rdi
lea    0xd21(%rip),%rsi
xor    %eax,%eax
mov    %rbx,%r15
call   1030 <FRAMERR@plt>
jmp    1373 <netbios_copy_name_dns+0x253>
mov    0x28(%rsp),%rax
lea    (%rax,%r14,1),%r13d
add    $0x2,%r13d
mov    0x10(%rsp),%rdi
lea    0xcb6(%rip),%rsi
jmp    1365 <netbios_copy_name_dns+0x245>
mov    0x28(%rsp),%rax
lea    (%rax,%r14,1),%r13d
add    $0x3,%r13d
mov    0x10(%rsp),%rdi
lea    0xce1(%rip),%rsi
xor    %eax,%eax
mov    %rbx,%r15
call   1030 <FRAMERR@plt>
mov    0xc(%rsp),%ebp
mov    0x8(%rsp),%edx
mov    0x18(%rsp),%rsi
jmp    1173 <netbios_copy_name_dns+0x53>
cmp    %edx,%r13d
jb     1399 <netbios_copy_name_dns+0x279>
lea    0xc73(%rip),%rsi
mov    0x10(%rsp),%rdi
xor    %eax,%eax
call   1030 <FRAMERR@plt>
mov    %r13d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.NetFrame = type { i32 }
@.str = [25 x i8] c"netbios: name too short\0A\00"
@.str.1 = [45 x i8] c"netbios: bad netbios name char %c (0x%02x) \0A\00"
@.str.2 = [24 x i8] c"netbios: name too long\0A\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
define i32 @netbios_copy_name_dns(%struct.NetFrame* %0, i8* %1, i32 %2, i32 %3, i8* %4, i32 %5) {
%7 = alloca %struct.NetFrame*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
store %struct.NetFrame* %0, %struct.NetFrame** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i32 %5, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
%17 = load i8*, i8** %11
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %18
br label %19
19: ; preds = %232, %6
%20 = load i32, i32* %10
%21 = load i32, i32* %9
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %233
23: ; preds = %19
%24 = load i8*, i8** %8
%25 = load i32, i32* %10
%26 = add i32 %25, 1
store i32 %26, i32* %10
%27 = zext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %24, i64 %27
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
store i32 %30, i32* %15
%31 = load i32, i32* %15
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %23
br label %233
34: ; preds = %23
%35 = load i32, i32* %15
%36 = and i32 %35, 192
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %61
38: ; preds = %34
%39 = load i32, i32* %10
%40 = load i32, i32* %9
%41 = icmp uge i32 %39, %40
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load %struct.NetFrame*, %struct.NetFrame** %7
%44 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %233
45: ; preds = %38
%46 = load i32, i32* %15
%47 = shl i32 %46, 8
%48 = icmp ne i32 %47, 0
br i1 %48, label %58, label %49
49: ; preds = %45
%50 = load i8*, i8** %8
%51 = load i32, i32* %10
%52 = add i32 %51, 1
store i32 %52, i32* %10
%53 = zext i32 %51 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = icmp ne i32 %56, 0
br label %58
58: ; preds = %49, %45
%59 = phi i1 [ true, %45 ], [ %57, %49 ]
%60 = zext i1 %59 to i32
store i32 %60, i32* %15
br label %233
61: ; preds = %34
store i32 0, i32* %13
br label %62
62: ; preds = %229, %61
%63 = load i32, i32* %13
%64 = load i32, i32* %15
%65 = icmp ult i32 %63, %64
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i32, i32* %10
%68 = load i32, i32* %9
%69 = icmp ult i32 %67, %68
br label %70
70: ; preds = %66, %62
%71 = phi i1 [ false, %62 ], [ %69, %66 ]
br i1 %71, label %72, label %232
72: ; preds = %70
%73 = load i8*, i8** %8
%74 = load i32, i32* %10
%75 = add i32 %74, 1
store i32 %75, i32* %10
%76 = zext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
store i8 %78, i8* %16
%79 = load i8, i8* %16
%80 = sext i8 %79 to i32
%81 = icmp slt i32 %80, 65
br i1 %81, label %86, label %82
82: ; preds = %72
%83 = load i8, i8* %16
%84 = sext i8 %83 to i32
%85 = icmp sgt i32 %84, 80
br i1 %85, label %86, label %93
86: ; preds = %82, %72
%87 = load %struct.NetFrame*, %struct.NetFrame** %7
%88 = load i8, i8* %16
%89 = sext i8 %88 to i32
%90 = load i8, i8* %16
%91 = sext i8 %90 to i32
%92 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %87, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %89, i32 %91)
br label %93
93: ; preds = %86, %82
%94 = load i32, i32* %14
%95 = load i32, i32* %12
%96 = sub i32 %95, 1
%97 = icmp ugt i32 %94, %96
br i1 %97, label %98, label %101
98: ; preds = %93
%99 = load %struct.NetFrame*, %struct.NetFrame** %7
%100 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %99, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %232
101: ; preds = %93
%102 = load i8, i8* %16
%103 = sext i8 %102 to i32
%104 = sub nsw i32 %103, 65
%105 = shl i32 %104, 4
%106 = trunc i32 %105 to i8
%107 = load i8*, i8** %11
%108 = load i32, i32* %14
%109 = zext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %107, i64 %109
store i8 %106, i8* %110
%111 = load i8*, i8** %11
%112 = load i32, i32* %14
%113 = add i32 %112, 1
%114 = zext i32 %113 to i64
%115 = getelementptr inbounds i8, i8* %111, i64 %114
store i8 0, i8* %115
%116 = load i32, i32* %13
%117 = add i32 %116, 1
store i32 %117, i32* %13
%118 = load i32, i32* %10
%119 = load i32, i32* %9
%120 = icmp uge i32 %118, %119
br i1 %120, label %121, label %124
121: ; preds = %101
%122 = load %struct.NetFrame*, %struct.NetFrame** %7
%123 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %122, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %232
124: ; preds = %101
%125 = load i8*, i8** %8
%126 = load i32, i32* %10
%127 = add i32 %126, 1
store i32 %127, i32* %10
%128 = zext i32 %126 to i64
%129 = getelementptr inbounds i8, i8* %125, i64 %128
%130 = load i8, i8* %129
store i8 %130, i8* %16
%131 = load i8, i8* %16
%132 = sext i8 %131 to i32
%133 = icmp slt i32 %132, 65
br i1 %133, label %138, label %134
134: ; preds = %124
%135 = load i8, i8* %16
%136 = sext i8 %135 to i32
%137 = icmp sgt i32 %136, 80
br i1 %137, label %138, label %145
138: ; preds = %134, %124
%139 = load %struct.NetFrame*, %struct.NetFrame** %7
%140 = load i8, i8* %16
%141 = sext i8 %140 to i32
%142 = load i8, i8* %16
%143 = sext i8 %142 to i32
%144 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %139, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %141, i32 %143)
br label %145
145: ; preds = %138, %134
%146 = load i8, i8* %16
%147 = sext i8 %146 to i32
%148 = sub nsw i32 %147, 65
%149 = and i32 %148, 15
%150 = trunc i32 %149 to i8
%151 = sext i8 %150 to i32
%152 = load i8*, i8** %11
%153 = load i32, i32* %14
%154 = zext i32 %153 to i64
%155 = getelementptr inbounds i8, i8* %152, i64 %154
%156 = load i8, i8* %155
%157 = sext i8 %156 to i32
%158 = or i32 %157, %151
%159 = trunc i32 %158 to i8
store i8 %159, i8* %155
%160 = load i8*, i8** %11
%161 = load i32, i32* %14
%162 = zext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %160, i64 %162
%164 = load i8, i8* %163
%165 = call i32 @isprint(i8 signext %164)
%166 = icmp ne i32 %165, 0
br i1 %166, label %225, label %167
167: ; preds = %145
%168 = load i32, i32* %14
%169 = add i32 %168, 3
%170 = load i32, i32* %12
%171 = sub i32 %170, 1
%172 = icmp ugt i32 %169, %171
br i1 %172, label %173, label %176
173: ; preds = %167
%174 = load %struct.NetFrame*, %struct.NetFrame** %7
%175 = call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %174, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %232
176: ; preds = %167
%177 = load i8*, i8** %11
%178 = load i32, i32* %14
%179 = zext i32 %178 to i64
%180 = getelementptr inbounds i8, i8* %177, i64 %179
%181 = load i8, i8* %180
%182 = sext i8 %181 to i32
%183 = ashr i32 %182, 4
%184 = and i32 %183, 15
%185 = sext i32 %184 to i64
%186 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.3, i64 0, i64 %185
%187 = load i8, i8* %186
%188 = load i8*, i8** %11
%189 = load i32, i32* %14
%190 = add i32 %189, 1
%191 = zext i32 %190 to i64
%192 = getelementptr inbounds i8, i8* %188, i64 %191
store i8 %187, i8* %192
%193 = load i8*, i8** %11
%194 = load i32, i32* %14
%195 = zext i32 %194 to i64
%196 = getelementptr inbounds i8, i8* %193, i64 %195
%197 = load i8, i8* %196
%198 = sext i8 %197 to i32
%199 = ashr i32 %198, 0
%200 = and i32 %199, 15
%201 = sext i32 %200 to i64
%202 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.3, i64 0, i64 %201
%203 = load i8, i8* %202
%204 = load i8*, i8** %11
%205 = load i32, i32* %14
%206 = add i32 %205, 2
%207 = zext i32 %206 to i64
%208 = getelementptr inbounds i8, i8* %204, i64 %207
store i8 %203, i8* %208
%209 = load i8*, i8** %11
%210 = load i32, i32* %14
%211 = add i32 %210, 3
%212 = zext i32 %211 to i64
%213 = getelementptr inbounds i8, i8* %209, i64 %212
store i8 62, i8* %213
%214 = load i8*, i8** %11
%215 = load i32, i32* %14
%216 = add i32 %215, 4
%217 = zext i32 %216 to i64
%218 = getelementptr inbounds i8, i8* %214, i64 %217
store i8 0, i8* %218
%219 = load i8*, i8** %11
%220 = load i32, i32* %14
%221 = zext i32 %220 to i64
%222 = getelementptr inbounds i8, i8* %219, i64 %221
store i8 60, i8* %222
%223 = load i32, i32* %14
%224 = add i32 %223, 4
store i32 %224, i32* %14
br label %228
225: ; preds = %145
%226 = load i32, i32* %14
%227 = add i32 %226, 1
store i32 %227, i32* %14
br label %228
228: ; preds = %225, %176
br label %229
229: ; preds = %228
%230 = load i32, i32* %13
%231 = add i32 %230, 1
store i32 %231, i32* %13
br label %62
232: ; preds = %173, %121, %98, %70
br label %19
233: ; preds = %58, %42, %33, %19
%234 = load i32, i32* %10
ret i32 %234
}

LLVM IR (-O2):
%struct.NetFrame = type { i32 }
@.str = [25 x i8] c"netbios: name too short\0A\00"
@.str.1 = [45 x i8] c"netbios: bad netbios name char %c (0x%02x) \0A\00"
@.str.2 = [24 x i8] c"netbios: name too long\0A\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
define i32 @netbios_copy_name_dns(%struct.NetFrame* %0, i8* nocapture %1, i32 %2, i32 %3, i8* nocapture %4, i32 %5) {
store i8 0, i8* %4
%7 = icmp ult i32 %3, %2
br i1 %7, label %8, label %112
8: ; preds = %6
%9 = add i32 %5, -1
%10 = zext i32 %2 to i64
br label %11
11: ; preds = %8, %108
%12 = phi i32 [ 0, %8 ], [ %109, %108 ]
%13 = phi i32 [ %3, %8 ], [ %110, %108 ]
%14 = add nuw i32 %13, 1
%15 = zext i32 %13 to i64
%16 = getelementptr inbounds i8, i8* %1, i64 %15
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp eq i8 %17, 0
br i1 %19, label %112, label %20
20: ; preds = %11
%21 = and i32 %18, 192
%22 = icmp eq i32 %21, 0
%23 = icmp ult i32 %14, %2
br i1 %22, label %24, label %27
24: ; preds = %20
br i1 %23, label %25, label %108
25: ; preds = %24
%26 = zext i32 %14 to i64
br label %30
27: ; preds = %20
br i1 %23, label %112, label %28
28: ; preds = %27
%29 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %112
30: ; preds = %25, %100
%31 = phi i64 [ %26, %25 ], [ %60, %100 ]
%32 = phi i32 [ %12, %25 ], [ %101, %100 ]
%33 = phi i32 [ 0, %25 ], [ %102, %100 ]
%34 = add nuw nsw i64 %31, 1
%35 = getelementptr inbounds i8, i8* %1, i64 %31
%36 = load i8, i8* %35
%37 = add i8 %36, -81
%38 = icmp ult i8 %37, -16
br i1 %38, label %39, label %42
39: ; preds = %30
%40 = sext i8 %36 to i32
%41 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %40)
br label %42
42: ; preds = %30, %39
%43 = icmp ugt i32 %32, %9
br i1 %43, label %44, label %47
44: ; preds = %42
%45 = trunc i64 %34 to i32
%46 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %108
47: ; preds = %42
%48 = shl i8 %36, 4
%49 = add i8 %48, -16
%50 = zext i32 %32 to i64
%51 = getelementptr inbounds i8, i8* %4, i64 %50
store i8 %49, i8* %51
%52 = add i32 %32, 1
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %4, i64 %53
store i8 0, i8* %54
%55 = icmp ult i64 %34, %10
br i1 %55, label %59, label %56
56: ; preds = %47
%57 = trunc i64 %34 to i32
%58 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %108
59: ; preds = %47
%60 = add nuw nsw i64 %31, 2
%61 = getelementptr inbounds i8, i8* %1, i64 %34
%62 = load i8, i8* %61
%63 = add i8 %62, -81
%64 = icmp ult i8 %63, -16
br i1 %64, label %65, label %69
65: ; preds = %59
%66 = sext i8 %62 to i32
%67 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %66, i32 %66)
%68 = load i8, i8* %51
br label %69
69: ; preds = %59, %65
%70 = phi i8 [ %49, %59 ], [ %68, %65 ]
%71 = add i8 %62, 15
%72 = and i8 %71, 15
%73 = or i8 %70, %72
store i8 %73, i8* %51
%74 = tail call i32 @isprint(i8 signext %73)
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %100
76: ; preds = %69
%77 = add i32 %32, 3
%78 = icmp ugt i32 %77, %9
br i1 %78, label %79, label %82
79: ; preds = %76
%80 = trunc i64 %60 to i32
%81 = tail call i32 (%struct.NetFrame*, i8*, ...) @FRAMERR(%struct.NetFrame* %0, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %108
82: ; preds = %76
%83 = load i8, i8* %51
%84 = lshr i8 %83, 4
%85 = zext i8 %84 to i64
%86 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.3, i64 0, i64 %85
%87 = load i8, i8* %86
store i8 %87, i8* %54
%88 = and i8 %83, 15
%89 = zext i8 %88 to i64
%90 = getelementptr inbounds [17 x i8], [17 x i8]* @.str.3, i64 0, i64 %89
%91 = load i8, i8* %90
%92 = add i32 %32, 2
%93 = zext i32 %92 to i64
%94 = getelementptr inbounds i8, i8* %4, i64 %93
store i8 %91, i8* %94
%95 = zext i32 %77 to i64
%96 = getelementptr inbounds i8, i8* %4, i64 %95
store i8 62, i8* %96
%97 = add i32 %32, 4
%98 = zext i32 %97 to i64
%99 = getelementptr inbounds i8, i8* %4, i64 %98
store i8 0, i8* %99
store i8 60, i8* %51
br label %100
100: ; preds = %69, %82
%101 = phi i32 [ %97, %82 ], [ %52, %69 ]
%102 = add nuw nsw i32 %33, 2
%103 = icmp ult i32 %102, %18
%104 = icmp ult i64 %60, %10
%105 = select i1 %103, i1 %104, i1 false
br i1 %105, label %30, label %106
106: ; preds = %100
%107 = trunc i64 %60 to i32
br label %108
108: ; preds = %106, %24, %79, %56, %44
%109 = phi i32 [ %32, %79 ], [ %32, %56 ], [ %32, %44 ], [ %12, %24 ], [ %101, %106 ]
%110 = phi i32 [ %80, %79 ], [ %57, %56 ], [ %45, %44 ], [ %14, %24 ], [ %107, %106 ]
%111 = icmp ult i32 %110, %2
br i1 %111, label %11, label %112
112: ; preds = %108, %11, %6, %27, %28
%113 = phi i32 [ %14, %28 ], [ %14, %27 ], [ %3, %6 ], [ %110, %108 ], [ %14, %11 ]
ret i32 %113
}