#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 */
struct pthreadpool {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int pthreadpool_destroy(struct pthreadpool *);
int pthreadpool_init(int, struct pthreadpool **);
int /*<<< orphan*/ stderr;
char *strerror(int);
int test_init(void) {
  struct pthreadpool *p;
  int ret;
  ret = pthreadpool_init(1, &p);
  if (ret != 0) {
    fprintf(stderr, "pthreadpool_init failed: %s\n", strerror(ret));
    return -1;
  }
  ret = pthreadpool_destroy(p);
  if (ret != 0) {
    fprintf(stderr, "pthreadpool_init failed: %s\n", strerror(ret));
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<test_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x1,%edi
lea    -0x10(%rbp),%rsi
call   1040 <pthreadpool_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1195 <test_init+0x55>
mov    0x2e76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe7c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <test_init+0xa4>
mov    -0x10(%rbp),%rdi
call   1030 <pthreadpool_destroy@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11dd <test_init+0x9d>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe34(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <test_init+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_init>:
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rsi
mov    $0x1,%edi
call   1040 <pthreadpool_init@plt>
test   %eax,%eax
jne    1166 <test_init+0x26>
mov    0x8(%rsp),%rdi
call   1030 <pthreadpool_destroy@plt>
test   %eax,%eax
je     1192 <test_init+0x52>
mov    0x2e73(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1060 <strerror@plt>
lea    0xe83(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
jmp    118c <test_init+0x4c>

LLVM IR (-O0):
%struct.pthreadpool = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"pthreadpool_init failed: %s\0A\00"
define i32 @test_init() {
%1 = alloca i32
%2 = alloca %struct.pthreadpool*
%3 = alloca i32
%4 = call i32 @pthreadpool_init(i32 1, %struct.pthreadpool** %2)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* %3
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 -1, i32* %1
br label %23
12: ; preds = %0
%13 = load %struct.pthreadpool*, %struct.pthreadpool** %2
%14 = call i32 @pthreadpool_destroy(%struct.pthreadpool* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i32, i32* %3
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %1
br label %23
22: ; preds = %12
store i32 0, i32* %1
br label %23
23: ; preds = %22, %17, %7
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
%struct.pthreadpool = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"pthreadpool_init failed: %s\0A\00"
define i32 @test_init() {
%1 = alloca %struct.pthreadpool*
%2 = bitcast %struct.pthreadpool** %1 to i8*
%3 = call i32 @pthreadpool_init(i32 1, %struct.pthreadpool** %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = load %struct.pthreadpool*, %struct.pthreadpool** %1
%7 = call i32 @pthreadpool_destroy(%struct.pthreadpool* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %5, %0
%10 = phi i32 [ %3, %0 ], [ %7, %5 ]
%11 = load i32, i32* @stderr
%12 = call i8* @strerror(i32 %10)
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %9, %5
%15 = phi i32 [ 0, %5 ], [ -1, %9 ]
ret i32 %15
}