#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 scalar_t__ cstat;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int WTERMSIG(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void print_termsig(FILE *fp, int cstat) {
  fprintf(fp, "Terminated, signal %d", WTERMSIG(cstat));
  if (((cstat)&0200))
    fprintf(fp, " (core dumped)");
  fprintf(fp, "\n");
}


x86 assembly (clang, -O0):
<print_termsig>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <WTERMSIG@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%edx
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1176 <print_termsig+0x56>
mov    -0x8(%rbp),%rdi
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_termsig>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1050 <WTERMSIG@plt>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
test   $0x80,%bpl
je     1181 <print_termsig+0x41>
lea    0xea7(%rip),%rdi
mov    $0xe,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1060 <fwrite@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
@.str = [22 x i8] c"Terminated, signal %d\00"
@.str.1 = [15 x i8] c" (core dumped)\00"
@.str.2 = [2 x i8] c"\0A\00"
define void @print_termsig(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32*, i32** %3
%6 = load i32, i32* %4
%7 = call i32 @WTERMSIG(i32 %6)
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %4
%10 = and i32 %9, 128
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32*, i32** %3
%14 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %12, %2
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"Terminated, signal %d\00"
@.str.1 = [15 x i8] c" (core dumped)\00"
define void @print_termsig(i32* nocapture %0, i32 %1) {
%3 = tail call i32 @WTERMSIG(i32 %1)
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = and i32 %1, 128
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64 14, i64 1, i32* %0)
br label %9
9: ; preds = %7, %2
%10 = tail call i32 @fputc(i32 10, i32* %0)
ret void
}