#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*/ tmp;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void dump_prov_ies(char *output, int maxlen, unsigned char *iedata, int len) {
  int ielen;
  int ie;
  int found;
  char tmp[256];
  if (len < 2)
    return;
  strcpy(output, "\n");
  maxlen -= strlen(output);
  output += strlen(output);
  while (len > 2) {
    ie = iedata[0];
    ielen = iedata[1];
    if (ielen + 2 > len) {
      snprintf(tmp, (int)sizeof(tmp),
               "Total Prov IE length of %d bytes exceeds remaining prov frame "
               "length of %d bytes\n",
               ielen + 2, len);
      strncpy(output, tmp, maxlen - 1);
      maxlen -= strlen(output);
      output += strlen(output);
      return;
    }
    found = 0;
    if (!found) {
      snprintf(tmp, (int)sizeof(tmp),
               "       Unknown Prov IE %03d  : Present\n", ie);
      strncpy(output, tmp, maxlen - 1);
      maxlen -= strlen(output);
      output += strlen(output);
    }
    iedata += (2 + ielen);
    len -= (2 + ielen);
  }
}


x86 assembly (clang, -O0):
<dump_prov_ies>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1168 <dump_prov_ies+0x28>
jmp    12c5 <dump_prov_ies+0x185>
mov    -0x8(%rbp),%rdi
lea    0xedd(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jle    12c5 <dump_prov_ies+0x185>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x2,%eax
cmp    -0x1c(%rbp),%eax
jle    1233 <dump_prov_ies+0xf3>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x100,%esi
lea    0xe16(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12c5 <dump_prov_ies+0x185>
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    129e <dump_prov_ies+0x15e>
lea    -0x130(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    $0x100,%esi
lea    0xdf8(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x130(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
movslq -0xc(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
jmp    119f <dump_prov_ies+0x5f>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_prov_ies>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
cmp    $0x2,%ecx
jl     1215 <dump_prov_ies+0xd5>
mov    %ecx,%r13d
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%r15
lea    0xee3(%rip),%rsi
call   1040 <strcpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    $0x2,%r13d
je     1215 <dump_prov_ies+0xd5>
add    %rax,%r15
sub    %eax,%r14d
mov    %r13d,%ebp
nopl   (%rax)
movzbl 0x1(%rbx),%r12d
add    $0x2,%r12
sub    %r12d,%ebp
jb     11e4 <dump_prov_ies+0xa4>
movzbl (%rbx),%ecx
mov    %rsp,%r13
mov    %r13,%rdi
mov    $0x100,%esi
lea    0xe9f(%rip),%rdx
xor    %eax,%eax
call   1060 <snprintf@plt>
lea    -0x1(%r14),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strncpy@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
add    %rax,%r15
sub    %eax,%r14d
add    %r12,%rbx
mov    %ebp,%r13d
cmp    $0x2,%ebp
jg     1190 <dump_prov_ies+0x50>
jmp    1215 <dump_prov_ies+0xd5>
lea    0xe15(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r12d,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1060 <snprintf@plt>
add    $0xffffffff,%r14d
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1030 <strncpy@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [82 x i8] c"Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\0A\00"
@.str.2 = [40 x i8] c" Unknown Prov IE %03d : Present\0A\00"
define void @dump_prov_ies(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [256 x i8]
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %16
15: ; preds = %4
br label %98
16: ; preds = %4
%17 = load i8*, i8** %5
%18 = call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %5
%20 = call i64 @strlen(i8* %19)
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = sub nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %6
%25 = load i8*, i8** %5
%26 = call i64 @strlen(i8* %25)
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 %26
store i8* %28, i8** %5
br label %29
29: ; preds = %88, %16
%30 = load i32, i32* %8
%31 = icmp sgt i32 %30, 2
br i1 %31, label %32, label %98
32: ; preds = %29
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
store i32 %36, i32* %10
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = add nsw i32 %41, 2
%43 = load i32, i32* %8
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %66
45: ; preds = %32
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 2
%49 = load i32, i32* %8
%50 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %46, i32 256, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %48, i32 %49)
%51 = load i8*, i8** %5
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%53 = load i32, i32* %6
%54 = sub nsw i32 %53, 1
%55 = call i32 @strncpy(i8* %51, i8* %52, i32 %54)
%56 = load i8*, i8** %5
%57 = call i64 @strlen(i8* %56)
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = sub nsw i64 %59, %57
%61 = trunc i64 %60 to i32
store i32 %61, i32* %6
%62 = load i8*, i8** %5
%63 = call i64 @strlen(i8* %62)
%64 = load i8*, i8** %5
%65 = getelementptr inbounds i8, i8* %64, i64 %63
store i8* %65, i8** %5
br label %98
66: ; preds = %32
store i32 0, i32* %11
%67 = load i32, i32* %11
%68 = icmp ne i32 %67, 0
br i1 %68, label %88, label %69
69: ; preds = %66
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%71 = load i32, i32* %10
%72 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %70, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%73 = load i8*, i8** %5
%74 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%75 = load i32, i32* %6
%76 = sub nsw i32 %75, 1
%77 = call i32 @strncpy(i8* %73, i8* %74, i32 %76)
%78 = load i8*, i8** %5
%79 = call i64 @strlen(i8* %78)
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = sub nsw i64 %81, %79
%83 = trunc i64 %82 to i32
store i32 %83, i32* %6
%84 = load i8*, i8** %5
%85 = call i64 @strlen(i8* %84)
%86 = load i8*, i8** %5
%87 = getelementptr inbounds i8, i8* %86, i64 %85
store i8* %87, i8** %5
br label %88
88: ; preds = %69, %66
%89 = load i32, i32* %9
%90 = add nsw i32 2, %89
%91 = load i8*, i8** %7
%92 = sext i32 %90 to i64
%93 = getelementptr inbounds i8, i8* %91, i64 %92
store i8* %93, i8** %7
%94 = load i32, i32* %9
%95 = add nsw i32 2, %94
%96 = load i32, i32* %8
%97 = sub nsw i32 %96, %95
store i32 %97, i32* %8
br label %29
98: ; preds = %15, %45, %29
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [82 x i8] c"Total Prov IE length of %d bytes exceeds remaining prov frame length of %d bytes\0A\00"
@.str.2 = [40 x i8] c" Unknown Prov IE %03d : Present\0A\00"
define void @dump_prov_ies(i8* %0, i32 %1, i8* nocapture %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%7 = icmp slt i32 %3, 2
br i1 %7, label %44, label %8
8: ; preds = %4
%9 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%11 = icmp eq i32 %3, 2
br i1 %11, label %44, label %12
12: ; preds = %8
%13 = getelementptr inbounds i8, i8* %0, i64 %10
%14 = trunc i64 %10 to i32
%15 = sub i32 %1, %14
br label %16
16: ; preds = %12, %30
%17 = phi i8* [ %37, %30 ], [ %13, %12 ]
%18 = phi i32 [ %39, %30 ], [ %15, %12 ]
%19 = phi i8* [ %41, %30 ], [ %2, %12 ]
%20 = phi i32 [ %42, %30 ], [ %3, %12 ]
%21 = getelementptr inbounds i8, i8* %19, i64 1
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = add nuw nsw i32 %23, 2
%25 = icmp ult i32 %20, %24
br i1 %25, label %26, label %30
26: ; preds = %16
%27 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %20)
%28 = add nsw i32 %18, -1
%29 = call i32 @strncpy(i8* %17, i8* %6, i32 %28)
br label %44
30: ; preds = %16
%31 = load i8, i8* %19
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %6, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = add nsw i32 %18, -1
%35 = call i32 @strncpy(i8* %17, i8* %6, i32 %34)
%36 = call i64 @strlen(i8* dereferenceable(1) %17)
%37 = getelementptr inbounds i8, i8* %17, i64 %36
%38 = trunc i64 %36 to i32
%39 = sub i32 %18, %38
%40 = zext i32 %24 to i64
%41 = getelementptr inbounds i8, i8* %19, i64 %40
%42 = sub nsw i32 %20, %24
%43 = icmp sgt i32 %42, 2
br i1 %43, label %16, label %44
44: ; preds = %30, %8, %4, %26
ret void
}