#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 SIGINT;
int SIGTERM;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ setStatus(char *);
void sigHandler(int signo) {
  if (signo == SIGTERM || signo == SIGINT) {
    printf("Receiving term\n");
    setStatus("Powering off              ");
    exit(0);
  } else {
    printf("got signo: %d\n", signo);
  }
}


x86 assembly (clang, -O0):
<sigHandler>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%eax
je     115f <sigHandler+0x2f>
mov    -0x4(%rbp),%eax
mov    0x2e91(%rip),%rcx
cmp    (%rcx),%eax
jne    1180 <sigHandler+0x50>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1040 <setStatus@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sigHandler>:
push   %rax
mov    0x2e98(%rip),%rax
cmp    %edi,(%rax)
je     1168 <sigHandler+0x28>
mov    %edi,%esi
mov    0x2e93(%rip),%rax
cmp    %edi,(%rax)
je     1168 <sigHandler+0x28>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1040 <printf@plt>
lea    0xebb(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
call   1050 <setStatus@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@SIGTERM = global i32 0
@SIGINT = global i32 0
@.str = [16 x i8] c"Receiving term\0A\00"
@.str.1 = [27 x i8] c"Powering off \00"
@.str.2 = [15 x i8] c"got signo: %d\0A\00"
define void @sigHandler(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* @SIGTERM
%5 = icmp eq i32 %3, %4
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = load i32, i32* %2
%8 = load i32, i32* @SIGINT
%9 = icmp eq i32 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %6, %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @setStatus(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %6
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14
ret void
}

LLVM IR (-O2):
@SIGTERM = global i32 0
@SIGINT = global i32 0
@.str.1 = [27 x i8] c"Powering off \00"
@.str.2 = [15 x i8] c"got signo: %d\0A\00"
@str = [15 x i8] c"Receiving term\00"
define void @sigHandler(i32 %0) {
%2 = load i32, i32* @SIGTERM
%3 = icmp eq i32 %2, %0
%4 = load i32, i32* @SIGINT
%5 = icmp eq i32 %4, %0
%6 = select i1 %3, i1 true, i1 %5
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @setStatus(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %0)
ret void
}