#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*/ str2;
typedef int /*<<< orphan*/ str1;

/* Variables and functions */
int /*<<< orphan*/ PTHREAD_CANCEL_DISABLE;
int /*<<< orphan*/ PTHREAD_CANCEL_ENABLE;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ pthread_cancel(int /*<<< orphan*/);
int /*<<< orphan*/ pthread_self();
int /*<<< orphan*/ pthread_setcancelstate(int /*<<< orphan*/,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
int main(void) {
  char str1[] = "You should see this.\n";
  char str2[] = "You should not see this.\n";
  pthread_cancel(pthread_self());
  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
  write(STDOUT_FILENO, str1, sizeof(str1) - 1);
  pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  write(STDOUT_FILENO, str2, sizeof(str2) - 1);
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe8f(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe87(%rip),%ax
mov    %ax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <pthread_self@plt>
mov    %eax,%edi
call   1070 <pthread_cancel@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <pthread_setcancelstate@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
lea    -0x20(%rbp),%rsi
mov    $0x15,%edx
call   1030 <write@plt>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <pthread_setcancelstate@plt>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
mov    $0x19,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0xa2e7369687420,%rax
mov    %rax,0xe(%rsp)
movups 0xeb4(%rip),%xmm0
movups %xmm0,0x2a(%rsp)
movaps 0xe9e(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
xor    %eax,%eax
call   1050 <pthread_self@plt>
mov    %eax,%edi
call   1070 <pthread_cancel@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <pthread_setcancelstate@plt>
mov    0x2e44(%rip),%rbx
mov    (%rbx),%edi
mov    %rsp,%rsi
mov    $0x15,%edx
call   1030 <write@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1040 <pthread_setcancelstate@plt>
mov    (%rbx),%edi
lea    0x20(%rsp),%rsi
mov    $0x19,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@__const.main.str1 = [22 x i8] c"You should see this.\0A\00"
@__const.main.str2 = [26 x i8] c"You should not see this.\0A\00"
@PTHREAD_CANCEL_DISABLE = global i32 0
@STDOUT_FILENO = global i32 0
@PTHREAD_CANCEL_ENABLE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [22 x i8]
%3 = alloca [26 x i8]
store i32 0, i32* %1
%4 = bitcast [22 x i8]* %2 to i8*
%5 = bitcast [26 x i8]* %3 to i8*
%6 = call i32 (...) @pthread_self()
%7 = call i32 @pthread_cancel(i32 %6)
%8 = load i32, i32* @PTHREAD_CANCEL_DISABLE
%9 = call i32 @pthread_setcancelstate(i32 %8, i32* null)
%10 = load i32, i32* @STDOUT_FILENO
%11 = getelementptr inbounds [22 x i8], [22 x i8]* %2, i64 0, i64 0
%12 = call i32 @write(i32 %10, i8* %11, i32 21)
%13 = load i32, i32* @PTHREAD_CANCEL_ENABLE
%14 = call i32 @pthread_setcancelstate(i32 %13, i32* null)
%15 = load i32, i32* @STDOUT_FILENO
%16 = getelementptr inbounds [26 x i8], [26 x i8]* %3, i64 0, i64 0
%17 = call i32 @write(i32 %15, i8* %16, i32 25)
%18 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@__const.main.str1 = [22 x i8] c"You should see this.\0A\00"
@__const.main.str2 = [26 x i8] c"You should not see this.\0A\00"
@PTHREAD_CANCEL_DISABLE = global i32 0
@STDOUT_FILENO = global i32 0
@PTHREAD_CANCEL_ENABLE = global i32 0
define i32 @main() {
%1 = alloca [22 x i8]
%2 = alloca [26 x i8]
%3 = getelementptr inbounds [22 x i8], [22 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [26 x i8], [26 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @pthread_self()
%6 = tail call i32 @pthread_cancel(i32 %5)
%7 = load i32, i32* @PTHREAD_CANCEL_DISABLE
%8 = tail call i32 @pthread_setcancelstate(i32 %7, i32* null)
%9 = load i32, i32* @STDOUT_FILENO
%10 = call i32 @write(i32 %9, i8* %3, i32 21)
%11 = load i32, i32* @PTHREAD_CANCEL_ENABLE
%12 = tail call i32 @pthread_setcancelstate(i32 %11, i32* null)
%13 = load i32, i32* @STDOUT_FILENO
%14 = call i32 @write(i32 %13, i8* %4, i32 25)
%15 = tail call i32 @exit(i32 1)
unreachable
}