#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
scalar_t__ trap(int);
int main(int argc, char *argv[]) {
  if (0 == trap(2)) {
    char buf[32];
    while (1) {
      fread(buf, 32, 1, stdin);
    }
  } else {
    fprintf(stderr, "cannot trap SIGINT\n");
    exit(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x2,%edi
call   1050 <trap@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1194 <main+0x54>
jmp    1173 <main+0x33>
lea    -0x30(%rbp),%rdi
mov    0x2e6a(%rip),%rax
mov    (%rax),%ecx
mov    $0x20,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
jmp    1173 <main+0x33>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    $0x2,%edi
call   1050 <trap@plt>
test   %rax,%rax
jne    1177 <main+0x37>
mov    0x2e8b(%rip),%r14
mov    %rsp,%rbx
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
jmp    1160 <main+0x20>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"cannot trap SIGINT\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i64 @trap(i32 2)
%8 = icmp eq i64 0, %7
br i1 %8, label %9, label %14
9: ; preds = %2
br label %10
10: ; preds = %9, %10
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i32 @fread(i8* %11, i32 32, i32 1, i32 %12)
br label %10
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stdin = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"cannot trap SIGINT\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = tail call i64 @trap(i32 2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
br label %8
8: ; preds = %8, %6
%9 = load i32, i32* @stdin
%10 = call i32 @fread(i8* %7, i32 32, i32 1, i32 %9)
br label %8
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
}