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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int pthread_rwlockattr_destroy(int /*<<< orphan*/ *);
int pthread_rwlockattr_init(int /*<<< orphan*/ *);
int main(void) {
  pthread_rwlockattr_t rwla;
  int rc;
  rc = pthread_rwlockattr_init(&rwla);
  if (rc != 0) {
    printf("Error at pthread_rwlockattr_init(), error code: %d\n", rc);
    return 2;
  }
  rc = pthread_rwlockattr_destroy(&rwla);
  if (rc != 0) {
    printf("Error at pthread_rwlockattr_destroy(), error code: %d\n", rc);
    printf("Test FAILED\n");
    return 1;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1040 <pthread_rwlockattr_init@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1172 <main+0x42>
mov    -0xc(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11c8 <main+0x98>
lea    -0x8(%rbp),%rdi
call   1050 <pthread_rwlockattr_destroy@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11b3 <main+0x83>
mov    -0xc(%rbp),%esi
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <main+0x98>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0x4(%rsp),%rdi
call   1050 <pthread_rwlockattr_init@plt>
test   %eax,%eax
je     1166 <main+0x26>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x2,%eax
pop    %rcx
ret
lea    0x4(%rsp),%rdi
call   1060 <pthread_rwlockattr_destroy@plt>
test   %eax,%eax
je     1197 <main+0x57>
lea    0xeb9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
pop    %rcx
ret
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [52 x i8] c"Error at pthread_rwlockattr_init(), error code: %d\0A\00"
@.str.1 = [55 x i8] c"Error at pthread_rwlockattr_destroy(), error code: %d\0A\00"
@.str.2 = [13 x i8] c"Test FAILED\0A\00"
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @pthread_rwlockattr_init(i32* %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 2, i32* %1
br label %20
10: ; preds = %0
%11 = call i32 @pthread_rwlockattr_destroy(i32* %2)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %20
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %20
20: ; preds = %18, %14, %7
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [52 x i8] c"Error at pthread_rwlockattr_init(), error code: %d\0A\00"
@.str.1 = [55 x i8] c"Error at pthread_rwlockattr_destroy(), error code: %d\0A\00"
@str = [12 x i8] c"Test PASSED\00"
@str.4 = [12 x i8] c"Test FAILED\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @pthread_rwlockattr_init(i32* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %15
7: ; preds = %0
%8 = call i32 @pthread_rwlockattr_destroy(i32* %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %15
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10, %5
%16 = phi i32 [ 2, %5 ], [ 1, %10 ], [ 0, %13 ]
ret i32 %16
}