#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 */
scalar_t__ ESRCH;
scalar_t__ errno;
int killpg(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(void) {
  if (killpg(999999, 0) != -1) {
    printf("killpg did not return -1 even though it was passed an invalid "
           "process group id.");
    return 2;
  }
  if (errno != ESRCH) {
    printf("killpg did not set errno to ESRCH even though it was passed an "
           "invalid signal number.");
    return 1;
  }
  printf("Test PASSED\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xf423f,%edi
xor    %esi,%esi
call   1040 <killpg@plt>
cmp    $0xffffffff,%eax
je     115c <main+0x3c>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    11a1 <main+0x81>
mov    0x2e7d(%rip),%rax
mov    (%rax),%rax
mov    0x2e63(%rip),%rcx
cmp    (%rcx),%rax
je     118e <main+0x6e>
lea    0xed3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <main+0x81>
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xf423f,%edi
xor    %esi,%esi
call   1050 <killpg@plt>
cmp    $0xffffffff,%eax
je     1155 <main+0x25>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%eax
pop    %rcx
ret
mov    0x2e84(%rip),%rax
mov    (%rax),%rax
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%rax
jne    117b <main+0x4b>
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [80 x i8] c"killpg did not return -1 even though it was passed an invalid process group id.\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.1 = [86 x i8] c"killpg did not set errno to ESRCH even though it was passed an invalid signal number.\00"
@.str.2 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @killpg(i32 999999, i32 0)
%3 = icmp ne i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %1
br label %14
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @ESRCH
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %14
12: ; preds = %6
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %14
14: ; preds = %12, %10, %4
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [80 x i8] c"killpg did not return -1 even though it was passed an invalid process group id.\00"
@errno = global i64 0
@ESRCH = global i64 0
@.str.1 = [86 x i8] c"killpg did not set errno to ESRCH even though it was passed an invalid signal number.\00"
@str = [12 x i8] c"Test PASSED\00"
define i32 @main() {
%1 = tail call i32 @killpg(i32 999999, i32 0)
%2 = icmp eq i32 %1, -1
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str, i64 0, i64 0))
br label %13
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = load i64, i64* @ESRCH
%8 = icmp eq i64 %6, %7
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([86 x i8], [86 x i8]* @.str.1, i64 0, i64 0))
br label %13
11: ; preds = %5
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %13
13: ; preds = %11, %9, %3
%14 = phi i32 [ 2, %3 ], [ 1, %9 ], [ 0, %11 ]
ret i32 %14
}