#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 */
#define PTHREAD_CREATE_DETACHED 136
#define PTHREAD_CREATE_JOINABLE 135
#define PTHREAD_EXPLICIT_SCHED 134
#define PTHREAD_INHERIT_SCHED 133
#define PTHREAD_SCOPE_PROCESS 132
#define PTHREAD_SCOPE_SYSTEM 131
#define SCHED_FIFO 130
#define SCHED_OTHER 129
#define SCHED_RR 128
const char *attrstr(int type, int attr) {
  switch (type) {
  case 'd':
    switch (attr) {
    case PTHREAD_CREATE_DETACHED:
      return "PTHREAD_CREATE_DETACHED";
    case PTHREAD_CREATE_JOINABLE:
      return "PTHREAD_CREATE_JOINABLE";
    }
    break;
  case 'i':
    switch (attr) {
    case PTHREAD_INHERIT_SCHED:
      return "PTHREAD_INHERIT_SCHED";
    case PTHREAD_EXPLICIT_SCHED:
      return "PTHREAD_EXPLICIT_SCHED";
    }
    break;
  case 'p':
    switch (attr) {
    case SCHED_OTHER:
      return "SCHED_OTHER";
    case SCHED_FIFO:
      return "SCHED_FIFO";
    case SCHED_RR:
      return "SCHED_RR";
    }
    break;
  case 's':
    switch (attr) {
    case PTHREAD_SCOPE_SYSTEM:
      return "PTHREAD_SCOPE_SYSTEM";
    case PTHREAD_SCOPE_PROCESS:
      return "PTHREAD_SCOPE_PROCESS";
    }
    break;
  }
  return "???";
}


x86 assembly (clang, -O0):
<attrstr>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xf,%eax
ja     128e <attrstr+0x18e>
mov    -0x18(%rbp),%rax
lea    0xed6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x87,%eax
je     116c <attrstr+0x6c>
jmp    1149 <attrstr+0x49>
mov    -0x1c(%rbp),%eax
sub    $0x88,%eax
jne    117c <attrstr+0x7c>
jmp    115c <attrstr+0x5c>
lea    0xedd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
lea    0xee5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
jmp    128e <attrstr+0x18e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x85,%eax
je     11aa <attrstr+0xaa>
jmp    1197 <attrstr+0x97>
mov    -0x20(%rbp),%eax
sub    $0x86,%eax
je     11ba <attrstr+0xba>
jmp    11ca <attrstr+0xca>
lea    0xebf(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
jmp    128e <attrstr+0x18e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     122b <attrstr+0x12b>
jmp    11e5 <attrstr+0xe5>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
je     120b <attrstr+0x10b>
jmp    11f8 <attrstr+0xf8>
mov    -0x24(%rbp),%eax
sub    $0x82,%eax
je     121b <attrstr+0x11b>
jmp    123b <attrstr+0x13b>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
lea    0xe87(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
jmp    128e <attrstr+0x18e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x83,%eax
je     1269 <attrstr+0x169>
jmp    1256 <attrstr+0x156>
mov    -0x28(%rbp),%eax
sub    $0x84,%eax
je     1279 <attrstr+0x179>
jmp    1289 <attrstr+0x189>
lea    0xe4d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
lea    0xe52(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1299 <attrstr+0x199>
jmp    128e <attrstr+0x18e>
lea    0xe53(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<attrstr>:
lea    0xfed(%rip),%rax
add    $0xffffff9c,%edi
cmp    $0xf,%edi
ja     118c <attrstr+0x8c>
lea    0xeea(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
cmp    $0x87,%esi
lea    0xf38(%rip),%rax
lea    0xfc1(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x88,%esi
lea    0xf08(%rip),%rax
cmovne %rcx,%rax
ret
cmp    $0x86,%esi
lea    0xf3c(%rip),%rax
lea    0xf97(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x85,%esi
lea    0xf0e(%rip),%rax
cmovne %rcx,%rax
ret
add    $0xffffff80,%esi
cmp    $0x3,%esi
jae    118c <attrstr+0x8c>
movslq %esi,%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
ret
cmp    $0x84,%esi
lea    0xf44(%rip),%rax
lea    0xf53(%rip),%rcx
cmove  %rax,%rcx
cmp    $0x83,%esi
lea    0xf17(%rip),%rax
cmovne %rcx,%rax
ret

LLVM IR (-O0):
@.str = [24 x i8] c"PTHREAD_CREATE_DETACHED\00"
@.str.1 = [24 x i8] c"PTHREAD_CREATE_JOINABLE\00"
@.str.2 = [22 x i8] c"PTHREAD_INHERIT_SCHED\00"
@.str.3 = [23 x i8] c"PTHREAD_EXPLICIT_SCHED\00"
@.str.4 = [12 x i8] c"SCHED_OTHER\00"
@.str.5 = [11 x i8] c"SCHED_FIFO\00"
@.str.6 = [9 x i8] c"SCHED_RR\00"
@.str.7 = [21 x i8] c"PTHREAD_SCOPE_SYSTEM\00"
@.str.8 = [22 x i8] c"PTHREAD_SCOPE_PROCESS\00"
@.str.9 = [4 x i8] c"???\00"
define i8* @attrstr(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %28 [
i32 100, label %7
i32 105, label %12
i32 112, label %17
i32 115, label %23
]
7: ; preds = %2
%8 = load i32, i32* %5
switch i32 %8, label %11 [
i32 136, label %9
i32 135, label %10
]
9: ; preds = %7
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8** %3
br label %29
10: ; preds = %7
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %29
11: ; preds = %7
br label %28
12: ; preds = %2
%13 = load i32, i32* %5
switch i32 %13, label %16 [
i32 133, label %14
i32 134, label %15
]
14: ; preds = %12
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %29
15: ; preds = %12
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %29
16: ; preds = %12
br label %28
17: ; preds = %2
%18 = load i32, i32* %5
switch i32 %18, label %22 [
i32 129, label %19
i32 130, label %20
i32 128, label %21
]
19: ; preds = %17
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %29
20: ; preds = %17
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8** %3
br label %29
21: ; preds = %17
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8** %3
br label %29
22: ; preds = %17
br label %28
23: ; preds = %2
%24 = load i32, i32* %5
switch i32 %24, label %27 [
i32 131, label %25
i32 132, label %26
]
25: ; preds = %23
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8** %3
br label %29
26: ; preds = %23
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8** %3
br label %29
27: ; preds = %23
br label %28
28: ; preds = %2, %27, %22, %16, %11
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %3
br label %29
29: ; preds = %28, %26, %25, %21, %20, %19, %15, %14, %10, %9
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
@.str = [24 x i8] c"PTHREAD_CREATE_DETACHED\00"
@.str.1 = [24 x i8] c"PTHREAD_CREATE_JOINABLE\00"
@.str.2 = [22 x i8] c"PTHREAD_INHERIT_SCHED\00"
@.str.3 = [23 x i8] c"PTHREAD_EXPLICIT_SCHED\00"
@.str.4 = [12 x i8] c"SCHED_OTHER\00"
@.str.5 = [11 x i8] c"SCHED_FIFO\00"
@.str.6 = [9 x i8] c"SCHED_RR\00"
@.str.7 = [21 x i8] c"PTHREAD_SCOPE_SYSTEM\00"
@.str.8 = [22 x i8] c"PTHREAD_SCOPE_PROCESS\00"
@.str.9 = [4 x i8] c"???\00"
@reltable.attrstr = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([9 x i8]* @.str.6 to i64), i64 ptrtoint ([3 x i32]* @reltable.attrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.attrstr to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([11 x i8]* @.str.5 to i64), i64 ptrtoint ([3 x i32]* @reltable.attrstr to i64)) to i32)]
define i8* @attrstr(i32 %0, i32 %1) {
switch i32 %0, label %25 [
i32 100, label %3
i32 105, label %8
i32 112, label %13
i32 115, label %16
]
3: ; preds = %2
%4 = icmp eq i32 %1, 135
%5 = select i1 %4, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0)
%6 = icmp eq i32 %1, 136
%7 = select i1 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %5
br label %25
8: ; preds = %2
%9 = icmp eq i32 %1, 134
%10 = select i1 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0)
%11 = icmp eq i32 %1, 133
%12 = select i1 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %10
br label %25
13: ; preds = %2
%14 = add i32 %1, -128
%15 = icmp ult i32 %14, 3
br i1 %15, label %21, label %25
16: ; preds = %2
%17 = icmp eq i32 %1, 132
%18 = select i1 %17, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0)
%19 = icmp eq i32 %1, 131
%20 = select i1 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %18
br label %25
21: ; preds = %13
%22 = sext i32 %14 to i64
%23 = shl i64 %22, 2
%24 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.attrstr to i8*), i64 %23)
br label %25
25: ; preds = %2, %13, %21, %16, %8, %3
%26 = phi i8* [ %7, %3 ], [ %12, %8 ], [ %20, %16 ], [ %24, %21 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %13 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %2 ]
ret i8* %26
}