#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;
int _NSIG;
scalar_t__ errno;
int /*<<< orphan*/ printf(char *, char *, ...);
int sighold(int);
int sigrelse(int);
char *strerror(scalar_t__);
int do_test(void) {
  int result = 0;
  int e;
  errno = 0;
  e = sighold(-1);
  if (e != -1) {
    printf("%s returned %d\n", "sighold (-1)", e);
    result = 1;
  } else if (errno != EINVAL) {
    printf("%s didn't set errno to EINVAL (%s instead)\n", "sighold (-1)",
           strerror(errno));
    result = 1;
  };
  errno = 0;
  e = sighold(_NSIG + 100);
  if (e != -1) {
    printf("%s returned %d\n", "sighold (_NSIG + 100)", e);
    result = 1;
  } else if (errno != EINVAL) {
    printf("%s didn't set errno to EINVAL (%s instead)\n",
           "sighold (_NSIG + 100)", strerror(errno));
    result = 1;
  };
  errno = 0;
  e = sigrelse(-1);
  if (e != -1) {
    printf("%s returned %d\n", "sigrelse (-1)", e);
    result = 1;
  } else if (errno != EINVAL) {
    printf("%s didn't set errno to EINVAL (%s instead)\n", "sigrelse (-1)",
           strerror(errno));
    result = 1;
  };
  errno = 0;
  e = sigrelse(_NSIG + 100);
  if (e != -1) {
    printf("%s returned %d\n", "sigrelse (_NSIG + 100)", e);
    result = 1;
  } else if (errno != EINVAL) {
    printf("%s didn't set errno to EINVAL (%s instead)\n",
           "sigrelse (_NSIG + 100)", strerror(errno));
    result = 1;
  };
  return result;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
movq   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1050 <sighold@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1198 <do_test+0x58>
mov    -0x8(%rbp),%edx
lea    0xe82(%rip),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <do_test+0xa5>
mov    0x2e39(%rip),%rax
mov    (%rax),%rax
mov    0x2e27(%rip),%rcx
cmp    (%rcx),%rax
je     11e0 <do_test+0xa0>
mov    0x2e1f(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rdx
lea    0xe52(%rip),%rdi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <do_test+0xa5>
mov    0x2dec(%rip),%rax
movq   $0x0,(%rax)
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
add    $0x64,%edi
call   1050 <sighold@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1235 <do_test+0xf5>
mov    -0x8(%rbp),%edx
lea    0xde5(%rip),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1282 <do_test+0x142>
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
mov    0x2d8a(%rip),%rcx
cmp    (%rcx),%rax
je     127d <do_test+0x13d>
mov    0x2d82(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rdx
lea    0xdb5(%rip),%rdi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1282 <do_test+0x142>
mov    0x2d4f(%rip),%rax
movq   $0x0,(%rax)
mov    $0xffffffff,%edi
call   1030 <sigrelse@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     12cb <do_test+0x18b>
mov    -0x8(%rbp),%edx
lea    0xd4f(%rip),%rdi
lea    0xda7(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1318 <do_test+0x1d8>
mov    0x2d06(%rip),%rax
mov    (%rax),%rax
mov    0x2cf4(%rip),%rcx
cmp    (%rcx),%rax
je     1313 <do_test+0x1d3>
mov    0x2cec(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rdx
lea    0xd1f(%rip),%rdi
lea    0xd5a(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1318 <do_test+0x1d8>
mov    0x2cb9(%rip),%rax
movq   $0x0,(%rax)
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
add    $0x64,%edi
call   1030 <sigrelse@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
je     1368 <do_test+0x228>
mov    -0x8(%rbp),%edx
lea    0xcb2(%rip),%rdi
lea    0xd18(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b5 <do_test+0x275>
mov    0x2c69(%rip),%rax
mov    (%rax),%rax
mov    0x2c57(%rip),%rcx
cmp    (%rcx),%rax
je     13b0 <do_test+0x270>
mov    0x2c4f(%rip),%rax
mov    (%rax),%rdi
call   1060 <strerror@plt>
mov    %rax,%rdx
lea    0xc82(%rip),%rdi
lea    0xccb(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13b5 <do_test+0x275>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %r15
push   %r14
push   %rbx
mov    0x2e8c(%rip),%r14
movq   $0x0,(%r14)
mov    $0xffffffff,%edi
call   1050 <sighold@plt>
cmp    $0xffffffff,%eax
je     117b <do_test+0x3b>
lea    0xe97(%rip),%rdi
lea    0xea0(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a9 <do_test+0x69>
mov    (%r14),%rdi
mov    0x2e4b(%rip),%rax
xor    %ebx,%ebx
cmp    (%rax),%rdi
je     11ae <do_test+0x6e>
call   1060 <strerror@plt>
lea    0xe85(%rip),%rdi
lea    0xe71(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
movq   $0x0,(%r14)
mov    0x2e34(%rip),%r15
mov    (%r15),%edi
add    $0x64,%edi
call   1050 <sighold@plt>
cmp    $0xffffffff,%eax
je     11e5 <do_test+0xa5>
lea    0xe2d(%rip),%rdi
lea    0xe6f(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1211 <do_test+0xd1>
mov    (%r14),%rdi
mov    0x2de1(%rip),%rax
cmp    (%rax),%rdi
je     1216 <do_test+0xd6>
call   1060 <strerror@plt>
lea    0xe1d(%rip),%rdi
lea    0xe42(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
movq   $0x0,(%r14)
mov    $0xffffffff,%edi
call   1030 <sigrelse@plt>
cmp    $0xffffffff,%eax
je     1245 <do_test+0x105>
lea    0xdcd(%rip),%rdi
lea    0xe25(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1271 <do_test+0x131>
mov    (%r14),%rdi
mov    0x2d81(%rip),%rax
cmp    (%rax),%rdi
je     1276 <do_test+0x136>
call   1060 <strerror@plt>
lea    0xdbd(%rip),%rdi
lea    0xdf8(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
movq   $0x0,(%r14)
mov    (%r15),%edi
add    $0x64,%edi
call   1030 <sigrelse@plt>
cmp    $0xffffffff,%eax
je     12a6 <do_test+0x166>
lea    0xd6c(%rip),%rdi
lea    0xdd2(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12d2 <do_test+0x192>
mov    (%r14),%rdi
mov    0x2d20(%rip),%rax
cmp    (%rax),%rdi
je     12d7 <do_test+0x197>
call   1060 <strerror@plt>
lea    0xd5c(%rip),%rdi
lea    0xda5(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [16 x i8] c"%s returned %d\0A\00"
@.str.1 = [13 x i8] c"sighold (-1)\00"
@EINVAL = global i64 0
@.str.2 = [44 x i8] c"%s didn't set errno to EINVAL (%s instead)\0A\00"
@_NSIG = global i32 0
@.str.3 = [22 x i8] c"sighold (_NSIG + 100)\00"
@.str.4 = [14 x i8] c"sigrelse (-1)\00"
@.str.5 = [23 x i8] c"sigrelse (_NSIG + 100)\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i64 0, i64* @errno
%3 = call i32 @sighold(i32 -1)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, -1
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* %2
%8 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7)
store i32 1, i32* %1
br label %18
9: ; preds = %0
%10 = load i64, i64* @errno
%11 = load i64, i64* @EINVAL
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i64, i64* @errno
%15 = call i8* @strerror(i64 %14)
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %15)
store i32 1, i32* %1
br label %17
17: ; preds = %13, %9
br label %18
18: ; preds = %17, %6
store i64 0, i64* @errno
%19 = load i32, i32* @_NSIG
%20 = add nsw i32 %19, 100
%21 = call i32 @sighold(i32 %20)
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i32, i32* %2
%26 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %25)
store i32 1, i32* %1
br label %36
27: ; preds = %18
%28 = load i64, i64* @errno
%29 = load i64, i64* @EINVAL
%30 = icmp ne i64 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %27
%32 = load i64, i64* @errno
%33 = call i8* @strerror(i64 %32)
%34 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %33)
store i32 1, i32* %1
br label %35
35: ; preds = %31, %27
br label %36
36: ; preds = %35, %24
store i64 0, i64* @errno
%37 = call i32 @sigrelse(i32 -1)
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, -1
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* %2
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %41)
store i32 1, i32* %1
br label %52
43: ; preds = %36
%44 = load i64, i64* @errno
%45 = load i64, i64* @EINVAL
%46 = icmp ne i64 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i64, i64* @errno
%49 = call i8* @strerror(i64 %48)
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %49)
store i32 1, i32* %1
br label %51
51: ; preds = %47, %43
br label %52
52: ; preds = %51, %40
store i64 0, i64* @errno
%53 = load i32, i32* @_NSIG
%54 = add nsw i32 %53, 100
%55 = call i32 @sigrelse(i32 %54)
store i32 %55, i32* %2
%56 = load i32, i32* %2
%57 = icmp ne i32 %56, -1
br i1 %57, label %58, label %61
58: ; preds = %52
%59 = load i32, i32* %2
%60 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %59)
store i32 1, i32* %1
br label %70
61: ; preds = %52
%62 = load i64, i64* @errno
%63 = load i64, i64* @EINVAL
%64 = icmp ne i64 %62, %63
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i64, i64* @errno
%67 = call i8* @strerror(i64 %66)
%68 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %67)
store i32 1, i32* %1
br label %69
69: ; preds = %65, %61
br label %70
70: ; preds = %69, %58
%71 = load i32, i32* %1
ret i32 %71
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [16 x i8] c"%s returned %d\0A\00"
@.str.1 = [13 x i8] c"sighold (-1)\00"
@EINVAL = global i64 0
@.str.2 = [44 x i8] c"%s didn't set errno to EINVAL (%s instead)\0A\00"
@_NSIG = global i32 0
@.str.3 = [22 x i8] c"sighold (_NSIG + 100)\00"
@.str.4 = [14 x i8] c"sigrelse (-1)\00"
@.str.5 = [23 x i8] c"sigrelse (_NSIG + 100)\00"
define i32 @do_test() {
store i64 0, i64* @errno
%1 = tail call i32 @sighold(i32 -1)
%2 = icmp eq i32 %1, -1
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %12
5: ; preds = %0
%6 = load i64, i64* @errno
%7 = load i64, i64* @EINVAL
%8 = icmp eq i64 %6, %7
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = tail call i8* @strerror(i64 %6)
%11 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %5, %9, %3
%13 = phi i32 [ 1, %3 ], [ 1, %9 ], [ 0, %5 ]
store i64 0, i64* @errno
%14 = load i32, i32* @_NSIG
%15 = add nsw i32 %14, 100
%16 = tail call i32 @sighold(i32 %15)
%17 = icmp eq i32 %16, -1
br i1 %17, label %20, label %18
18: ; preds = %12
%19 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %27
20: ; preds = %12
%21 = load i64, i64* @errno
%22 = load i64, i64* @EINVAL
%23 = icmp eq i64 %21, %22
br i1 %23, label %27, label %24
24: ; preds = %20
%25 = tail call i8* @strerror(i64 %21)
%26 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %20, %24, %18
%28 = phi i32 [ 1, %18 ], [ 1, %24 ], [ %13, %20 ]
store i64 0, i64* @errno
%29 = tail call i32 @sigrelse(i32 -1)
%30 = icmp eq i32 %29, -1
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %29)
br label %40
33: ; preds = %27
%34 = load i64, i64* @errno
%35 = load i64, i64* @EINVAL
%36 = icmp eq i64 %34, %35
br i1 %36, label %40, label %37
37: ; preds = %33
%38 = tail call i8* @strerror(i64 %34)
%39 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %33, %37, %31
%41 = phi i32 [ 1, %31 ], [ 1, %37 ], [ %28, %33 ]
store i64 0, i64* @errno
%42 = load i32, i32* @_NSIG
%43 = add nsw i32 %42, 100
%44 = tail call i32 @sigrelse(i32 %43)
%45 = icmp eq i32 %44, -1
br i1 %45, label %48, label %46
46: ; preds = %40
%47 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %44)
br label %55
48: ; preds = %40
%49 = load i64, i64* @errno
%50 = load i64, i64* @EINVAL
%51 = icmp eq i64 %49, %50
br i1 %51, label %55, label %52
52: ; preds = %48
%53 = tail call i8* @strerror(i64 %49)
%54 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %48, %52, %46
%56 = phi i32 [ 1, %46 ], [ 1, %52 ], [ %41, %48 ]
ret i32 %56
}