int main(void) {
  int err;
  err = prctl(34, 0, 0, 0, 0, 0);
  if (err < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_GET"),
        exit(1);
  if (err != 2)
    printf("FAILURE: "
           "starting policy not default"
           "\n"),
        exit(1);
  if (prctl(33, 1, 0, 0, 0, 0) < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_SET late"),
        exit(1);
  test(0);
  if (prctl(33, 1, 1, 0, 0, 0) < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_SET early"),
        exit(1);
  test(1);
  err = prctl(34, 0, 0, 0, 0, 0);
  if (err < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_GET"),
        exit(1);
  if (err != 1)
    printf("FAILURE: "
           "get mode not early after setting"
           "\n"),
        exit(1);
  if (prctl(33, 0, 0, 0, 0, 0) < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_CLEAR"),
        exit(1);
  err = prctl(34, 0, 0, 0, 0, 0);
  if (err < 0)
    perror("FAILURE: "
           "PR_MCE_KILL_GET"),
        exit(1);
  if (err != 2)
    printf("FAILURE: "
           "ending policy not default"
           "\n"),
        exit(1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x22,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    119f <main+0x4f>
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
je     11c1 <main+0x71>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x21,%edi
mov    $0x1,%esi
xor    %r9d,%r9d
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
cmp    $0x0,%eax
jge    11ff <main+0xaf>
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %edi,%edi
mov    $0x0,%al
call   1070 <test@plt>
mov    $0x21,%edi
mov    $0x1,%edx
xor    %r9d,%r9d
mov    %edx,%esi
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
cmp    $0x0,%eax
jge    1245 <main+0xf5>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x1,%edi
mov    $0x0,%al
call   1070 <test@plt>
mov    $0x22,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1291 <main+0x141>
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x1,-0x8(%rbp)
je     12b3 <main+0x163>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x21,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
cmp    $0x0,%eax
jge    12ef <main+0x19f>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    $0x22,%edi
xor    %r9d,%r9d
mov    %r9d,%esi
mov    %r9d,%edx
mov    %r9d,%ecx
mov    %r9d,%r8d
mov    $0x0,%al
call   1040 <prctl@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    132f <main+0x1df>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
je     1351 <main+0x201>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x22,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     123a <main+0xea>
cmp    $0x2,%eax
jne    1243 <main+0xf3>
mov    $0x21,%edi
mov    $0x1,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     124c <main+0xfc>
xor    %edi,%edi
xor    %eax,%eax
call   1070 <test@plt>
mov    $0x21,%edi
mov    $0x1,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     1255 <main+0x105>
mov    $0x1,%edi
xor    %eax,%eax
call   1070 <test@plt>
mov    $0x22,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     123a <main+0xea>
cmp    $0x1,%eax
jne    125e <main+0x10e>
mov    $0x21,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     1267 <main+0x117>
mov    $0x22,%edi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   1040 <prctl@plt>
test   %eax,%eax
js     123a <main+0xea>
cmp    $0x2,%eax
jne    127f <main+0x12f>
xor    %eax,%eax
pop    %rcx
ret
lea    0xdbf(%rip),%rdi
jmp    126e <main+0x11e>
lea    0xe74(%rip),%rdi
jmp    1286 <main+0x136>
lea    0xdc6(%rip),%rdi
jmp    126e <main+0x11e>
lea    0xddb(%rip),%rdi
jmp    126e <main+0x11e>
lea    0xe2f(%rip),%rdi
jmp    1286 <main+0x136>
lea    0xde8(%rip),%rdi
xor    %eax,%eax
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"FAILURE: PR_MCE_KILL_GET\00"
@.str.1 = [38 x i8] c"FAILURE: starting policy not default\0A\00"
@.str.2 = [30 x i8] c"FAILURE: PR_MCE_KILL_SET late\00"
@.str.3 = [31 x i8] c"FAILURE: PR_MCE_KILL_SET early\00"
@.str.4 = [43 x i8] c"FAILURE: get mode not early after setting\0A\00"
@.str.5 = [27 x i8] c"FAILURE: PR_MCE_KILL_CLEAR\00"
@.str.6 = [36 x i8] c"FAILURE: ending policy not default\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
unreachable
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
unreachable
13: ; preds = %8
%14 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 1, i32 0, i32 0, i32 0, i32 0)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
unreachable
18: ; preds = %13
%19 = call i32 (i32, ...) bitcast (i32 (...)* @test to i32 (i32, ...)*)(i32 0)
%20 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 1, i32 1, i32 0, i32 0, i32 0)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
unreachable
24: ; preds = %18
%25 = call i32 (i32, ...) bitcast (i32 (...)* @test to i32 (i32, ...)*)(i32 1)
%26 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
store i32 %26, i32* %2
%27 = load i32, i32* %2
%28 = icmp slt i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
unreachable
31: ; preds = %24
%32 = load i32, i32* %2
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
unreachable
36: ; preds = %31
%37 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 0, i32 0, i32 0, i32 0, i32 0)
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
unreachable
41: ; preds = %36
%42 = call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
store i32 %42, i32* %2
%43 = load i32, i32* %2
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
unreachable
47: ; preds = %41
%48 = load i32, i32* %2
%49 = icmp ne i32 %48, 2
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
unreachable
52: ; preds = %47
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"FAILURE: PR_MCE_KILL_GET\00"
@.str.2 = [30 x i8] c"FAILURE: PR_MCE_KILL_SET late\00"
@.str.3 = [31 x i8] c"FAILURE: PR_MCE_KILL_SET early\00"
@.str.5 = [27 x i8] c"FAILURE: PR_MCE_KILL_CLEAR\00"
@str = [35 x i8] c"FAILURE: ending policy not default\00"
@str.7 = [42 x i8] c"FAILURE: get mode not early after setting\00"
@str.8 = [37 x i8] c"FAILURE: starting policy not default\00"
define i32 @main() {
%1 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
5: ; preds = %0
%6 = icmp eq i32 %1, 2
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.8, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
9: ; preds = %5
%10 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 1, i32 0, i32 0, i32 0, i32 0)
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
14: ; preds = %9
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @test to i32 (i32, ...)*)(i32 0)
%16 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 1, i32 1, i32 0, i32 0, i32 0)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
20: ; preds = %14
%21 = tail call i32 (i32, ...) bitcast (i32 (...)* @test to i32 (i32, ...)*)(i32 1)
%22 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
26: ; preds = %20
%27 = icmp eq i32 %22, 1
br i1 %27, label %30, label %28
28: ; preds = %26
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.7, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
30: ; preds = %26
%31 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 33, i32 0, i32 0, i32 0, i32 0, i32 0)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
35: ; preds = %30
%36 = tail call i32 (i32, i32, i32, i32, i32, i32, ...) bitcast (i32 (...)* @prctl to i32 (i32, i32, i32, i32, i32, i32, ...)*)(i32 34, i32 0, i32 0, i32 0, i32 0, i32 0)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = tail call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
40: ; preds = %35
%41 = icmp eq i32 %36, 2
br i1 %41, label %44, label %42
42: ; preds = %40
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
tail call void @exit(i32 1)
unreachable
44: ; preds = %40
ret i32 0
}