#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*/ bootp_print_option(unsigned char const *);
void bootp_print_tlv(const unsigned char *opts) {
  opts += 4;
  while (opts[0] != 255) {
    if (opts[0] == 0) {
      opts++;
    } else {
      bootp_print_option(opts);
      opts += (2 + opts[1]);
    }
  }
}


x86 assembly (clang, -O0):
<bootp_print_tlv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0xff,%eax
je     1182 <bootp_print_tlv+0x72>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    115b <bootp_print_tlv+0x4b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    117d <bootp_print_tlv+0x6d>
mov    -0x8(%rbp),%rdi
call   1030 <bootp_print_option@plt>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%ecx
add    $0x2,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    1128 <bootp_print_tlv+0x18>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bootp_print_tlv>:
push   %rbx
mov    %rdi,%rbx
add    $0x4,%rbx
jmp    1123 <bootp_print_tlv+0x13>
nopw   0x0(%rax,%rax,1)
add    %rax,%rbx
movzbl (%rbx),%ecx
mov    $0x1,%eax
test   %cl,%cl
je     1120 <bootp_print_tlv+0x10>
cmp    $0xff,%cl
je     1146 <bootp_print_tlv+0x36>
mov    %rbx,%rdi
call   1030 <bootp_print_option@plt>
movzbl 0x1(%rbx),%eax
add    $0x2,%rax
jmp    1120 <bootp_print_tlv+0x10>
pop    %rbx
ret

LLVM IR (-O0):
define void @bootp_print_tlv(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 4
store i8* %4, i8** %2
br label %5
5: ; preds = %31, %1
%6 = load i8*, i8** %2
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = icmp ne i32 %9, 255
br i1 %10, label %11, label %32
11: ; preds = %5
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 0
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %2
br label %31
20: ; preds = %11
%21 = load i8*, i8** %2
%22 = call i32 @bootp_print_option(i8* %21)
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = add nsw i32 2, %26
%28 = load i8*, i8** %2
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %2
br label %31
31: ; preds = %20, %17
br label %5
32: ; preds = %5
ret void
}

LLVM IR (-O2):
define void @bootp_print_tlv(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 4
br label %3
3: ; preds = %12, %1
%4 = phi i8* [ %2, %1 ], [ %14, %12 ]
%5 = load i8, i8* %4
switch i8 %5, label %6 [
i8 -1, label %15
i8 0, label %12
]
6: ; preds = %3
%7 = tail call i32 @bootp_print_option(i8* %4)
%8 = getelementptr inbounds i8, i8* %4, i64 1
%9 = load i8, i8* %8
%10 = zext i8 %9 to i64
%11 = add nuw nsw i64 %10, 2
br label %12
12: ; preds = %3, %6
%13 = phi i64 [ %11, %6 ], [ 1, %3 ]
%14 = getelementptr inbounds i8, i8* %4, i64 %13
br label %3
15: ; preds = %3
ret void
}