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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
int pthread_barrier_init(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
char *strerror(int);
bool pthread_wrapper_create_barrier(pthread_barrier_t *b, int num_threads) {
  int err;
  if (!b)
    return false;
  err = pthread_barrier_init(b, NULL, num_threads);
  if (err) {
    printf("Error: Barrier init failed:%s", strerror(err));
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<pthread_wrapper_create_barrier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1156 <pthread_wrapper_create_barrier+0x26>
movl   $0x0,-0x4(%rbp)
jmp    119d <pthread_wrapper_create_barrier+0x6d>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1030 <pthread_barrier_init@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1196 <pthread_wrapper_create_barrier+0x66>
mov    -0x18(%rbp),%edi
call   1050 <strerror@plt>
mov    %rax,%rsi
lea    0xe7b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119d <pthread_wrapper_create_barrier+0x6d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pthread_wrapper_create_barrier>:
push   %rbx
test   %rdi,%rdi
je     115d <pthread_wrapper_create_barrier+0x2d>
mov    %esi,%edx
xor    %ebx,%ebx
xor    %esi,%esi
call   1030 <pthread_barrier_init@plt>
test   %eax,%eax
je     1161 <pthread_wrapper_create_barrier+0x31>
mov    %eax,%edi
call   1050 <strerror@plt>
lea    0xead(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
jmp    1166 <pthread_wrapper_create_barrier+0x36>
xor    %ebx,%ebx
jmp    1166 <pthread_wrapper_create_barrier+0x36>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Error: Barrier init failed:%s\00"
define i32 @pthread_wrapper_create_barrier(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %2
store i32 0, i32* %3
br label %21
10: ; preds = %2
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = call i32 @pthread_barrier_init(i32* %11, i32* null, i32 %12)
store i32 %13, i32* %6
%14 = load i32, i32* %6
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* %6
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 0, i32* %3
br label %21
20: ; preds = %10
store i32 1, i32* %3
br label %21
21: ; preds = %20, %16, %9
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [30 x i8] c"Error: Barrier init failed:%s\00"
define i32 @pthread_wrapper_create_barrier(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = tail call i32 @pthread_barrier_init(i32* %0, i32* null, i32 %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i8* @strerror(i32 %5)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %4, %2, %7
%11 = phi i32 [ 0, %7 ], [ 0, %2 ], [ 1, %4 ]
ret i32 %11
}