#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void ses_subenc_nickname_sdg(const unsigned char *resp, int resp_len) {
  int k, el, num_subs;
  unsigned int gen_code;
  const unsigned char *ucp;
  const unsigned char *last_ucp;
  printf("Subenclosure nickname status diagnostic page:\n");
  if (resp_len < 4)
    goto truncated;
  num_subs = resp[1] + 1;
  last_ucp = resp + resp_len - 1;
  printf("  number of secondary subenclosures: %d\n", num_subs - 1);
  gen_code = (resp[4] << 24) | (resp[5] << 16) | (resp[6] << 8) | resp[7];
  printf("  generation code: 0x%x\n", gen_code);
  ucp = resp + 8;
  el = 40;
  for (k = 0; k < num_subs; ++k, ucp += el) {
    if ((ucp + el - 1) > last_ucp)
      goto truncated;
    printf("   subenclosure identifier: %d\n", ucp[1]);
    printf("   nickname status: 0x%x\n", ucp[2]);
    printf("   nickname additional status: 0x%x\n", ucp[3]);
    printf("   nickname language code: %.2s\n", ucp + 6);
    printf("   nickname: %s\n", ucp + 8);
  }
  return;
truncated:
  fprintf(stderr, "    <<<subence str: response too short>>>\n");
  return;
}


x86 assembly (clang, -O0):
<ses_subenc_nickname_sdg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x4,-0xc(%rbp)
jge    114c <ses_subenc_nickname_sdg+0x2c>
jmp    129a <ses_subenc_nickname_sdg+0x17a>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%esi
sub    $0x1,%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
shl    $0x18,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x5(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x6(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
movl   $0x28,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1295 <ses_subenc_nickname_sdg+0x175>
mov    -0x28(%rbp),%rax
movslq -0x14(%rbp),%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
cmp    -0x30(%rbp),%rax
jbe    1208 <ses_subenc_nickname_sdg+0xe8>
jmp    129a <ses_subenc_nickname_sdg+0x17a>
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movzbl 0x2(%rax),%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
movzbl 0x3(%rax),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
add    $0x6,%rsi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
add    $0x8,%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    11de <ses_subenc_nickname_sdg+0xbe>
jmp    12af <ses_subenc_nickname_sdg+0x18f>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ses_subenc_nickname_sdg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xfb6(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%r14d
jge    1176 <ses_subenc_nickname_sdg+0x46>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xf70(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>
movzbl 0x1(%rbx),%ebp
mov    %r14d,%eax
lea    (%rbx,%rax,1),%r15
add    $0xffffffffffffffff,%r15
lea    0xe74(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%esi
bswap  %esi
lea    0xe88(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x2f,%rbx
lea    0xec6(%rip),%r12
lea    0xee4(%rip),%r13
lea    0xefe(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %r15,%rbx
ja     1153 <ses_subenc_nickname_sdg+0x23>
movzbl -0x26(%rbx),%esi
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x25(%rbx),%esi
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl -0x24(%rbx),%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x21(%rbx),%rsi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1f(%rbx),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x28,%rbx
add    $0xffffffff,%ebp
jne    11d0 <ses_subenc_nickname_sdg+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Subenclosure nickname status diagnostic page:\0A\00"
@.str.1 = [41 x i8] c" number of secondary subenclosures: %d\0A\00"
@.str.2 = [25 x i8] c" generation code: 0x%x\0A\00"
@.str.3 = [32 x i8] c" subenclosure identifier: %d\0A\00"
@.str.4 = [26 x i8] c" nickname status: 0x%x\0A\00"
@.str.5 = [37 x i8] c" nickname additional status: 0x%x\0A\00"
@.str.6 = [33 x i8] c" nickname language code: %.2s\0A\00"
@.str.7 = [17 x i8] c" nickname: %s\0A\00"
@stderr = global i32 0
@.str.8 = [43 x i8] c" <<<subence str: response too short>>>\0A\00"
define void @ses_subenc_nickname_sdg(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %15
14: ; preds = %2
br label %98
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
%21 = load i8*, i8** %3
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = getelementptr inbounds i8, i8* %24, i64 -1
store i8* %25, i8** %10
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 4
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = shl i32 %32, 24
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 5
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = shl i32 %37, 16
%39 = or i32 %33, %38
%40 = load i8*, i8** %3
%41 = getelementptr inbounds i8, i8* %40, i64 6
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = shl i32 %43, 8
%45 = or i32 %39, %44
%46 = load i8*, i8** %3
%47 = getelementptr inbounds i8, i8* %46, i64 7
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = or i32 %45, %49
store i32 %50, i32* %8
%51 = load i32, i32* %8
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %51)
%53 = load i8*, i8** %3
%54 = getelementptr inbounds i8, i8* %53, i64 8
store i8* %54, i8** %9
store i32 40, i32* %6
store i32 0, i32* %5
br label %55
55: ; preds = %90, %15
%56 = load i32, i32* %5
%57 = load i32, i32* %7
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %97
59: ; preds = %55
%60 = load i8*, i8** %9
%61 = load i32, i32* %6
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = getelementptr inbounds i8, i8* %63, i64 -1
%65 = load i8*, i8** %10
%66 = icmp ugt i8* %64, %65
br i1 %66, label %67, label %68
67: ; preds = %59
br label %98
68: ; preds = %59
%69 = load i8*, i8** %9
%70 = getelementptr inbounds i8, i8* %69, i64 1
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %72)
%74 = load i8*, i8** %9
%75 = getelementptr inbounds i8, i8* %74, i64 2
%76 = load i8, i8* %75
%77 = zext i8 %76 to i32
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %77)
%79 = load i8*, i8** %9
%80 = getelementptr inbounds i8, i8* %79, i64 3
%81 = load i8, i8* %80
%82 = zext i8 %81 to i32
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %82)
%84 = load i8*, i8** %9
%85 = getelementptr inbounds i8, i8* %84, i64 6
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %85)
%87 = load i8*, i8** %9
%88 = getelementptr inbounds i8, i8* %87, i64 8
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %88)
br label %90
90: ; preds = %68
%91 = load i32, i32* %5
%92 = add nsw i32 %91, 1
store i32 %92, i32* %5
%93 = load i32, i32* %6
%94 = load i8*, i8** %9
%95 = sext i32 %93 to i64
%96 = getelementptr inbounds i8, i8* %94, i64 %95
store i8* %96, i8** %9
br label %55
97: ; preds = %55
br label %101
98: ; preds = %67, %14
%99 = load i32, i32* @stderr
%100 = call i32 @fprintf(i32 %99, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0))
br label %101
101: ; preds = %98, %97
ret void
}

LLVM IR (-O2):
@.str.1 = [41 x i8] c" number of secondary subenclosures: %d\0A\00"
@.str.2 = [25 x i8] c" generation code: 0x%x\0A\00"
@.str.3 = [32 x i8] c" subenclosure identifier: %d\0A\00"
@.str.4 = [26 x i8] c" nickname status: 0x%x\0A\00"
@.str.5 = [37 x i8] c" nickname additional status: 0x%x\0A\00"
@.str.6 = [33 x i8] c" nickname language code: %.2s\0A\00"
@.str.7 = [17 x i8] c" nickname: %s\0A\00"
@stderr = global i32 0
@.str.8 = [43 x i8] c" <<<subence str: response too short>>>\0A\00"
@str = [46 x i8] c"Subenclosure nickname status diagnostic page:\00"
define void @ses_subenc_nickname_sdg(i8* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %1, 4
br i1 %4, label %58, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = zext i32 %1 to i64
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%13 = getelementptr inbounds i8, i8* %0, i64 4
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = shl nuw i32 %15, 24
%17 = getelementptr inbounds i8, i8* %0, i64 5
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = shl nuw nsw i32 %19, 16
%21 = or i32 %20, %16
%22 = getelementptr inbounds i8, i8* %0, i64 6
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = shl nuw nsw i32 %24, 8
%26 = or i32 %21, %25
%27 = getelementptr inbounds i8, i8* %0, i64 7
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %26, %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = getelementptr inbounds i8, i8* %0, i64 8
br label %33
33: ; preds = %5, %38
%34 = phi i32 [ 0, %5 ], [ %56, %38 ]
%35 = phi i8* [ %32, %5 ], [ %39, %38 ]
%36 = getelementptr inbounds i8, i8* %35, i64 39
%37 = icmp ugt i8* %36, %11
br i1 %37, label %58, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %35, i64 40
%40 = getelementptr inbounds i8, i8* %35, i64 1
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %42)
%44 = getelementptr inbounds i8, i8* %35, i64 2
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds i8, i8* %35, i64 3
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %50)
%52 = getelementptr inbounds i8, i8* %35, i64 6
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds i8, i8* %35, i64 8
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %54)
%56 = add nuw nsw i32 %34, 1
%57 = icmp eq i32 %34, %8
br i1 %57, label %61, label %33
58: ; preds = %33, %2
%59 = load i32, i32* @stderr
%60 = tail call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.8, i64 0, i64 0))
br label %61
61: ; preds = %38, %58
ret void
}