#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 EINVAL;
int /*<<< orphan*/ exit(int);
int pthread_getconcurrency();
int pthread_setconcurrency(int);
int /*<<< orphan*/ puts(char *);
int do_test(void) {
  int c = pthread_getconcurrency();
  if (c != 0) {
    puts("initial concurrencylevel wrong");
    exit(1);
  }
  if (pthread_setconcurrency(1) != 0) {
    puts("setconcurrency failed");
    exit(1);
  }
  c = pthread_getconcurrency();
  if (c != 1) {
    puts("getconcurrency didn't return the value previous set");
    exit(1);
  }
  int e = pthread_setconcurrency(-1);
  if (e == 0) {
    puts("setconcurrency of negative value didn't failed");
    exit(1);
  }
  if (e != EINVAL) {
    puts("setconcurrency didn't return EINVAL for negative value");
    exit(1);
  }
  c = pthread_getconcurrency();
  if (c != 1) {
    puts("invalid getconcurrency changed level");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <pthread_getconcurrency@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1172 <do_test+0x32>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x1,%edi
call   1040 <pthread_setconcurrency@plt>
cmp    $0x0,%eax
je     119b <do_test+0x5b>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1050 <pthread_getconcurrency@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     11c5 <do_test+0x85>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0xffffffff,%edi
call   1040 <pthread_setconcurrency@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11f2 <do_test+0xb2>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%eax
mov    0x2de4(%rip),%rcx
cmp    (%rcx),%eax
je     121a <do_test+0xda>
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x0,%al
call   1050 <pthread_getconcurrency@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x1,-0x4(%rbp)
je     1244 <do_test+0x104>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rax
xor    %eax,%eax
call   1050 <pthread_getconcurrency@plt>
test   %eax,%eax
jne    118f <do_test+0x4f>
mov    $0x1,%edi
call   1040 <pthread_setconcurrency@plt>
test   %eax,%eax
jne    1198 <do_test+0x58>
xor    %eax,%eax
call   1050 <pthread_getconcurrency@plt>
cmp    $0x1,%eax
jne    11a1 <do_test+0x61>
mov    $0xffffffff,%edi
call   1040 <pthread_setconcurrency@plt>
test   %eax,%eax
je     11aa <do_test+0x6a>
mov    0x2e65(%rip),%rcx
cmp    (%rcx),%eax
jne    11b3 <do_test+0x73>
xor    %eax,%eax
call   1050 <pthread_getconcurrency@plt>
cmp    $0x1,%eax
jne    11bc <do_test+0x7c>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe6a(%rip),%rdi
jmp    11c3 <do_test+0x83>
lea    0xe80(%rip),%rdi
jmp    11c3 <do_test+0x83>
lea    0xe8d(%rip),%rdi
jmp    11c3 <do_test+0x83>
lea    0xeb8(%rip),%rdi
jmp    11c3 <do_test+0x83>
lea    0xede(%rip),%rdi
jmp    11c3 <do_test+0x83>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"initial concurrencylevel wrong\00"
@.str.1 = [22 x i8] c"setconcurrency failed\00"
@.str.2 = [52 x i8] c"getconcurrency didn't return the value previous set\00"
@.str.3 = [47 x i8] c"setconcurrency of negative value didn't failed\00"
@EINVAL = global i32 0
@.str.4 = [55 x i8] c"setconcurrency didn't return EINVAL for negative value\00"
@.str.5 = [37 x i8] c"invalid getconcurrency changed level\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @pthread_getconcurrency()
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 @pthread_setconcurrency(i32 1)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %9
%16 = call i32 (...) @pthread_getconcurrency()
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = call i32 @puts(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %15
%23 = call i32 @pthread_setconcurrency(i32 -1)
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %22
%30 = load i32, i32* %2
%31 = load i32, i32* @EINVAL
%32 = icmp ne i32 %30, %31
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = call i32 @puts(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29
%37 = call i32 (...) @pthread_getconcurrency()
store i32 %37, i32* %1
%38 = load i32, i32* %1
%39 = icmp ne i32 %38, 1
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = call i32 @puts(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %36
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"initial concurrencylevel wrong\00"
@.str.1 = [22 x i8] c"setconcurrency failed\00"
@.str.2 = [52 x i8] c"getconcurrency didn't return the value previous set\00"
@.str.3 = [47 x i8] c"setconcurrency of negative value didn't failed\00"
@EINVAL = global i32 0
@.str.4 = [55 x i8] c"setconcurrency didn't return EINVAL for negative value\00"
@.str.5 = [37 x i8] c"invalid getconcurrency changed level\00"
define i32 @do_test() {
%1 = tail call i32 (...) @pthread_getconcurrency()
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @exit(i32 1)
unreachable
6: ; preds = %0
%7 = tail call i32 @pthread_setconcurrency(i32 1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %6
%13 = tail call i32 (...) @pthread_getconcurrency()
%14 = icmp eq i32 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = tail call i32 @pthread_setconcurrency(i32 -1)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0))
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %18
%25 = load i32, i32* @EINVAL
%26 = icmp eq i32 %19, %25
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.4, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %24
%31 = tail call i32 (...) @pthread_getconcurrency()
%32 = icmp eq i32 %31, 1
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %30
ret i32 0
}