#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*/ assert(int);
int pthread_getconcurrency();
int pthread_setconcurrency(int);
int main(int argc, char **argv) {
  int i;
  int err;
  i = pthread_getconcurrency();
  assert(i == 0);
  err = pthread_setconcurrency(-1);
  assert(err == EINVAL);
  err = pthread_setconcurrency(4);
  assert(err == 0);
  i = pthread_getconcurrency();
  assert(i == 4);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <pthread_getconcurrency@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0xffffffff,%edi
call   1030 <pthread_setconcurrency@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x4,%edi
call   1030 <pthread_setconcurrency@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    $0x0,%al
call   1050 <pthread_getconcurrency@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1050 <pthread_getconcurrency@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
mov    $0xffffffff,%edi
call   1030 <pthread_setconcurrency@plt>
mov    0x2e8a(%rip),%rcx
xor    %edi,%edi
cmp    (%rcx),%eax
sete   %dil
call   1040 <assert@plt>
mov    $0x4,%edi
call   1030 <pthread_setconcurrency@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
call   1050 <pthread_getconcurrency@plt>
xor    %edi,%edi
cmp    $0x4,%eax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @pthread_getconcurrency()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = call i32 @pthread_setconcurrency(i32 -1)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = load i32, i32* @EINVAL
%16 = icmp eq i32 %14, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @pthread_setconcurrency(i32 4)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = call i32 (...) @pthread_getconcurrency()
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 4
%27 = zext i1 %26 to i32
%28 = call i32 @assert(i32 %27)
ret i32 0
}

LLVM IR (-O2):
@EINVAL = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @pthread_getconcurrency()
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = tail call i32 @pthread_setconcurrency(i32 -1)
%8 = load i32, i32* @EINVAL
%9 = icmp eq i32 %7, %8
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = tail call i32 @pthread_setconcurrency(i32 4)
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 (...) @pthread_getconcurrency()
%17 = icmp eq i32 %16, 4
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
ret i32 0
}