#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 -= (int)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 -= (int)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 -= (int)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    12bc <dump_prov_ies+0x17c>
mov    -0x8(%rbp),%rdi
lea    0xedd(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
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    12bc <dump_prov_ies+0x17c>
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    122d <dump_prov_ies+0xed>
lea    -0x130(%rbp),%rdi
mov    -0x20(%rbp),%ecx
add    $0x2,%ecx
mov    -0x1c(%rbp),%r8d
mov    $0x100,%esi
lea    0xe19(%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    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
add    -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    12bc <dump_prov_ies+0x17c>
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1295 <dump_prov_ies+0x155>
lea    -0x130(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    $0x100,%esi
lea    0xdfe(%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    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
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    119c <dump_prov_ies+0x5c>
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 %95
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 = trunc i64 %20 to i32
%22 = load i32, i32* %6
%23 = sub nsw i32 %22, %21
store i32 %23, i32* %6
%24 = load i8*, i8** %5
%25 = call i64 @strlen(i8* %24)
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 %25
store i8* %27, i8** %5
br label %28
28: ; preds = %85, %16
%29 = load i32, i32* %8
%30 = icmp sgt i32 %29, 2
br i1 %30, label %31, label %95
31: ; preds = %28
%32 = load i8*, i8** %7
%33 = getelementptr inbounds i8, i8* %32, i64 0
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
store i32 %35, i32* %10
%36 = load i8*, i8** %7
%37 = getelementptr inbounds i8, i8* %36, i64 1
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
store i32 %39, i32* %9
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 2
%42 = load i32, i32* %8
%43 = icmp sgt i32 %41, %42
br i1 %43, label %44, label %64
44: ; preds = %31
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 2
%48 = load i32, i32* %8
%49 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %45, i32 256, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.1, i64 0, i64 0), i32 %47, i32 %48)
%50 = load i8*, i8** %5
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%52 = load i32, i32* %6
%53 = sub nsw i32 %52, 1
%54 = call i32 @strncpy(i8* %50, i8* %51, i32 %53)
%55 = load i8*, i8** %5
%56 = call i64 @strlen(i8* %55)
%57 = trunc i64 %56 to i32
%58 = load i32, i32* %6
%59 = sub nsw i32 %58, %57
store i32 %59, i32* %6
%60 = load i8*, i8** %5
%61 = call i64 @strlen(i8* %60)
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i64 %61
store i8* %63, i8** %5
br label %95
64: ; preds = %31
store i32 0, i32* %11
%65 = load i32, i32* %11
%66 = icmp ne i32 %65, 0
br i1 %66, label %85, label %67
67: ; preds = %64
%68 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%69 = load i32, i32* %10
%70 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %68, i32 256, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %69)
%71 = load i8*, i8** %5
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%73 = load i32, i32* %6
%74 = sub nsw i32 %73, 1
%75 = call i32 @strncpy(i8* %71, i8* %72, i32 %74)
%76 = load i8*, i8** %5
%77 = call i64 @strlen(i8* %76)
%78 = trunc i64 %77 to i32
%79 = load i32, i32* %6
%80 = sub nsw i32 %79, %78
store i32 %80, i32* %6
%81 = load i8*, i8** %5
%82 = call i64 @strlen(i8* %81)
%83 = load i8*, i8** %5
%84 = getelementptr inbounds i8, i8* %83, i64 %82
store i8* %84, i8** %5
br label %85
85: ; preds = %67, %64
%86 = load i32, i32* %9
%87 = add nsw i32 2, %86
%88 = load i8*, i8** %7
%89 = sext i32 %87 to i64
%90 = getelementptr inbounds i8, i8* %88, i64 %89
store i8* %90, i8** %7
%91 = load i32, i32* %9
%92 = add nsw i32 2, %91
%93 = load i32, i32* %8
%94 = sub nsw i32 %93, %92
store i32 %94, i32* %8
br label %28
95: ; preds = %15, %44, %28
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 nsw 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 nsw 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
}