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

/* Variables and functions */
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ WNOHANG;
int /*<<< orphan*/ _debug(char *, int, int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
void sigchld_handler(int s) {
  int status;
  pid_t rc;
  _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/ForgotFun/wifidog/refs/heads/master/src/"
         "gateway.c",
         259, LOG_DEBUG, "Handler for SIGCHLD called. Trying to reap a child");
  rc = waitpid(-1, &status, WNOHANG);
  _debug("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/ForgotFun/wifidog/refs/heads/master/src/"
         "gateway.c",
         263, LOG_DEBUG, "Handler for SIGCHLD reaped child PID %d", rc);
}


x86 assembly (clang, -O0):
<sigchld_handler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
lea    0xec5(%rip),%rdi
mov    $0x103,%esi
lea    0xf45(%rip),%rcx
mov    $0x0,%al
call   1030 <_debug@plt>
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffff,%edi
lea    -0x8(%rbp),%rsi
call   1040 <waitpid@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%edx
mov    -0xc(%rbp),%r8d
lea    0xe84(%rip),%rdi
mov    $0x107,%esi
lea    0xf37(%rip),%rcx
mov    $0x0,%al
call   1030 <_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigchld_handler>:
push   %r14
push   %rbx
push   %rax
mov    0x2ead(%rip),%rbx
mov    (%rbx),%edx
lea    0xecc(%rip),%r14
lea    0xf51(%rip),%rcx
mov    %r14,%rdi
mov    $0x103,%esi
xor    %eax,%eax
call   1030 <_debug@plt>
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rsi
mov    $0xffffffff,%edi
call   1040 <waitpid@plt>
mov    (%rbx),%edx
lea    0xf54(%rip),%rcx
mov    %r14,%rdi
mov    $0x107,%esi
mov    %eax,%r8d
xor    %eax,%eax
call   1030 <_debug@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ForgotFun/wifidog/refs/heads/master/src/gateway.c\00"
@LOG_DEBUG = global i32 0
@.str.1 = [51 x i8] c"Handler for SIGCHLD called. Trying to reap a child\00"
@WNOHANG = global i32 0
@.str.2 = [40 x i8] c"Handler for SIGCHLD reaped child PID %d\00"
define void @sigchld_handler(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* @LOG_DEBUG
%6 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 259, i32 %5, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @WNOHANG
%8 = call i32 @waitpid(i32 -1, i32* %3, i32 %7)
store i32 %8, i32* %4
%9 = load i32, i32* @LOG_DEBUG
%10 = load i32, i32* %4
%11 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 263, i32 %9, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret void
}

LLVM IR (-O2):
@.str = [140 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/ForgotFun/wifidog/refs/heads/master/src/gateway.c\00"
@LOG_DEBUG = global i32 0
@.str.1 = [51 x i8] c"Handler for SIGCHLD called. Trying to reap a child\00"
@WNOHANG = global i32 0
@.str.2 = [40 x i8] c"Handler for SIGCHLD reaped child PID %d\00"
define void @sigchld_handler(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @LOG_DEBUG
%5 = tail call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 259, i32 %4, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @WNOHANG
%7 = call i32 @waitpid(i32 -1, i32* %2, i32 %6)
%8 = load i32, i32* @LOG_DEBUG
%9 = call i32 (i8*, i32, i32, i8*, ...) @_debug(i8* getelementptr inbounds ([140 x i8], [140 x i8]* @.str, i64 0, i64 0), i32 263, i32 %8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i32 %7)
ret void
}