#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*/ val8;
typedef int /*<<< orphan*/ val4;
typedef int /*<<< orphan*/ val2;
typedef int /*<<< orphan*/ val1;
typedef int uint8_t;
typedef int uint64_t;
typedef int uint32_t;
typedef int uint16_t;
typedef int socklen_t;

/* Variables and functions */
int inet6_opt_get_val(void *, int, ...);
int inet6_opt_next(void *, int, int, int *, int *, void **);
int /*<<< orphan*/ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int decode_inet6_opt(void *eb, socklen_t el) {
  int ret = 0;
  int seq = 0;
  int cl = 0;
  int offset;
  uint8_t type;
  socklen_t len;
  uint8_t val1;
  uint16_t val2;
  uint32_t val4;
  uint64_t val8;
  void *db;
  char buf[8];
  while ((cl = inet6_opt_next(eb, el, cl, &type, &len, &db)) != -1)
    switch (type) {
    case 42:
      if (seq++ != 0) {
        puts("OPT_X is not first");
        ret = 1;
      }
      if (len != 12) {
        printf("OPT_X's length %d != 12\n", len);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, 0, &val4, sizeof(val4));
      if (val4 != 0x12345678) {
        printf("OPT_X's val4 %x != 0x12345678\n", val4);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, offset, &val8, sizeof(val8));
      if (offset != len || val8 != 0x0102030405060708LL) {
        printf("OPT_X's val8 %llx != 0x0102030405060708\n", (long long)val8);
        ret = 1;
      }
      break;
    case 43:
      if (seq++ != 1) {
        puts("OPT_Y is not second");
        ret = 1;
      }
      if (len != 7) {
        printf("OPT_Y's length %d != 7\n", len);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, 0, &val1, sizeof(val1));
      if (val1 != 0x01) {
        printf("OPT_Y's val1 %x != 0x01\n", val1);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, offset, &val2, sizeof(val2));
      if (val2 != 0x1331) {
        printf("OPT_Y's val2 %x != 0x1331\n", val2);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, offset, &val4, sizeof(val4));
      if (offset != len || val4 != 0x01020304) {
        printf("OPT_Y's val4 %x != 0x01020304\n", val4);
        ret = 1;
      }
      break;
    case 44:
      if (seq++ != 2) {
        puts("OPT_Z is not third");
        ret = 1;
      }
      if (len != 7) {
        printf("OPT_Z's length %d != 7\n", len);
        ret = 1;
      }
      offset = inet6_opt_get_val(db, 0, buf, 7);
      if (offset != len || memcmp(buf, "abcdefg", 7) != 0) {
        buf[7] = '\0';
        printf("OPT_Z's buf \"%s\" != \"abcdefg\"\n", buf);
        ret = 1;
      }
      break;
    default:
      printf("Unknown option %d\n", type);
      ret = 1;
      break;
    }
  if (seq != 3) {
    puts("Didn't see all of OPT_X, OPT_Y and OPT_Z");
    ret = 1;
  }
  return ret;
}


x86 assembly (clang, -O0):
<decode_inet6_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    -0x20(%rbp),%rcx
lea    -0x24(%rbp),%r8
lea    -0x40(%rbp),%r9
call   1070 <inet6_opt_next@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1491 <decode_inet6_opt+0x341>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4c(%rbp)
sub    $0x2a,%eax
je     11d1 <decode_inet6_opt+0x81>
jmp    11af <decode_inet6_opt+0x5f>
mov    -0x4c(%rbp),%eax
sub    $0x2b,%eax
je     12b3 <decode_inet6_opt+0x163>
jmp    11c0 <decode_inet6_opt+0x70>
mov    -0x4c(%rbp),%eax
sub    $0x2c,%eax
je     13c6 <decode_inet6_opt+0x276>
jmp    1474 <decode_inet6_opt+0x324>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     11f8 <decode_inet6_opt+0xa8>
lea    0xe14(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0xc,-0x24(%rbp)
je     121a <decode_inet6_opt+0xca>
mov    -0x24(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
lea    -0x30(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x12345678,-0x30(%rbp)
je     1258 <decode_inet6_opt+0x108>
mov    -0x30(%rbp),%esi
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x34(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1295 <decode_inet6_opt+0x145>
movslq -0x34(%rbp),%rax
movabs $0x102030405060708,%rcx
03 02 01
cmp    %rcx,%rax
je     12ae <decode_inet6_opt+0x15e>
movslq -0x34(%rbp),%rsi
lea    0xdab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    148c <decode_inet6_opt+0x33c>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x1,%eax
je     12da <decode_inet6_opt+0x18a>
lea    0xda6(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x7,-0x24(%rbp)
je     12fc <decode_inet6_opt+0x1ac>
mov    -0x24(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
lea    -0x28(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     1337 <decode_inet6_opt+0x1e7>
mov    -0x28(%rbp),%esi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x2c(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1331,-0x2c(%rbp)
je     1376 <decode_inet6_opt+0x226>
mov    -0x2c(%rbp),%esi
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x1c(%rbp),%esi
lea    -0x30(%rbp),%rdx
mov    $0x4,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    13a9 <decode_inet6_opt+0x259>
cmpl   $0x1020304,-0x30(%rbp)
je     13c1 <decode_inet6_opt+0x271>
mov    -0x30(%rbp),%esi
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    148c <decode_inet6_opt+0x33c>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x2,%eax
je     13ed <decode_inet6_opt+0x29d>
lea    0xd12(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x7,-0x24(%rbp)
je     140f <decode_inet6_opt+0x2bf>
mov    -0x24(%rbp),%esi
lea    0xd05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x48(%rbp),%rdx
xor    %esi,%esi
mov    $0x7,%ecx
mov    $0x0,%al
call   1030 <inet6_opt_get_val@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1452 <decode_inet6_opt+0x302>
lea    -0x48(%rbp),%rdi
lea    0xcdf(%rip),%rsi
mov    $0x7,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%eax
je     146f <decode_inet6_opt+0x31f>
movb   $0x0,-0x41(%rbp)
lea    -0x48(%rbp),%rsi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    148c <decode_inet6_opt+0x33c>
mov    -0x20(%rbp),%esi
lea    0xcc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1174 <decode_inet6_opt+0x24>
cmpl   $0x3,-0x14(%rbp)
je     14ae <decode_inet6_opt+0x35e>
lea    0xcb6(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_inet6_opt>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %esi,%r13d
mov    %rdi,%r14
lea    0x18(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0x8(%rsp),%r9
xor    %edx,%edx
call   1070 <inet6_opt_next@plt>
cmp    $0xffffffff,%eax
je     143f <decode_inet6_opt+0x2ef>
mov    %eax,%ebp
lea    0x28(%rsp),%rbx
xor    %r15d,%r15d
xor    %r12d,%r12d
mov    %r14,0x30(%rsp)
jmp    1201 <decode_inet6_opt+0xb1>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
mov    0x8(%rsp),%rdi
mov    $0x4,%ecx
mov    %ebx,%esi
lea    0x1c(%rsp),%rdx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
movslq 0x1c(%rsp),%rsi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
lea    0x28(%rsp),%rbx
mov    %r14,%rdi
mov    %r13d,%esi
mov    %ebp,%edx
lea    0x18(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0x8(%rsp),%r9
call   1070 <inet6_opt_next@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
je     1439 <decode_inet6_opt+0x2e9>
mov    0x18(%rsp),%esi
cmp    $0x2c,%esi
je     1390 <decode_inet6_opt+0x240>
cmp    $0x2b,%esi
je     1290 <decode_inet6_opt+0x140>
cmp    $0x2a,%esi
jne    1420 <decode_inet6_opt+0x2d0>
test   %r15d,%r15d
je     122d <decode_inet6_opt+0xdd>
lea    0xdd8(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rsp),%esi
cmp    $0xc,%esi
je     1244 <decode_inet6_opt+0xf4>
lea    0xdd6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
mov    $0x4,%ecx
xor    %esi,%esi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
mov    %eax,%ebx
mov    0x14(%rsp),%esi
cmp    $0x12345678,%esi
je     11a0 <decode_inet6_opt+0x50>
lea    0xdb7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a0 <decode_inet6_opt+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x1,%r15d
je     12a8 <decode_inet6_opt+0x158>
lea    0xdd7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r12d
mov    0x4(%rsp),%esi
cmp    $0x7,%esi
je     12c5 <decode_inet6_opt+0x175>
lea    0xdd0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
mov    %r13d,%r14d
mov    0x8(%rsp),%rdi
mov    $0x4,%ecx
xor    %esi,%esi
lea    0x24(%rsp),%rdx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
mov    %eax,%ebx
mov    0x24(%rsp),%esi
cmp    $0x1,%esi
je     12ff <decode_inet6_opt+0x1af>
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
mov    0x8(%rsp),%rdi
mov    $0x4,%ecx
mov    %ebx,%esi
lea    0x20(%rsp),%rdx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
mov    %eax,%r13d
mov    0x20(%rsp),%esi
cmp    $0x1331,%esi
je     133a <decode_inet6_opt+0x1ea>
lea    0xd8c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
add    $0x1,%r15d
mov    0x8(%rsp),%rdi
mov    $0x4,%ecx
mov    %r13d,%esi
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
mov    0x14(%rsp),%esi
cmp    0x4(%rsp),%eax
lea    0x28(%rsp),%rbx
jne    136e <decode_inet6_opt+0x21e>
cmp    $0x1020304,%esi
je     1382 <decode_inet6_opt+0x232>
lea    0xd5f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
mov    %r14d,%r13d
mov    0x30(%rsp),%r14
jmp    11da <decode_inet6_opt+0x8a>
nop
cmp    $0x2,%r15d
je     13a8 <decode_inet6_opt+0x258>
lea    0xd56(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r12d
mov    0x4(%rsp),%esi
cmp    $0x7,%esi
je     13c5 <decode_inet6_opt+0x275>
lea    0xd4e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
add    $0x1,%r15d
mov    0x8(%rsp),%rdi
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x7,%ecx
xor    %eax,%eax
call   1030 <inet6_opt_get_val@plt>
cmp    0x4(%rsp),%eax
jne    1401 <decode_inet6_opt+0x2b1>
mov    %rbx,%rdi
lea    0xd2f(%rip),%rsi
mov    $0x7,%edx
call   1060 <memcmp@plt>
test   %eax,%eax
je     11da <decode_inet6_opt+0x8a>
movb   $0x0,0x2f(%rsp)
lea    0xd19(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    142e <decode_inet6_opt+0x2de>
nopl   0x0(%rax)
lea    0xd1e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%r12d
jmp    11da <decode_inet6_opt+0x8a>
cmp    $0x3,%r15d
je     1451 <decode_inet6_opt+0x301>
lea    0xd12(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"OPT_X is not first\00"
@.str.1 = [25 x i8] c"OPT_X's length %d != 12\0A\00"
@.str.2 = [31 x i8] c"OPT_X's val4 %x != 0x12345678\0A\00"
@.str.3 = [41 x i8] c"OPT_X's val8 %llx != 0x0102030405060708\0A\00"
@.str.4 = [20 x i8] c"OPT_Y is not second\00"
@.str.5 = [24 x i8] c"OPT_Y's length %d != 7\0A\00"
@.str.6 = [25 x i8] c"OPT_Y's val1 %x != 0x01\0A\00"
@.str.7 = [27 x i8] c"OPT_Y's val2 %x != 0x1331\0A\00"
@.str.8 = [31 x i8] c"OPT_Y's val4 %x != 0x01020304\0A\00"
@.str.9 = [19 x i8] c"OPT_Z is not third\00"
@.str.10 = [24 x i8] c"OPT_Z's length %d != 7\0A\00"
@.str.11 = [8 x i8] c"abcdefg\00"
@.str.12 = [31 x i8] c"OPT_Z's buf \22%s\22 != \22abcdefg\22\0A\00"
@.str.13 = [19 x i8] c"Unknown option %d\0A\00"
@.str.14 = [41 x i8] c"Didn't see all of OPT_X, OPT_Y and OPT_Z\00"
define i32 @decode_inet6_opt(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca [8 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
br label %17
17: ; preds = %135, %2
%18 = load i8*, i8** %3
%19 = load i32, i32* %4
%20 = load i32, i32* %7
%21 = call i32 @inet6_opt_next(i8* %18, i32 %19, i32 %20, i32* %9, i32* %10, i8** %15)
store i32 %21, i32* %7
%22 = icmp ne i32 %21, -1
br i1 %22, label %23, label %136
23: ; preds = %17
%24 = load i32, i32* %9
switch i32 %24, label %132 [
i32 42, label %25
i32 43, label %61
i32 44, label %104
]
25: ; preds = %23
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
%28 = icmp ne i32 %26, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %31
31: ; preds = %29, %25
%32 = load i32, i32* %10
%33 = icmp ne i32 %32, 12
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i32, i32* %10
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %35)
store i32 1, i32* %5
br label %37
37: ; preds = %34, %31
%38 = load i8*, i8** %15
%39 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %38, i32 0, i32* %13, i64 4)
store i32 %39, i32* %8
%40 = load i32, i32* %13
%41 = icmp ne i32 %40, 305419896
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* %13
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %43)
store i32 1, i32* %5
br label %45
45: ; preds = %42, %37
%46 = load i8*, i8** %15
%47 = load i32, i32* %8
%48 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %46, i32 %47, i32* %14, i64 4)
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = load i32, i32* %10
%51 = icmp ne i32 %49, %50
br i1 %51, label %56, label %52
52: ; preds = %45
%53 = load i32, i32* %14
%54 = sext i32 %53 to i64
%55 = icmp ne i64 %54, 72623859790382856
br i1 %55, label %56, label %60
56: ; preds = %52, %45
%57 = load i32, i32* %14
%58 = sext i32 %57 to i64
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i64 %58)
store i32 1, i32* %5
br label %60
60: ; preds = %56, %52
br label %135
61: ; preds = %23
%62 = load i32, i32* %6
%63 = add nsw i32 %62, 1
store i32 %63, i32* %6
%64 = icmp ne i32 %62, 1
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %5
br label %67
67: ; preds = %65, %61
%68 = load i32, i32* %10
%69 = icmp ne i32 %68, 7
br i1 %69, label %70, label %73
70: ; preds = %67
%71 = load i32, i32* %10
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %71)
store i32 1, i32* %5
br label %73
73: ; preds = %70, %67
%74 = load i8*, i8** %15
%75 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %74, i32 0, i32* %11, i64 4)
store i32 %75, i32* %8
%76 = load i32, i32* %11
%77 = icmp ne i32 %76, 1
br i1 %77, label %78, label %81
78: ; preds = %73
%79 = load i32, i32* %11
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %79)
store i32 1, i32* %5
br label %81
81: ; preds = %78, %73
%82 = load i8*, i8** %15
%83 = load i32, i32* %8
%84 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %82, i32 %83, i32* %12, i64 4)
store i32 %84, i32* %8
%85 = load i32, i32* %12
%86 = icmp ne i32 %85, 4913
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = load i32, i32* %12
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %88)
store i32 1, i32* %5
br label %90
90: ; preds = %87, %81
%91 = load i8*, i8** %15
%92 = load i32, i32* %8
%93 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %91, i32 %92, i32* %13, i64 4)
store i32 %93, i32* %8
%94 = load i32, i32* %8
%95 = load i32, i32* %10
%96 = icmp ne i32 %94, %95
br i1 %96, label %100, label %97
97: ; preds = %90
%98 = load i32, i32* %13
%99 = icmp ne i32 %98, 16909060
br i1 %99, label %100, label %103
100: ; preds = %97, %90
%101 = load i32, i32* %13
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %101)
store i32 1, i32* %5
br label %103
103: ; preds = %100, %97
br label %135
104: ; preds = %23
%105 = load i32, i32* %6
%106 = add nsw i32 %105, 1
store i32 %106, i32* %6
%107 = icmp ne i32 %105, 2
br i1 %107, label %108, label %110
108: ; preds = %104
%109 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %5
br label %110
110: ; preds = %108, %104
%111 = load i32, i32* %10
%112 = icmp ne i32 %111, 7
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32, i32* %10
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %114)
store i32 1, i32* %5
br label %116
116: ; preds = %113, %110
%117 = load i8*, i8** %15
%118 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%119 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %117, i32 0, i8* %118, i32 7)
store i32 %119, i32* %8
%120 = load i32, i32* %8
%121 = load i32, i32* %10
%122 = icmp ne i32 %120, %121
br i1 %122, label %127, label %123
123: ; preds = %116
%124 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%125 = call i32 @memcmp(i8* %124, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 7)
%126 = icmp ne i32 %125, 0
br i1 %126, label %127, label %131
127: ; preds = %123, %116
%128 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 7
store i8 0, i8* %128
%129 = getelementptr inbounds [8 x i8], [8 x i8]* %16, i64 0, i64 0
%130 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %129)
store i32 1, i32* %5
br label %131
131: ; preds = %127, %123
br label %135
132: ; preds = %23
%133 = load i32, i32* %9
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %133)
store i32 1, i32* %5
br label %135
135: ; preds = %132, %131, %103, %60
br label %17
136: ; preds = %17
%137 = load i32, i32* %6
%138 = icmp ne i32 %137, 3
br i1 %138, label %139, label %141
139: ; preds = %136
%140 = call i32 @puts(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %5
br label %141
141: ; preds = %139, %136
%142 = load i32, i32* %5
ret i32 %142
}

LLVM IR (-O2):
@.str = [19 x i8] c"OPT_X is not first\00"
@.str.1 = [25 x i8] c"OPT_X's length %d != 12\0A\00"
@.str.2 = [31 x i8] c"OPT_X's val4 %x != 0x12345678\0A\00"
@.str.3 = [41 x i8] c"OPT_X's val8 %llx != 0x0102030405060708\0A\00"
@.str.4 = [20 x i8] c"OPT_Y is not second\00"
@.str.5 = [24 x i8] c"OPT_Y's length %d != 7\0A\00"
@.str.6 = [25 x i8] c"OPT_Y's val1 %x != 0x01\0A\00"
@.str.7 = [27 x i8] c"OPT_Y's val2 %x != 0x1331\0A\00"
@.str.8 = [31 x i8] c"OPT_Y's val4 %x != 0x01020304\0A\00"
@.str.9 = [19 x i8] c"OPT_Z is not third\00"
@.str.10 = [24 x i8] c"OPT_Z's length %d != 7\0A\00"
@.str.11 = [8 x i8] c"abcdefg\00"
@.str.12 = [31 x i8] c"OPT_Z's buf \22%s\22 != \22abcdefg\22\0A\00"
@.str.13 = [19 x i8] c"Unknown option %d\0A\00"
@.str.14 = [41 x i8] c"Didn't see all of OPT_X, OPT_Y and OPT_Z\00"
define i32 @decode_inet6_opt(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca [8 x i8]
%11 = bitcast i32* %3 to i8*
%12 = bitcast i32* %4 to i8*
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i8** %9 to i8*
%18 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 0
%19 = call i32 @inet6_opt_next(i8* %0, i32 %1, i32 0, i32* %3, i32* %4, i8** %9)
%20 = icmp eq i32 %19, -1
br i1 %20, label %120, label %21
21: ; preds = %2
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %10, i64 0, i64 7
br label %23
23: ; preds = %21, %113
%24 = phi i32 [ %19, %21 ], [ %116, %113 ]
%25 = phi i32 [ 0, %21 ], [ %115, %113 ]
%26 = phi i32 [ 0, %21 ], [ %114, %113 ]
%27 = load i32, i32* %3
switch i32 %27, label %111 [
i32 42, label %28
i32 43, label %51
i32 44, label %89
]
28: ; preds = %23
%29 = add nsw i32 %25, 1
%30 = icmp eq i32 %25, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %28
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 12
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %34)
br label %38
38: ; preds = %36, %33
%39 = load i8*, i8** %9
%40 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %39, i32 0, i32* %7, i64 4)
%41 = load i32, i32* %7
%42 = icmp eq i32 %41, 305419896
br i1 %42, label %45, label %43
43: ; preds = %38
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %45
45: ; preds = %43, %38
%46 = load i8*, i8** %9
%47 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %46, i32 %40, i32* %8, i64 4)
%48 = load i32, i32* %8
%49 = sext i32 %48 to i64
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i64 %49)
br label %113
51: ; preds = %23
%52 = add nsw i32 %25, 1
%53 = icmp eq i32 %25, 1
br i1 %53, label %56, label %54
54: ; preds = %51
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
%57 = phi i32 [ 1, %54 ], [ %26, %51 ]
%58 = load i32, i32* %4
%59 = icmp eq i32 %58, 7
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %58)
br label %62
62: ; preds = %60, %56
%63 = phi i32 [ 1, %60 ], [ %57, %56 ]
%64 = load i8*, i8** %9
%65 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %64, i32 0, i32* %5, i64 4)
%66 = load i32, i32* %5
%67 = icmp eq i32 %66, 1
br i1 %67, label %70, label %68
68: ; preds = %62
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i32 %66)
br label %70
70: ; preds = %68, %62
%71 = phi i32 [ 1, %68 ], [ %63, %62 ]
%72 = load i8*, i8** %9
%73 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %72, i32 %65, i32* %6, i64 4)
%74 = load i32, i32* %6
%75 = icmp eq i32 %74, 4913
br i1 %75, label %78, label %76
76: ; preds = %70
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %74)
br label %78
78: ; preds = %76, %70
%79 = phi i32 [ 1, %76 ], [ %71, %70 ]
%80 = load i8*, i8** %9
%81 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %80, i32 %73, i32* %7, i64 4)
%82 = load i32, i32* %4
%83 = icmp ne i32 %81, %82
%84 = load i32, i32* %7
%85 = icmp ne i32 %84, 16909060
%86 = select i1 %83, i1 true, i1 %85
br i1 %86, label %87, label %113
87: ; preds = %78
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %84)
br label %113
89: ; preds = %23
%90 = add nsw i32 %25, 1
%91 = icmp eq i32 %25, 2
br i1 %91, label %94, label %92
92: ; preds = %89
%93 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %94
94: ; preds = %92, %89
%95 = phi i32 [ 1, %92 ], [ %26, %89 ]
%96 = load i32, i32* %4
%97 = icmp eq i32 %96, 7
br i1 %97, label %100, label %98
98: ; preds = %94
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i32 %96)
br label %100
100: ; preds = %98, %94
%101 = phi i32 [ 1, %98 ], [ %95, %94 ]
%102 = load i8*, i8** %9
%103 = call i32 (i8*, i32, ...) @inet6_opt_get_val(i8* %102, i32 0, i8* %18, i32 7)
%104 = load i32, i32* %4
%105 = icmp eq i32 %103, %104
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = call i32 @memcmp(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0), i32 7)
%108 = icmp eq i32 %107, 0
br i1 %108, label %113, label %109
109: ; preds = %106, %100
store i8 0, i8* %22
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.12, i64 0, i64 0), i8* %18)
br label %113
111: ; preds = %23
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %27)
br label %113
113: ; preds = %106, %109, %87, %78, %45, %111
%114 = phi i32 [ 1, %111 ], [ 1, %109 ], [ %101, %106 ], [ 1, %87 ], [ %79, %78 ], [ 1, %45 ]
%115 = phi i32 [ %25, %111 ], [ %90, %109 ], [ %90, %106 ], [ %52, %87 ], [ %52, %78 ], [ %29, %45 ]
%116 = call i32 @inet6_opt_next(i8* %0, i32 %1, i32 %24, i32* %3, i32* %4, i8** %9)
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %23
118: ; preds = %113
%119 = icmp eq i32 %115, 3
br i1 %119, label %122, label %120
120: ; preds = %2, %118
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.14, i64 0, i64 0))
br label %122
122: ; preds = %120, %118
%123 = phi i32 [ 1, %120 ], [ %114, %118 ]
ret i32 %123
}