#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*/ dStrHex(char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void ses_subenc_string_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 string in 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;
  for (k = 0; k < num_subs; ++k, ucp += el) {
    if ((ucp + 3) > last_ucp)
      goto truncated;
    el = (ucp[2] << 8) + ucp[3] + 4;
    printf("   subenclosure identifier: %d\n", ucp[1]);
    if (el > 4)
      dStrHex((const char *)(ucp + 4), el - 4, 0);
    else
      printf("    <empty>\n");
  }
  return;
truncated:
  fprintf(stderr, "    <<<subence str: response too short>>>\n");
  return;
}


x86 assembly (clang, -O0):
<ses_subenc_string_sdg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x4,-0xc(%rbp)
jge    115c <ses_subenc_string_sdg+0x2c>
jmp    1296 <ses_subenc_string_sdg+0x166>
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    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <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    0xe85(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1291 <ses_subenc_string_sdg+0x161>
mov    -0x28(%rbp),%rax
add    $0x3,%rax
cmp    -0x30(%rbp),%rax
jbe    120a <ses_subenc_string_sdg+0xda>
jmp    1296 <ses_subenc_string_sdg+0x166>
mov    -0x28(%rbp),%rax
movzbl 0x2(%rax),%eax
shl    $0x8,%eax
mov    -0x28(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
add    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x4,-0x14(%rbp)
jle    125f <ses_subenc_string_sdg+0x12f>
mov    -0x28(%rbp),%rdi
add    $0x4,%rdi
mov    -0x14(%rbp),%esi
sub    $0x4,%esi
xor    %edx,%edx
call   1030 <dStrHex@plt>
jmp    126d <ses_subenc_string_sdg+0x13d>
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1272 <ses_subenc_string_sdg+0x142>
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    11e7 <ses_subenc_string_sdg+0xb7>
jmp    12ab <ses_subenc_string_sdg+0x17b>
mov    0x2d43(%rip),%rax
mov    (%rax),%edi
lea    0xdf2(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ses_subenc_string_sdg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%ebp
jge    1184 <ses_subenc_string_sdg+0x44>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xef1(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <fprintf@plt>
movzbl 0x1(%rbx),%r12d
mov    %ebp,%eax
lea    (%rbx,%rax,1),%r13
add    $0xffffffffffffffff,%r13
lea    0xe66(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
bswap  %esi
lea    0xe79(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x8,%rbx
add    $0x1,%r12d
lea    0xe7c(%rip),%r14
jmp    11e5 <ses_subenc_string_sdg+0xa5>
nopl   0x0(%rax,%rax,1)
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
add    %r15,%rbx
add    $0xffffffff,%r12d
je     1223 <ses_subenc_string_sdg+0xe3>
lea    0x3(%rbx),%rax
cmp    %r13,%rax
ja     1161 <ses_subenc_string_sdg+0x21>
movzwl 0x2(%rbx),%ebp
shl    $0x30,%rbp
bswap  %rbp
lea    0x4(%rbp),%r15
movzbl 0x1(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
test   %rbp,%rbp
je     11d0 <ses_subenc_string_sdg+0x90>
lea    0x4(%rbx),%rdi
mov    %ebp,%esi
xor    %edx,%edx
call   1040 <dStrHex@plt>
jmp    11dc <ses_subenc_string_sdg+0x9c>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"Subenclosure string in 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 = [13 x i8] c" <empty>\0A\00"
@stderr = global i32 0
@.str.5 = [43 x i8] c" <<<subence str: response too short>>>\0A\00"
define void @ses_subenc_string_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 ([41 x i8], [41 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 %101
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 0, i32* %5
br label %55
55: ; preds = %93, %15
%56 = load i32, i32* %5
%57 = load i32, i32* %7
%58 = icmp slt i32 %56, %57
br i1 %58, label %59, label %100
59: ; preds = %55
%60 = load i8*, i8** %9
%61 = getelementptr inbounds i8, i8* %60, i64 3
%62 = load i8*, i8** %10
%63 = icmp ugt i8* %61, %62
br i1 %63, label %64, label %65
64: ; preds = %59
br label %101
65: ; preds = %59
%66 = load i8*, i8** %9
%67 = getelementptr inbounds i8, i8* %66, i64 2
%68 = load i8, i8* %67
%69 = zext i8 %68 to i32
%70 = shl i32 %69, 8
%71 = load i8*, i8** %9
%72 = getelementptr inbounds i8, i8* %71, i64 3
%73 = load i8, i8* %72
%74 = zext i8 %73 to i32
%75 = add nsw i32 %70, %74
%76 = add nsw i32 %75, 4
store i32 %76, i32* %6
%77 = load i8*, i8** %9
%78 = getelementptr inbounds i8, i8* %77, i64 1
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %6
%83 = icmp sgt i32 %82, 4
br i1 %83, label %84, label %90
84: ; preds = %65
%85 = load i8*, i8** %9
%86 = getelementptr inbounds i8, i8* %85, i64 4
%87 = load i32, i32* %6
%88 = sub nsw i32 %87, 4
%89 = call i32 @dStrHex(i8* %86, i32 %88, i32 0)
br label %92
90: ; preds = %65
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %90, %84
br label %93
93: ; preds = %92
%94 = load i32, i32* %5
%95 = add nsw i32 %94, 1
store i32 %95, i32* %5
%96 = load i32, i32* %6
%97 = load i8*, i8** %9
%98 = sext i32 %96 to i64
%99 = getelementptr inbounds i8, i8* %97, i64 %98
store i8* %99, i8** %9
br label %55
100: ; preds = %55
br label %104
101: ; preds = %64, %14
%102 = load i32, i32* @stderr
%103 = call i32 @fprintf(i32 %102, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %104
104: ; preds = %101, %100
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"
@stderr = global i32 0
@.str.5 = [43 x i8] c" <<<subence str: response too short>>>\0A\00"
@str = [40 x i8] c"Subenclosure string in diagnostic page:\00"
@str.6 = [12 x i8] c" <empty>\00"
define void @ses_subenc_string_sdg(i8* %0, i32 %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %1, 4
br i1 %4, label %62, 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, %57
%34 = phi i32 [ 0, %5 ], [ %58, %57 ]
%35 = phi i8* [ %32, %5 ], [ %60, %57 ]
%36 = getelementptr inbounds i8, i8* %35, i64 3
%37 = icmp ugt i8* %36, %11
br i1 %37, label %62, label %38
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %35, i64 2
%40 = load i8, i8* %39
%41 = zext i8 %40 to i32
%42 = shl nuw nsw i32 %41, 8
%43 = load i8, i8* %36
%44 = zext i8 %43 to i32
%45 = or i32 %42, %44
%46 = add nuw nsw i32 %45, 4
%47 = getelementptr inbounds i8, i8* %35, i64 1
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = icmp eq i32 %45, 0
br i1 %51, label %55, label %52
52: ; preds = %38
%53 = getelementptr inbounds i8, i8* %35, i64 4
%54 = tail call i32 @dStrHex(i8* %53, i32 %45, i32 0)
br label %57
55: ; preds = %38
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
br label %57
57: ; preds = %52, %55
%58 = add nuw nsw i32 %34, 1
%59 = zext i32 %46 to i64
%60 = getelementptr inbounds i8, i8* %35, i64 %59
%61 = icmp eq i32 %34, %8
br i1 %61, label %65, label %33
62: ; preds = %33, %2
%63 = load i32, i32* @stderr
%64 = tail call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
br label %65
65: ; preds = %57, %62
ret void
}