#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*/ sigset_t;

/* Variables and functions */
int /*<<< orphan*/ SIGINT;
int /*<<< orphan*/ SIG_BLOCK;
int /*<<< orphan*/ SIG_UNBLOCK;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sigaddset(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
int /*<<< orphan*/ sigprocmask(int /*<<< orphan*/, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ sleep(int);
int main() {
  sigset_t set;
  sigprocmask(SIG_BLOCK, NULL, &set);
  sigaddset(&set, SIGINT);
  sigprocmask(SIG_BLOCK, &set, NULL);
  for (int i = 0; i < 5; i++) {
    printf("hello\n");
    sleep(1);
  }
  sigemptyset(&set);
  sigaddset(&set, SIGINT);
  sigprocmask(SIG_UNBLOCK, &set, NULL);
  while (1) {
    printf("hehheheheh");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
lea    -0x8(%rbp),%rdx
call   1030 <sigprocmask@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x5,-0xc(%rbp)
jge    11d2 <main+0x82>
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a4 <main+0x54>
lea    -0x8(%rbp),%rdi
call   1050 <sigemptyset@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
lea    -0x8(%rbp),%rdi
call   1070 <sigaddset@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
lea    -0x8(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigprocmask@plt>
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <main+0xb3>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e60(%rip),%rbx
mov    (%rbx),%edi
lea    0xc(%rsp),%r14
xor    %esi,%esi
mov    %r14,%rdx
call   1030 <sigprocmask@plt>
mov    0x2e58(%rip),%r15
mov    (%r15),%esi
mov    %r14,%rdi
call   1080 <sigaddset@plt>
mov    (%rbx),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
lea    0xe65(%rip),%rbx
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    %r14,%rdi
call   1060 <sigemptyset@plt>
mov    (%r15),%esi
mov    %r14,%rdi
call   1080 <sigaddset@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigprocmask@plt>
lea    0xdd3(%rip),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <printf@plt>
jmp    1230 <main+0xd0>

LLVM IR (-O0):
@SIG_BLOCK = global i32 0
@SIGINT = global i32 0
@.str = [7 x i8] c"hello\0A\00"
@SIG_UNBLOCK = global i32 0
@.str.1 = [11 x i8] c"hehheheheh\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @SIG_BLOCK
%5 = call i32 @sigprocmask(i32 %4, i32* null, i32* %2)
%6 = load i32, i32* @SIGINT
%7 = call i32 @sigaddset(i32* %2, i32 %6)
%8 = load i32, i32* @SIG_BLOCK
%9 = call i32 @sigprocmask(i32 %8, i32* %2, i32* null)
store i32 0, i32* %3
br label %10
10: ; preds = %16, %0
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @sleep(i32 1)
br label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %10
19: ; preds = %10
%20 = call i32 @sigemptyset(i32* %2)
%21 = load i32, i32* @SIGINT
%22 = call i32 @sigaddset(i32* %2, i32 %21)
%23 = load i32, i32* @SIG_UNBLOCK
%24 = call i32 @sigprocmask(i32 %23, i32* %2, i32* null)
br label %25
25: ; preds = %19, %25
%26 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %25
}

LLVM IR (-O2):
@SIG_BLOCK = global i32 0
@SIGINT = global i32 0
@SIG_UNBLOCK = global i32 0
@.str.1 = [11 x i8] c"hehheheheh\00"
@str = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = load i32, i32* @SIG_BLOCK
%4 = call i32 @sigprocmask(i32 %3, i32* null, i32* %1)
%5 = load i32, i32* @SIGINT
%6 = call i32 @sigaddset(i32* %1, i32 %5)
%7 = load i32, i32* @SIG_BLOCK
%8 = call i32 @sigprocmask(i32 %7, i32* %1, i32* null)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%10 = call i32 @sleep(i32 1)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%12 = call i32 @sleep(i32 1)
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%14 = call i32 @sleep(i32 1)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%16 = call i32 @sleep(i32 1)
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%18 = call i32 @sleep(i32 1)
%19 = call i32 @sigemptyset(i32* %1)
%20 = load i32, i32* @SIGINT
%21 = call i32 @sigaddset(i32* %1, i32 %20)
%22 = load i32, i32* @SIG_UNBLOCK
%23 = call i32 @sigprocmask(i32 %22, i32* %1, i32* null)
br label %24
24: ; preds = %24, %0
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %24
}