#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*/ snprintf(char *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char const);
int /*<<< orphan*/ strcpy(char *, char *);
void iw_print_key(char *buffer, int buflen, const unsigned char *key,
                  int key_size, int key_flags) {
  int i;
  if ((key_size * 3) > buflen) {
    snprintf(buffer, buflen, "<too big>");
    return;
  }
  if (key_flags & 0x0800) {
    if (key_size <= 0)
      strcpy(buffer, "on");
    else {
      strcpy(buffer, "**");
      buffer += 2;
      for (i = 1; i < key_size; i++) {
        if ((i & 0x1) == 0)
          strcpy(buffer++, "-");
        strcpy(buffer, "**");
        buffer += 2;
      }
    }
  } else {
    sprintf(buffer, "%.2X", key[0]);
    buffer += 2;
    for (i = 1; i < key_size; i++) {
      if ((i & 0x1) == 0)
        strcpy(buffer++, "-");
      sprintf(buffer, "%.2X", key[i]);
      buffer += 2;
    }
  }
}


x86 assembly (clang, -O0):
<iw_print_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
imul   $0x3,-0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    116f <iw_print_key+0x3f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xe9b(%rip),%rdx
call   1040 <snprintf@plt>
jmp    12c7 <iw_print_key+0x197>
mov    -0x20(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     122c <iw_print_key+0xfc>
cmpl   $0x0,-0x1c(%rbp)
jg     119f <iw_print_key+0x6f>
mov    -0x8(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1227 <iw_print_key+0xf7>
mov    -0x8(%rbp),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1222 <iw_print_key+0xf2>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11f8 <iw_print_key+0xc8>
mov    -0x8(%rbp),%rdi
mov    %rdi,%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    0xe1d(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
lea    0xe0a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c2 <iw_print_key+0x92>
jmp    1227 <iw_print_key+0xf7>
jmp    12c7 <iw_print_key+0x197>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
lea    0xdd7(%rip),%rsi
movzbl (%rax),%edx
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12c2 <iw_print_key+0x192>
mov    -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    128c <iw_print_key+0x15c>
mov    -0x8(%rbp),%rdi
mov    %rdi,%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
lea    0xd89(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
lea    0xd73(%rip),%rsi
movzbl (%rax,%rcx,1),%edx
call   1050 <sprintf@plt>
mov    -0x8(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1256 <iw_print_key+0x126>
jmp    12c7 <iw_print_key+0x197>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_print_key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdi,%rbx
lea    (%r14,%r14,2),%eax
cmp    %esi,%eax
jle    1166 <iw_print_key+0x36>
lea    0xeb0(%rip),%rdx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <snprintf@plt>
test   $0x800,%r8d
jne    11e4 <iw_print_key+0xb4>
mov    %rdx,%r15
movzbl (%rdx),%edx
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
cmp    $0x2,%r14d
jl     11fe <iw_print_key+0xce>
mov    %r14d,%r13d
mov    $0x1,%ebp
lea    0xe77(%rip),%r14
lea    0xe72(%rip),%r12
jmp    11d5 <iw_print_key+0xa5>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x3,%rbx
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
movzbl (%r15,%rbp,1),%edx
mov    %r12,%rsi
call   1050 <sprintf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
je     11fe <iw_print_key+0xce>
lea    0x2(%rbx),%rdi
test   $0x1,%bpl
je     11b0 <iw_print_key+0x80>
mov    %rdi,%rbx
jmp    11bf <iw_print_key+0x8f>
test   %r14d,%r14d
jle    120d <iw_print_key+0xdd>
lea    0xe1d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
cmp    $0x1,%r14d
jne    122a <iw_print_key+0xfa>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <strcpy@plt>
mov    $0x1,%ebp
lea    0xdda(%rip),%r15
lea    0xdd0(%rip),%r12
jmp    125f <iw_print_key+0x12f>
nop
add    $0x3,%rbx
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
je     11fe <iw_print_key+0xce>
lea    0x2(%rbx),%rdi
test   $0x1,%bpl
je     1240 <iw_print_key+0x110>
mov    %rdi,%rbx
jmp    124f <iw_print_key+0x11f>

LLVM IR (-O0):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [3 x i8] c"**\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [5 x i8] c"%.2X\00"
define void @iw_print_key(i8* %0, i32 %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%12 = load i32, i32* %9
%13 = mul nsw i32 %12, 3
%14 = load i32, i32* %7
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @snprintf(i8* %17, i32 %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %91
20: ; preds = %5
%21 = load i32, i32* %10
%22 = and i32 %21, 2048
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %57
24: ; preds = %20
%25 = load i32, i32* %9
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %56
30: ; preds = %24
%31 = load i8*, i8** %6
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%33 = load i8*, i8** %6
%34 = getelementptr inbounds i8, i8* %33, i64 2
store i8* %34, i8** %6
store i32 1, i32* %11
br label %35
35: ; preds = %52, %30
%36 = load i32, i32* %11
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load i32, i32* %11
%41 = and i32 %40, 1
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
%46 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %43, %39
%48 = load i8*, i8** %6
%49 = call i32 @strcpy(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%50 = load i8*, i8** %6
%51 = getelementptr inbounds i8, i8* %50, i64 2
store i8* %51, i8** %6
br label %52
52: ; preds = %47
%53 = load i32, i32* %11
%54 = add nsw i32 %53, 1
store i32 %54, i32* %11
br label %35
55: ; preds = %35
br label %56
56: ; preds = %55, %27
br label %91
57: ; preds = %20
%58 = load i8*, i8** %6
%59 = load i8*, i8** %8
%60 = getelementptr inbounds i8, i8* %59, i64 0
%61 = load i8, i8* %60
%62 = call i32 @sprintf(i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %61)
%63 = load i8*, i8** %6
%64 = getelementptr inbounds i8, i8* %63, i64 2
store i8* %64, i8** %6
store i32 1, i32* %11
br label %65
65: ; preds = %87, %57
%66 = load i32, i32* %11
%67 = load i32, i32* %9
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %90
69: ; preds = %65
%70 = load i32, i32* %11
%71 = and i32 %70, 1
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %77
73: ; preds = %69
%74 = load i8*, i8** %6
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %6
%76 = call i32 @strcpy(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %77
77: ; preds = %73, %69
%78 = load i8*, i8** %6
%79 = load i8*, i8** %8
%80 = load i32, i32* %11
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = load i8, i8* %82
%84 = call i32 @sprintf(i8* %78, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %83)
%85 = load i8*, i8** %6
%86 = getelementptr inbounds i8, i8* %85, i64 2
store i8* %86, i8** %6
br label %87
87: ; preds = %77
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 1
store i32 %89, i32* %11
br label %65
90: ; preds = %65
br label %91
91: ; preds = %16, %90, %56
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [3 x i8] c"on\00"
@.str.2 = [3 x i8] c"**\00"
@.str.3 = [2 x i8] c"-\00"
@.str.4 = [5 x i8] c"%.2X\00"
define void @iw_print_key(i8* %0, i32 %1, i8* nocapture %2, i32 %3, i32 %4) {
%6 = mul nsw i32 %3, 3
%7 = icmp sgt i32 %6, %1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %56
10: ; preds = %5
%11 = and i32 %4, 2048
%12 = icmp eq i32 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %10
%14 = icmp slt i32 %3, 1
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %56
17: ; preds = %13
%18 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %3, 1
br i1 %19, label %56, label %20
20: ; preds = %17, %29
%21 = phi i32 [ %32, %29 ], [ 1, %17 ]
%22 = phi i8* [ %30, %29 ], [ %0, %17 ]
%23 = getelementptr inbounds i8, i8* %22, i64 2
%24 = and i32 %21, 1
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = getelementptr inbounds i8, i8* %22, i64 3
%28 = tail call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %29
29: ; preds = %26, %20
%30 = phi i8* [ %27, %26 ], [ %23, %20 ]
%31 = tail call i32 @strcpy(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%32 = add nuw nsw i32 %21, 1
%33 = icmp eq i32 %32, %3
br i1 %33, label %56, label %20
34: ; preds = %10
%35 = load i8, i8* %2
%36 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %35)
%37 = icmp sgt i32 %3, 1
br i1 %37, label %38, label %56
38: ; preds = %34
%39 = zext i32 %3 to i64
br label %40
40: ; preds = %38, %49
%41 = phi i64 [ 1, %38 ], [ %54, %49 ]
%42 = phi i8* [ %0, %38 ], [ %50, %49 ]
%43 = getelementptr inbounds i8, i8* %42, i64 2
%44 = and i64 %41, 1
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = getelementptr inbounds i8, i8* %42, i64 3
%48 = tail call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %49
49: ; preds = %46, %40
%50 = phi i8* [ %47, %46 ], [ %43, %40 ]
%51 = getelementptr inbounds i8, i8* %2, i64 %41
%52 = load i8, i8* %51
%53 = tail call i32 @sprintf(i8* %50, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8 zeroext %52)
%54 = add nuw nsw i64 %41, 1
%55 = icmp eq i64 %54, %39
br i1 %55, label %56, label %40
56: ; preds = %29, %49, %17, %34, %15, %8
ret void
}