#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 pthread_key_t;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ FAIL(char *);
int /*<<< orphan*/ PASS(char *);
int pthread_key_create(int *, int /*<<< orphan*/ *);
int main() {
  pthread_key_t key;
  int result = pthread_key_create(&key, NULL);
  if (result != 0)
    FAIL("pthread-keys creation failure");
  else if (key < 4)
    FAIL("pthread-keys key out of bounds");
  else
    PASS("pthread-keys");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <pthread_key_create@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     116a <main+0x3a>
lea    0xea0(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1196 <main+0x66>
cmpl   $0x4,-0x8(%rbp)
jge    1185 <main+0x55>
lea    0xea3(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1191 <main+0x61>
lea    0xeb1(%rip),%rdi
call   1040 <PASS@plt>
jmp    1196 <main+0x66>
mov    0x2e43(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x4(%rsp),%rdi
xor    %esi,%esi
call   1030 <pthread_key_create@plt>
test   %eax,%eax
je     114f <main+0x1f>
lea    0xeb8(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1170 <main+0x40>
cmpl   $0x3,0x4(%rsp)
jg     1164 <main+0x34>
lea    0xec1(%rip),%rdi
call   1050 <FAIL@plt>
jmp    1170 <main+0x40>
lea    0xed2(%rip),%rdi
call   1040 <PASS@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"pthread-keys creation failure\00"
@.str.1 = [31 x i8] c"pthread-keys key out of bounds\00"
@.str.2 = [13 x i8] c"pthread-keys\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @pthread_key_create(i32* %2, i32* null)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @FAIL(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %17
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 4
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @FAIL(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %9
%15 = call i32 @PASS(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
br label %17
17: ; preds = %16, %7
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

LLVM IR (-O2):
@.str = [30 x i8] c"pthread-keys creation failure\00"
@.str.1 = [31 x i8] c"pthread-keys key out of bounds\00"
@.str.2 = [13 x i8] c"pthread-keys\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @pthread_key_create(i32* %1, i32* null)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 @FAIL(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %14
7: ; preds = %0
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i32 @FAIL(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %7
%13 = call i32 @PASS(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %10, %12, %5
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}