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

/* Variables and functions */
int /*<<< orphan*/ *hybris_alloc_init_cond();
scalar_t__ hybris_check_android_shared_cond(int);
int pthread_cond_broadcast(int /*<<< orphan*/ *);
int my_pthread_cond_broadcast(pthread_cond_t *cond) {
  int value = (*(int *)cond);
  if (hybris_check_android_shared_cond(value)) {
    ;
    return 0;
  }
  pthread_cond_t *realcond = (pthread_cond_t *)value;
  if (value <= 0xFFFF) {
    realcond = hybris_alloc_init_cond();
    *((int *)cond) = (int)realcond;
  }
  return pthread_cond_broadcast(realcond);
}


x86 assembly (clang, -O0):
<my_pthread_cond_broadcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <hybris_check_android_shared_cond@plt>
cmp    $0x0,%rax
je     1163 <my_pthread_cond_broadcast+0x33>
movl   $0x0,-0x4(%rbp)
jmp    119b <my_pthread_cond_broadcast+0x6b>
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0xffff,-0x14(%rbp)
jg     118f <my_pthread_cond_broadcast+0x5f>
mov    $0x0,%al
call   1040 <hybris_alloc_init_cond@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <pthread_cond_broadcast@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<my_pthread_cond_broadcast>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%ebp
mov    %ebp,%edi
call   1050 <hybris_check_android_shared_cond@plt>
test   %rax,%rax
je     114d <my_pthread_cond_broadcast+0x1d>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    $0xffff,%ebp
jg     1163 <my_pthread_cond_broadcast+0x33>
xor    %eax,%eax
call   1040 <hybris_alloc_init_cond@plt>
mov    %rax,%rdi
mov    %edi,(%rbx)
jmp    1166 <my_pthread_cond_broadcast+0x36>
movslq %ebp,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <pthread_cond_broadcast@plt>

LLVM IR (-O0):
define i32 @my_pthread_cond_broadcast(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 = load i32, i32* %6
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = call i64 @hybris_check_android_shared_cond(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %26
12: ; preds = %1
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
store i32* %15, i32** %5
%16 = load i32, i32* %4
%17 = icmp sle i32 %16, 65535
br i1 %17, label %18, label %23
18: ; preds = %12
%19 = call i32* (...) @hybris_alloc_init_cond()
store i32* %19, i32** %5
%20 = load i32*, i32** %5
%21 = ptrtoint i32* %20 to i32
%22 = load i32*, i32** %3
store i32 %21, i32* %22
br label %23
23: ; preds = %18, %12
%24 = load i32*, i32** %5
%25 = call i32 @pthread_cond_broadcast(i32* %24)
store i32 %25, i32* %2
br label %26
26: ; preds = %23, %11
%27 = load i32, i32* %2
ret i32 %27
}

LLVM IR (-O2):
define i32 @my_pthread_cond_broadcast(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = tail call i64 @hybris_check_android_shared_cond(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %16
5: ; preds = %1
%6 = sext i32 %2 to i64
%7 = inttoptr i64 %6 to i32*
%8 = icmp slt i32 %2, 65536
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = tail call i32* (...) @hybris_alloc_init_cond()
%11 = ptrtoint i32* %10 to i64
%12 = trunc i64 %11 to i32
store i32 %12, i32* %0
br label %13
13: ; preds = %9, %5
%14 = phi i32* [ %10, %9 ], [ %7, %5 ]
%15 = tail call i32 @pthread_cond_broadcast(i32* %14)
br label %16
16: ; preds = %1, %13
%17 = phi i32 [ %15, %13 ], [ 0, %1 ]
ret i32 %17
}