#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 */

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ realloc(int *, int);
void add_single_signal(int **signalSet, int *nbSignals, int signal) {
  assert(NULL != signalSet);
  assert(NULL != nbSignals);
  assert(0 <= nbSignals[0]);
  assert(0 <= signal);
  int newSize = (1 + nbSignals[0]);
  signalSet[0] = (int *)realloc(signalSet[0], newSize * sizeof(int));
  signalSet[0][nbSignals[0]] = signal;
  nbSignals[0] = newSize;
}


x86 assembly (clang, -O0):
<add_single_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1040 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_single_signal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1030 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
mov    (%rbx),%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
mov    %r14d,%edi
not    %edi
shr    $0x1f,%edi
call   1030 <assert@plt>
mov    (%rbx),%eax
mov    (%r15),%rdi
lea    0x4(,%rax,4),%esi
mov    %eax,%ebp
add    $0x1,%ebp
call   1040 <realloc@plt>
mov    %rax,(%r15)
movslq (%rbx),%rcx
mov    %r14d,(%rax,%rcx,4)
mov    %ebp,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @add_single_signal(i32** %0, i32* %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32** %0, i32*** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32**, i32*** %4
%9 = icmp ne i32** null, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %5
%13 = icmp ne i32* null, %12
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 0
%18 = load i32, i32* %17
%19 = icmp sle i32 0, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %6
%23 = icmp sle i32 0, %22
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = load i32*, i32** %5
%27 = getelementptr inbounds i32, i32* %26, i64 0
%28 = load i32, i32* %27
%29 = add nsw i32 1, %28
store i32 %29, i32* %7
%30 = load i32**, i32*** %4
%31 = getelementptr inbounds i32*, i32** %30, i64 0
%32 = load i32*, i32** %31
%33 = load i32, i32* %7
%34 = sext i32 %33 to i64
%35 = mul i64 %34, 4
%36 = trunc i64 %35 to i32
%37 = call i64 @realloc(i32* %32, i32 %36)
%38 = inttoptr i64 %37 to i32*
%39 = load i32**, i32*** %4
%40 = getelementptr inbounds i32*, i32** %39, i64 0
store i32* %38, i32** %40
%41 = load i32, i32* %6
%42 = load i32**, i32*** %4
%43 = getelementptr inbounds i32*, i32** %42, i64 0
%44 = load i32*, i32** %43
%45 = load i32*, i32** %5
%46 = getelementptr inbounds i32, i32* %45, i64 0
%47 = load i32, i32* %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i32, i32* %44, i64 %48
store i32 %41, i32* %49
%50 = load i32, i32* %7
%51 = load i32*, i32** %5
%52 = getelementptr inbounds i32, i32* %51, i64 0
store i32 %50, i32* %52
ret void
}

LLVM IR (-O2):
define void @add_single_signal(i32** %0, i32* %1, i32 %2) {
%4 = icmp ne i32** %0, null
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp ne i32* %1, null
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = load i32, i32* %1
%11 = xor i32 %10, -1
%12 = lshr i32 %11, 31
%13 = tail call i32 @assert(i32 %12)
%14 = xor i32 %2, -1
%15 = lshr i32 %14, 31
%16 = tail call i32 @assert(i32 %15)
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
%19 = load i32*, i32** %0
%20 = shl i32 %18, 2
%21 = tail call i64 @realloc(i32* %19, i32 %20)
%22 = inttoptr i64 %21 to i32*
store i32* %22, i32** %0
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
store i32 %2, i32* %25
store i32 %18, i32* %1
ret void
}