#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 */
int PTHREAD_CREATE_DETACHED;
int errno;
int /*<<< orphan*/ printf(char *, char *, int, char *, int, int);
int pthread_attr_getdetachstate(int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ puts(char *);
int verify_detach_result(pthread_attr_t *attr) {
  int state;
  ({
    int ret = pthread_attr_getdetachstate(attr, &state);
    if (ret != 0) {
      printf("%s:%d: %s returned %d (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/"
             "baseline/nptl/tst-default-attr.c",
             139, "pthread_attr_getdetachstate", ret, errno);
      return ret;
    }
  });
  if (state != PTHREAD_CREATE_DETACHED) {
    puts("failed to set detach state");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<verify_detach_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <pthread_attr_getdetachstate@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     118e <verify_detach_result+0x5e>
mov    -0x18(%rbp),%r8d
mov    0x2e77(%rip),%rax
mov    (%rax),%r9d
lea    0xe95(%rip),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x8b,%edx
lea    0xf41(%rip),%rcx
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <verify_detach_result+0x8f>
mov    -0x14(%rbp),%eax
mov    0x2e48(%rip),%rcx
cmp    (%rcx),%eax
je     11b8 <verify_detach_result+0x88>
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11bf <verify_detach_result+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verify_detach_result>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
call   1050 <pthread_attr_getdetachstate@plt>
test   %eax,%eax
je     1173 <verify_detach_result+0x43>
mov    %eax,%ebx
mov    0x2e8c(%rip),%rax
mov    (%rax),%r9d
lea    0xeaa(%rip),%rdi
lea    0xec7(%rip),%rsi
lea    0xf5b(%rip),%rcx
mov    $0x8b,%edx
mov    %ebx,%r8d
call   1040 <printf@plt>
jmp    1195 <verify_detach_result+0x65>
mov    0xc(%rsp),%eax
mov    0x2e62(%rip),%rcx
xor    %ebx,%ebx
cmp    (%rcx),%eax
je     1195 <verify_detach_result+0x65>
lea    0xf50(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%s:%d: %s returned %d (errno = %d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/baseline/nptl/tst-default-attr.c\00"
@.str.2 = [28 x i8] c"pthread_attr_getdetachstate\00"
@errno = global i32 0
@PTHREAD_CREATE_DETACHED = global i32 0
@.str.3 = [27 x i8] c"failed to set detach state\00"
define i32 @verify_detach_result(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @pthread_attr_getdetachstate(i32* %6, i32* %4)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32, i32* %5
%12 = load i32, i32* @errno
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 139, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %5
store i32 %14, i32* %2
br label %22
15: ; preds = %1
%16 = load i32, i32* %4
%17 = load i32, i32* @PTHREAD_CREATE_DETACHED
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %2
br label %22
21: ; preds = %15
store i32 0, i32* %2
br label %22
22: ; preds = %21, %19, %10
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [36 x i8] c"%s:%d: %s returned %d (errno = %d)\0A\00"
@.str.1 = [155 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Phant0mas/glibc-hurd/refs/heads/baseline/nptl/tst-default-attr.c\00"
@.str.2 = [28 x i8] c"pthread_attr_getdetachstate\00"
@errno = global i32 0
@PTHREAD_CREATE_DETACHED = global i32 0
@.str.3 = [27 x i8] c"failed to set detach state\00"
define i32 @verify_detach_result(i32* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call i32 @pthread_attr_getdetachstate(i32* %0, i32* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = load i32, i32* @errno
%8 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str.1, i64 0, i64 0), i32 139, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %7)
br label %15
9: ; preds = %1
%10 = load i32, i32* %2
%11 = load i32, i32* @PTHREAD_CREATE_DETACHED
%12 = icmp eq i32 %10, %11
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %6, %9, %13
%16 = phi i32 [ 1, %13 ], [ %4, %6 ], [ 0, %9 ]
ret i32 %16
}