void wait_a_child(void) {
  int status;
  if (waitpid(-1, &status, 0) == -1)
    do {
      printf("System Panic !!! \n\n");
      printf("["
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/rajeshmajumdar/SillyCon/refs/heads/"
             "master/ASLR - Canary/server.c"
             ":"
             "39"
             "] %s "
             "wait_a_child returned -1 \n",
             __FUNCTION__);
      exit(-1);
    } while (0);
  ;
}


x86 assembly (clang, -O0):
<wait_a_child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xffffffff,%edi
lea    -0x4(%rbp),%rsi
xor    %edx,%edx
mov    $0x0,%al
call   1040 <waitpid@plt>
cmp    $0xffffffff,%eax
jne    1185 <wait_a_child+0x55>
jmp    1158 <wait_a_child+0x28>
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea7(%rip),%rdi
lea    0xf5e(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_a_child>:
push   %rax
lea    0x4(%rsp),%rsi
mov    $0xffffffff,%edi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <waitpid@plt>
cmp    $0xffffffff,%eax
je     115b <wait_a_child+0x1b>
pop    %rax
ret
lea    0xf69(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
lea    0xf49(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"System Panic !!! \0A\0A\00"
@.str.1 = [190 x i8] c"[/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rajeshmajumdar/SillyCon/refs/heads/master/ASLR - Canary/server.c:39] %s wait_a_child returned -1 \0A\00"
@__FUNCTION__.wait_a_child = [13 x i8] c"wait_a_child\00"
define void @wait_a_child() {
%1 = alloca i32
%2 = call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @waitpid to i32 (i32, i32*, i32, ...)*)(i32 -1, i32* %1, i32 0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %9
4: ; preds = %0
br label %5
5: ; preds = %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([190 x i8], [190 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.wait_a_child, i64 0, i64 0))
unreachable
8: ; No predecessors!
br label %9
9: ; preds = %8, %0
ret void
}

LLVM IR (-O2):
@.str.1 = [190 x i8] c"[/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/rajeshmajumdar/SillyCon/refs/heads/master/ASLR - Canary/server.c:39] %s wait_a_child returned -1 \0A\00"
@__FUNCTION__.wait_a_child = [13 x i8] c"wait_a_child\00"
@str = [19 x i8] c"System Panic !!! \0A\00"
define void @wait_a_child() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 (i32, i32*, i32, ...) bitcast (i32 (...)* @waitpid to i32 (i32, i32*, i32, ...)*)(i32 -1, i32* %1, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([190 x i8], [190 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @__FUNCTION__.wait_a_child, i64 0, i64 0))
unreachable
8: ; preds = %0
ret void
}