#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__ EINVAL;
scalar_t__ errno;
int /*<<< orphan*/ printf(char *);
int sigpause(int);
int main(void) {
  int return_value = 0;
  int result;
  return_value = sigpause(-1);
  if (return_value == -1) {
    if (errno == EINVAL) {
      printf("Test PASSED: sigpause returned -1 and "
             "set errno to EINVAL\n");
      result = 0;
    } else {
      printf("Test FAILED: sigpause did not set errno "
             "to EINVAL\n");
      result = 1;
    }
  } else {
    printf("Test FAILED: sigpause did not return -1\n");
    if (errno == EINVAL)
      printf("Test FAILED: sigpause did not set errno "
             "to EINVAL\n");
    result = 1;
  }
  if (result == 2)
    return 2;
  if (result == 1)
    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)
movl   $0x0,-0x8(%rbp)
mov    $0xffffffff,%edi
call   1040 <sigpause@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1197 <main+0x77>
mov    0x2e8c(%rip),%rax
mov    (%rax),%rax
mov    0x2e7a(%rip),%rcx
cmp    (%rcx),%rax
jne    117f <main+0x5f>
lea    0xe92(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
jmp    1192 <main+0x72>
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
jmp    11d0 <main+0xb0>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    0x2e24(%rip),%rcx
cmp    (%rcx),%rax
jne    11c9 <main+0xa9>
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
cmpl   $0x2,-0xc(%rbp)
jne    11e6 <main+0xc6>
movl   $0x2,-0x4(%rbp)
jmp    120f <main+0xef>
cmpl   $0x1,-0xc(%rbp)
jne    11fc <main+0xdc>
movl   $0x1,-0x4(%rbp)
jmp    120f <main+0xef>
lea    0xe94(%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   %rbx
mov    $0xffffffff,%edi
call   1040 <sigpause@plt>
cmp    $0xffffffff,%eax
je     1159 <main+0x39>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e9d(%rip),%rax
mov    (%rax),%rax
mov    0x2e8b(%rip),%rcx
mov    $0x1,%ebx
cmp    (%rcx),%rax
je     118b <main+0x6b>
jmp    1197 <main+0x77>
mov    0x2e80(%rip),%rax
mov    (%rax),%rax
mov    0x2e6e(%rip),%rcx
cmp    (%rcx),%rax
jne    1186 <main+0x66>
lea    0xef0(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
lea    0xea4(%rip),%rdi
jmp    1192 <main+0x72>
mov    $0x1,%ebx
lea    0xea2(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@errno = global i64 0
@EINVAL = global i64 0
@.str = [59 x i8] c"Test PASSED: sigpause returned -1 and set errno to EINVAL\0A\00"
@.str.1 = [51 x i8] c"Test FAILED: sigpause did not set errno to EINVAL\0A\00"
@.str.2 = [41 x i8] c"Test FAILED: sigpause did not return -1\0A\00"
@.str.3 = [13 x i8] c"Test PASSED\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%4 = call i32 @sigpause(i32 -1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %16
7: ; preds = %0
%8 = load i64, i64* @errno
%9 = load i64, i64* @EINVAL
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %15
13: ; preds = %7
%14 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %15
15: ; preds = %13, %11
br label %24
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%18 = load i64, i64* @errno
%19 = load i64, i64* @EINVAL
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %23
21: ; preds = %16
%22 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %16
store i32 1, i32* %3
br label %24
24: ; preds = %23, %15
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 2, i32* %1
br label %34
28: ; preds = %24
%29 = load i32, i32* %3
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %32
31: ; preds = %28
store i32 1, i32* %1
br label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %34
34: ; preds = %32, %31, %27
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@errno = global i64 0
@EINVAL = global i64 0
@str = [40 x i8] c"Test FAILED: sigpause did not return -1\00"
@str.4 = [12 x i8] c"Test PASSED\00"
@str.6 = [50 x i8] c"Test FAILED: sigpause did not set errno to EINVAL\00"
@str.7 = [58 x i8] c"Test PASSED: sigpause returned -1 and set errno to EINVAL\00"
define i32 @main() {
%1 = tail call i32 @sigpause(i32 -1)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %9
3: ; preds = %0
%4 = load i64, i64* @errno
%5 = load i64, i64* @EINVAL
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %14
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.7, i64 0, i64 0))
br label %14
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str, i64 0, i64 0))
%11 = load i64, i64* @errno
%12 = load i64, i64* @EINVAL
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %18
14: ; preds = %9, %3, %7
%15 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0), %7 ], [ getelementptr inbounds ([50 x i8], [50 x i8]* @str.6, i64 0, i64 0), %3 ], [ getelementptr inbounds ([50 x i8], [50 x i8]* @str.6, i64 0, i64 0), %9 ]
%16 = phi i32 [ 0, %7 ], [ 1, %3 ], [ 1, %9 ]
%17 = tail call i32 @puts(i8* dereferenceable(1) %15)
br label %18
18: ; preds = %14, %9
%19 = phi i32 [ 1, %9 ], [ %16, %14 ]
ret i32 %19
}