#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 */
char *find_diag_page_desc(int);
int /*<<< orphan*/ printf(char *, char const *, ...);
void ses_supported_pages_sdg(const char *leadin, const unsigned char *resp,
                             int resp_len) {
  int k, code, prev;
  const char *cp;
  printf("%s:\n", leadin);
  for (k = 0, prev = 0; k < (resp_len - 4); ++k, prev = code) {
    code = resp[k + 4];
    if (code < prev)
      break;
    cp = find_diag_page_desc(code);
    printf("  %s [0x%x]\n", (cp ? cp : "<unknown>"), code);
  }
}


x86 assembly (clang, -O0):
<ses_supported_pages_sdg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jge    11e6 <ses_supported_pages_sdg+0xc6>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1189 <ses_supported_pages_sdg+0x69>
jmp    11e6 <ses_supported_pages_sdg+0xc6>
mov    -0x1c(%rbp),%edi
call   1040 <find_diag_page_desc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ad <ses_supported_pages_sdg+0x8d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11bd <ses_supported_pages_sdg+0x9d>
lea    0xe5e(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11bd <ses_supported_pages_sdg+0x9d>
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    1153 <ses_supported_pages_sdg+0x33>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ses_supported_pages_sdg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%rsi
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x5,%r13d
jl     1192 <ses_supported_pages_sdg+0x72>
add    $0xfffffffc,%r13d
lea    0xebf(%rip),%r12
lea    0xeab(%rip),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %ebp,%eax
movzbl 0x4(%r14,%rbx,1),%ebp
cmp    %ebp,%eax
ja     1192 <ses_supported_pages_sdg+0x72>
mov    %ebp,%edi
call   1040 <find_diag_page_desc@plt>
test   %rax,%rax
cmove  %r12,%rax
mov    %r15,%rdi
mov    %rax,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1160 <ses_supported_pages_sdg+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [13 x i8] c" %s [0x%x]\0A\00"
@.str.2 = [10 x i8] c"<unknown>\00"
define void @ses_supported_pages_sdg(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%11 = load i8*, i8** %4
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 0, i32* %7
store i32 0, i32* %9
br label %13
13: ; preds = %42, %3
%14 = load i32, i32* %7
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 4
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %46
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
store i32 %25, i32* %8
%26 = load i32, i32* %8
%27 = load i32, i32* %9
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %30
29: ; preds = %18
br label %46
30: ; preds = %18
%31 = load i32, i32* %8
%32 = call i8* @find_diag_page_desc(i32 %31)
store i8* %32, i8** %10
%33 = load i8*, i8** %10
%34 = icmp ne i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i8*, i8** %10
br label %38
37: ; preds = %30
br label %38
38: ; preds = %37, %35
%39 = phi i8* [ %36, %35 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), %37 ]
%40 = load i32, i32* %8
%41 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %39, i32 %40)
br label %42
42: ; preds = %38
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
%45 = load i32, i32* %8
store i32 %45, i32* %9
br label %13
46: ; preds = %29, %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s:\0A\00"
@.str.1 = [13 x i8] c" %s [0x%x]\0A\00"
@.str.2 = [10 x i8] c"<unknown>\00"
define void @ses_supported_pages_sdg(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %2, 4
br i1 %5, label %6, label %24
6: ; preds = %3
%7 = add nsw i32 %2, -4
%8 = zext i32 %7 to i64
br label %9
9: ; preds = %6, %17
%10 = phi i64 [ 0, %6 ], [ %22, %17 ]
%11 = phi i32 [ 0, %6 ], [ %15, %17 ]
%12 = add nuw nsw i64 %10, 4
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = zext i8 %14 to i32
%16 = icmp ugt i32 %11, %15
br i1 %16, label %24, label %17
17: ; preds = %9
%18 = tail call i8* @find_diag_page_desc(i32 %15)
%19 = icmp eq i8* %18, null
%20 = select i1 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %18
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %20, i32 %15)
%22 = add nuw nsw i64 %10, 1
%23 = icmp eq i64 %22, %8
br i1 %23, label %24, label %9
24: ; preds = %17, %9, %3
ret void
}