#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*/ sprintf(char *, char *, int, int, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int MakeRegList(char *list, int mask, int ea) {
  int reverse = 0, i = 0, low = 0, len = 0;
  if ((ea & 0x38) == 0x20)
    reverse = 1;
  mask &= 0xffff;
  list[0] = 0;
  for (i = 0; i < 17; i++) {
    int bit = 0;
    if (reverse)
      bit = 0x8000 >> i;
    else
      bit = 1 << i;
    bit &= mask;
    if (bit == 0 || i == 8) {
      char add[16] = "";
      int ad = low & 8 ? 'a' : 'd';
      if (low == i - 1)
        sprintf(add, "%c%d/", ad, low & 7);
      if (low < i - 1)
        sprintf(add, "%c%d-%c%d/", ad, low & 7, ad, (i - 1) & 7);
      strcat(list, add);
      low = i;
    }
    if (bit == 0)
      low = i + 1;
  }
  len = strlen(list);
  if (len > 0)
    if (list[len - 1] == '/')
      list[len - 1] = 0;
  return 0;
}


x86 assembly (clang, -O0):
<MakeRegList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x38,%eax
cmp    $0x20,%eax
jne    1184 <MakeRegList+0x44>
movl   $0x1,-0x14(%rbp)
mov    -0xc(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x18(%rbp)
cmpl   $0x11,-0x18(%rbp)
jge    12be <MakeRegList+0x17e>
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ca <MakeRegList+0x8a>
mov    -0x18(%rbp),%ecx
mov    $0x8000,%eax
sar    %cl,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <MakeRegList+0x97>
mov    -0x18(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11f4 <MakeRegList+0xb4>
cmpl   $0x8,-0x18(%rbp)
jne    1298 <MakeRegList+0x158>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
mov    -0x1c(%rbp),%edx
and    $0x8,%edx
mov    $0x64,%eax
mov    $0x61,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1249 <MakeRegList+0x109>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    -0x1c(%rbp),%ecx
and    $0x7,%ecx
lea    0xdc3(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1285 <MakeRegList+0x145>
lea    -0x40(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    -0x1c(%rbp),%ecx
and    $0x7,%ecx
mov    -0x44(%rbp),%r8d
mov    -0x18(%rbp),%r9d
sub    $0x1,%r9d
and    $0x7,%r9d
lea    0xd82(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1050 <strcat@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    12ab <MakeRegList+0x16b>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b0 <MakeRegList+0x170>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119d <MakeRegList+0x5d>
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1304 <MakeRegList+0x1c4>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    12ff <MakeRegList+0x1bf>
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1304 <MakeRegList+0x1c4>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeRegList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%r15
and    $0x38,%edx
movzwl %si,%esi
movb   $0x0,(%rdi)
mov    $0x1,%r13d
xor    %ebx,%ebx
mov    %rdi,0x20(%rsp)
mov    %edx,0xc(%rsp)
mov    %esi,0x8(%rsp)
jmp    11a1 <MakeRegList+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%r15
mov    %r15,%rdi
lea    0x10(%rsp),%rsi
call   1040 <strcat@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%esi
test   %ebp,%ebp
cmove  %r13d,%r14d
add    $0x1,%r13d
mov    %r14d,%ebx
cmp    $0x12,%r13d
je     123f <MakeRegList+0x10f>
lea    -0x1(%r13),%r14d
mov    $0x8000,%eax
mov    %r14d,%ecx
shr    %cl,%eax
mov    $0x1,%ebp
shl    %cl,%ebp
cmp    $0x20,%edx
cmove  %eax,%ebp
and    %esi,%ebp
je     11d0 <MakeRegList+0xa0>
cmp    $0x9,%r13d
je     11d0 <MakeRegList+0xa0>
mov    %ebx,%r14d
jmp    118a <MakeRegList+0x5a>
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
xor    %eax,%eax
test   $0x8,%bl
sete   %al
lea    (%rax,%rax,2),%r12d
add    $0x61,%r12d
lea    -0x2(%r13),%r15d
cmp    %ebx,%r15d
jne    120c <MakeRegList+0xdc>
mov    %ebx,%ecx
and    $0x7,%ecx
lea    0x10(%rsp),%rdi
lea    0xe13(%rip),%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
cmp    %r15d,%ebx
jge    1170 <MakeRegList+0x40>
and    $0x7,%ebx
and    $0x7,%r15d
lea    0x10(%rsp),%rdi
lea    0xde8(%rip),%rsi
mov    %r12d,%edx
mov    %ebx,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1170 <MakeRegList+0x40>
mov    %r15,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    125a <MakeRegList+0x12a>
add    $0xffffffff,%eax
cmpb   $0x2f,(%r15,%rax,1)
jne    125a <MakeRegList+0x12a>
movb   $0x0,(%r15,%rax,1)
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%c%d/\00"
@.str.1 = [11 x i8] c"%c%d-%c%d/\00"
define i32 @MakeRegList(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [16 x i8]
%13 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%14 = load i32, i32* %6
%15 = and i32 %14, 56
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 1, i32* %7
br label %18
18: ; preds = %17, %3
%19 = load i32, i32* %5
%20 = and i32 %19, 65535
store i32 %20, i32* %5
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8 0, i8* %22
store i32 0, i32* %8
br label %23
23: ; preds = %88, %18
%24 = load i32, i32* %8
%25 = icmp slt i32 %24, 17
br i1 %25, label %26, label %91
26: ; preds = %23
store i32 0, i32* %11
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %8
%31 = ashr i32 32768, %30
store i32 %31, i32* %11
br label %35
32: ; preds = %26
%33 = load i32, i32* %8
%34 = shl i32 1, %33
store i32 %34, i32* %11
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %5
%37 = load i32, i32* %11
%38 = and i32 %37, %36
store i32 %38, i32* %11
%39 = load i32, i32* %11
%40 = icmp eq i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %35
%42 = load i32, i32* %8
%43 = icmp eq i32 %42, 8
br i1 %43, label %44, label %81
44: ; preds = %41, %35
%45 = bitcast [16 x i8]* %12 to i8*
%46 = load i32, i32* %9
%47 = and i32 %46, 8
%48 = icmp ne i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 97, i32 100
store i32 %50, i32* %13
%51 = load i32, i32* %9
%52 = load i32, i32* %8
%53 = sub nsw i32 %52, 1
%54 = icmp eq i32 %51, %53
br i1 %54, label %55, label %61
55: ; preds = %44
%56 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%57 = load i32, i32* %13
%58 = load i32, i32* %9
%59 = and i32 %58, 7
%60 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %57, i32 %59)
br label %61
61: ; preds = %55, %44
%62 = load i32, i32* %9
%63 = load i32, i32* %8
%64 = sub nsw i32 %63, 1
%65 = icmp slt i32 %62, %64
br i1 %65, label %66, label %76
66: ; preds = %61
%67 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%68 = load i32, i32* %13
%69 = load i32, i32* %9
%70 = and i32 %69, 7
%71 = load i32, i32* %13
%72 = load i32, i32* %8
%73 = sub nsw i32 %72, 1
%74 = and i32 %73, 7
%75 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %68, i32 %70, i32 %71, i32 %74)
br label %76
76: ; preds = %66, %61
%77 = load i8*, i8** %4
%78 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%79 = call i32 @strcat(i8* %77, i8* %78)
%80 = load i32, i32* %8
store i32 %80, i32* %9
br label %81
81: ; preds = %76, %41
%82 = load i32, i32* %11
%83 = icmp eq i32 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32, i32* %8
%86 = add nsw i32 %85, 1
store i32 %86, i32* %9
br label %87
87: ; preds = %84, %81
br label %88
88: ; preds = %87
%89 = load i32, i32* %8
%90 = add nsw i32 %89, 1
store i32 %90, i32* %8
br label %23
91: ; preds = %23
%92 = load i8*, i8** %4
%93 = call i32 @strlen(i8* %92)
store i32 %93, i32* %10
%94 = load i32, i32* %10
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %112
96: ; preds = %91
%97 = load i8*, i8** %4
%98 = load i32, i32* %10
%99 = sub nsw i32 %98, 1
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %97, i64 %100
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 47
br i1 %104, label %105, label %111
105: ; preds = %96
%106 = load i8*, i8** %4
%107 = load i32, i32* %10
%108 = sub nsw i32 %107, 1
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds i8, i8* %106, i64 %109
store i8 0, i8* %110
br label %111
111: ; preds = %105, %96
br label %112
112: ; preds = %111, %91
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%c%d/\00"
@.str.1 = [11 x i8] c"%c%d-%c%d/\00"
define i32 @MakeRegList(i8* %0, i32 %1, i32 %2) {
%4 = alloca [16 x i8]
%5 = and i32 %2, 56
%6 = icmp eq i32 %5, 32
%7 = and i32 %1, 65535
store i8 0, i8* %0
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
br label %9
9: ; preds = %3, %36
%10 = phi i32 [ 0, %3 ], [ %39, %36 ]
%11 = phi i32 [ 0, %3 ], [ %38, %36 ]
%12 = lshr i32 32768, %11
%13 = shl nuw nsw i32 1, %11
%14 = select i1 %6, i32 %12, i32 %13
%15 = and i32 %7, %14
%16 = icmp eq i32 %15, 0
%17 = icmp eq i32 %11, 8
%18 = select i1 %16, i1 true, i1 %17
br i1 %18, label %19, label %36
19: ; preds = %9
%20 = and i32 %10, 8
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 100, i32 97
%23 = add nsw i32 %11, -1
%24 = icmp eq i32 %10, %23
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = and i32 %10, 7
%27 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %26)
br label %28
28: ; preds = %25, %19
%29 = icmp slt i32 %10, %23
br i1 %29, label %30, label %34
30: ; preds = %28
%31 = and i32 %10, 7
%32 = and i32 %23, 7
%33 = call i32 (i8*, i8*, i32, i32, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %31, i32 %22, i32 %32)
br label %34
34: ; preds = %30, %28
%35 = call i32 @strcat(i8* %0, i8* %8)
br label %36
36: ; preds = %9, %34
%37 = phi i32 [ %11, %34 ], [ %10, %9 ]
%38 = add nuw nsw i32 %11, 1
%39 = select i1 %16, i32 %38, i32 %37
%40 = icmp eq i32 %38, 17
br i1 %40, label %41, label %9
41: ; preds = %36
%42 = call i32 @strlen(i8* %0)
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %41
%45 = add nsw i32 %42, -1
%46 = zext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %0, i64 %46
%48 = load i8, i8* %47
%49 = icmp eq i8 %48, 47
br i1 %49, label %50, label %51
50: ; preds = %44
store i8 0, i8* %47
br label %51
51: ; preds = %44, %50, %41
ret i32 0
}