#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*/ mask2;
typedef int /*<<< orphan*/ mask1;

/* Variables and functions */
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ memset(char *, int, int);
int /*<<< orphan*/ printf(char *);
int main() {
  char mask1[8];
  char mask2[8];
  memset(mask1, 0, sizeof(mask1));
  memset(mask2, 0, sizeof(mask2));
  if (memcmp(mask1 + 4, mask2 + 4, sizeof(mask1) - 4) != 0) {
    printf("SYS_sigprocmask wrote beyond end of signal mask\n");
    return 1;
  }
  memset(mask1, 0xff, sizeof(mask1));
  memset(mask2, 0xff, sizeof(mask2));
  if (memcmp(mask1 + 4, mask2 + 4, sizeof(mask1) - 4) != 0) {
    printf("SYS_sigprocmask wrote beyond end of signal mask\n");
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0xc(%rbp),%rdi
add    $0x4,%rdi
lea    -0x14(%rbp),%rsi
add    $0x4,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     119b <main+0x6b>
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <main+0xd4>
lea    -0xc(%rbp),%rdi
mov    $0xff,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0x14(%rbp),%rdi
mov    $0xff,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    -0xc(%rbp),%rdi
add    $0x4,%rdi
lea    -0x14(%rbp),%rsi
add    $0x4,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     11fd <main+0xcd>
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1204 <main+0xd4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0x8(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
lea    0xc(%rsp),%r14
lea    0x4(%rsp),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    11b5 <main+0x85>
lea    0x8(%rsp),%rdi
mov    $0xff,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %rsp,%rdi
mov    $0xff,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11c6 <main+0x96>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [49 x i8] c"SYS_sigprocmask wrote beyond end of signal mask\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [8 x i8]
%3 = alloca [8 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 8)
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 8)
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds i8, i8* %8, i64 4
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds i8, i8* %10, i64 4
%12 = call i64 @memcmp(i8* %9, i8* %11, i32 4)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %30
16: ; preds = %0
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%18 = call i32 @memset(i8* %17, i32 255, i32 8)
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 255, i32 8)
%21 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%22 = getelementptr inbounds i8, i8* %21, i64 4
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%24 = getelementptr inbounds i8, i8* %23, i64 4
%25 = call i64 @memcmp(i8* %22, i8* %24, i32 4)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %30
29: ; preds = %16
store i32 0, i32* %1
br label %30
30: ; preds = %29, %27, %14
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@str.1 = [48 x i8] c"SYS_sigprocmask wrote beyond end of signal mask\00"
define i32 @main() {
%1 = alloca [8 x i8]
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = call i32 @memset(i8* %3, i32 0, i32 8)
%6 = call i32 @memset(i8* %4, i32 0, i32 8)
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %1, i64 0, i64 4
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%9 = call i64 @memcmp(i8* %7, i8* %8, i32 4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %0
%12 = call i32 @memset(i8* %3, i32 255, i32 8)
%13 = call i32 @memset(i8* %4, i32 255, i32 8)
%14 = call i64 @memcmp(i8* %7, i8* %8, i32 4)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %11, %0
%17 = phi i8* [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.1, i64 0, i64 0), %0 ], [ getelementptr inbounds ([48 x i8], [48 x i8]* @str.1, i64 0, i64 0), %11 ]
%18 = call i32 @puts(i8* dereferenceable(1) %17)
br label %19
19: ; preds = %16, %11
%20 = phi i32 [ 0, %11 ], [ 1, %16 ]
ret i32 %20
}