#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 */
typedef int /*<<< orphan*/ pthread_attr_t;

/* Variables and functions */
#define PTHREAD_SCOPE_PROCESS 129
#define PTHREAD_SCOPE_SYSTEM 128
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int pthread_attr_getscope(int /*<<< orphan*/ *, int *);
int verify_scope(pthread_attr_t *attr, int scopetype) {
  int rc;
  int scope;
  rc = pthread_attr_getscope(attr, &scope);
  if (rc != 0) {
    perror("unexpected error: "
           "pthread_attr_getscope"
           " "
           "1-1"
           ": "
           "pthread_attr_getscope");
    exit(2);
  }
  switch (scopetype) {
  case PTHREAD_SCOPE_SYSTEM:
    if (scope != PTHREAD_SCOPE_SYSTEM) {
      perror("unexpected error: "
             "pthread_attr_getscope"
             " "
             "1-1"
             ": "
             "got wrong scope param");
      exit(1);
    }
    break;
  case PTHREAD_SCOPE_PROCESS:
    if (scope != PTHREAD_SCOPE_PROCESS) {
      perror("unexpected error: "
             "pthread_attr_getscope"
             " "
             "1-1"
             ": "
             "got wrong scope param");
      exit(1);
    }
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify_scope>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <pthread_attr_getscope@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     116f <verify_scope+0x3f>
lea    0xea0(%rip),%rdi
call   1040 <perror@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x80,%eax
je     1198 <verify_scope+0x68>
jmp    1185 <verify_scope+0x55>
mov    -0x18(%rbp),%eax
sub    $0x81,%eax
je     11c0 <verify_scope+0x90>
jmp    11e8 <verify_scope+0xb8>
cmpl   $0x80,-0x14(%rbp)
je     11bb <verify_scope+0x8b>
lea    0xe97(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11e8 <verify_scope+0xb8>
cmpl   $0x81,-0x14(%rbp)
je     11e3 <verify_scope+0xb3>
lea    0xe6f(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11e8 <verify_scope+0xb8>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_scope>:
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
lea    0xc(%rsp),%rsi
call   1030 <pthread_attr_getscope@plt>
test   %eax,%eax
jne    1187 <verify_scope+0x57>
cmp    $0x81,%ebx
je     1167 <verify_scope+0x37>
cmp    $0x80,%ebx
jne    115f <verify_scope+0x2f>
cmpl   $0x80,0xc(%rsp)
jne    1171 <verify_scope+0x41>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
cmpl   $0x81,0xc(%rsp)
je     115f <verify_scope+0x2f>
lea    0xecb(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
lea    0xe72(%rip),%rdi
call   1040 <perror@plt>
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [67 x i8] c"unexpected error: pthread_attr_getscope 1-1: pthread_attr_getscope\00"
@.str.1 = [67 x i8] c"unexpected error: pthread_attr_getscope 1-1: got wrong scope param\00"
define i32 @verify_scope(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
%8 = call i32 @pthread_attr_getscope(i32* %7, i32* %6)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 2)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
switch i32 %15, label %30 [
i32 128, label %16
i32 129, label %23
]
16: ; preds = %14
%17 = load i32, i32* %6
%18 = icmp ne i32 %17, 128
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %16
br label %30
23: ; preds = %14
%24 = load i32, i32* %6
%25 = icmp ne i32 %24, 129
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %23
br label %30
30: ; preds = %14, %29, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [67 x i8] c"unexpected error: pthread_attr_getscope 1-1: pthread_attr_getscope\00"
@.str.1 = [67 x i8] c"unexpected error: pthread_attr_getscope 1-1: got wrong scope param\00"
define i32 @verify_scope(i32* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @pthread_attr_getscope(i32* %0, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %2
switch i32 %1, label %23 [
i32 128, label %11
i32 129, label %17
]
11: ; preds = %10
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 128
br i1 %13, label %23, label %14
14: ; preds = %11
%15 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %10
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 129
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = call i32 @perror(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %17, %11, %10
ret i32 0
}