#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 */
struct sigaction {
  int /*<<< orphan*/ sa_handler;
  int /*<<< orphan*/ sa_mask;
};
typedef int /*<<< orphan*/ act;

/* Variables and functions */
int /*<<< orphan*/ SIGPIPE;
int /*<<< orphan*/ SIG_IGN;
int errno;
int /*<<< orphan*/ logError(char *, int, int, char *);
int /*<<< orphan*/ memset(struct sigaction *, int /*<<< orphan*/, int);
scalar_t__ sigaction(int /*<<< orphan*/, struct sigaction *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ sigemptyset(int /*<<< orphan*/ *);
char *strerror(int);
int ignore_signal_pipe() {
  struct sigaction act;
  memset(&act, 0, sizeof(act));
  sigemptyset(&act.sa_mask);
  act.sa_handler = SIG_IGN;
  if (sigaction(SIGPIPE, &act, NULL) < 0) {
    logError("file: "
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/master/"
             "fastdfs-5.01/common/shared_func.c"
             ", line: %d, "
             "call sigaction fail, errno: %d, error info: %s",
             2127, errno,
             (strerror(errno) != NULL ? strerror(errno) : "Unkown error"));
    return errno;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ignore_signal_pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
call   1060 <sigemptyset@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1030 <sigaction@plt>
cmp    $0x0,%rax
jge    1215 <ignore_signal_pipe+0xc5>
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
cmp    $0x0,%rax
je     11dc <ignore_signal_pipe+0x8c>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,-0x20(%rbp)
jmp    11ec <ignore_signal_pipe+0x9c>
lea    0xefc(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    11ec <ignore_signal_pipe+0x9c>
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
lea    0xe06(%rip),%rdi
mov    $0x84f,%esi
call   1040 <logError@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121c <ignore_signal_pipe+0xcc>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ignore_signal_pipe>:
push   %r14
push   %rbx
push   %rax
mov    %rsp,%r14
xor    %ebx,%ebx
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    0x4(%rsp),%rdi
call   1060 <sigemptyset@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1030 <sigaction@plt>
test   %rax,%rax
jns    11d6 <ignore_signal_pipe+0x86>
mov    0x2e33(%rip),%r14
mov    (%r14),%ebx
mov    %ebx,%edi
call   1070 <strerror@plt>
test   %rax,%rax
je     11b9 <ignore_signal_pipe+0x69>
mov    (%r14),%edi
call   1070 <strerror@plt>
mov    %rax,%rcx
jmp    11c0 <ignore_signal_pipe+0x70>
lea    0xf1f(%rip),%rcx
lea    0xe39(%rip),%rdi
mov    $0x84f,%esi
mov    %ebx,%edx
call   1040 <logError@plt>
mov    (%r14),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.sigaction = type { i32, i32 }
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [223 x i8] c"file: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/master/fastdfs-5.01/common/shared_func.c, line: %d, call sigaction fail, errno: %d, error info: %s\00"
@errno = global i32 0
@.str.1 = [13 x i8] c"Unkown error\00"
define i32 @ignore_signal_pipe() {
%1 = alloca i32
%2 = alloca %struct.sigaction
%3 = call i32 @memset(%struct.sigaction* %2, i32 0, i32 8)
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 1
%5 = call i32 @sigemptyset(i32* %4)
%6 = load i32, i32* @SIG_IGN
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %2, i32 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* @SIGPIPE
%9 = call i64 @sigaction(i32 %8, %struct.sigaction* %2, i32* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %0
%12 = load i32, i32* @errno
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
br label %20
19: ; preds = %11
br label %20
20: ; preds = %19, %16
%21 = phi i8* [ %18, %16 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %19 ]
%22 = call i32 @logError(i8* getelementptr inbounds ([223 x i8], [223 x i8]* @.str, i64 0, i64 0), i32 2127, i32 %12, i8* %21)
%23 = load i32, i32* @errno
store i32 %23, i32* %1
br label %25
24: ; preds = %0
store i32 0, i32* %1
br label %25
25: ; preds = %24, %20
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
%struct.sigaction = type { i32, i32 }
@SIG_IGN = global i32 0
@SIGPIPE = global i32 0
@.str = [223 x i8] c"file: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/fatedier/studies/refs/heads/master/fastdfs-5.01/common/shared_func.c, line: %d, call sigaction fail, errno: %d, error info: %s\00"
@errno = global i32 0
@.str.1 = [13 x i8] c"Unkown error\00"
define i32 @ignore_signal_pipe() {
%1 = alloca %struct.sigaction
%2 = bitcast %struct.sigaction* %1 to i8*
%3 = call i32 @memset(%struct.sigaction* %1, i32 0, i32 8)
%4 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 1
%5 = call i32 @sigemptyset(i32* %4)
%6 = load i32, i32* @SIG_IGN
%7 = getelementptr inbounds %struct.sigaction, %struct.sigaction* %1, i64 0, i32 0
store i32 %6, i32* %7
%8 = load i32, i32* @SIGPIPE
%9 = call i64 @sigaction(i32 %8, %struct.sigaction* %1, i32* null)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %0
%12 = load i32, i32* @errno
%13 = call i8* @strerror(i32 %12)
%14 = icmp eq i8* %13, null
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = load i32, i32* @errno
%17 = call i8* @strerror(i32 %16)
br label %18
18: ; preds = %11, %15
%19 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), %11 ]
%20 = call i32 @logError(i8* getelementptr inbounds ([223 x i8], [223 x i8]* @.str, i64 0, i64 0), i32 2127, i32 %12, i8* %19)
%21 = load i32, i32* @errno
br label %22
22: ; preds = %0, %18
%23 = phi i32 [ %21, %18 ], [ 0, %0 ]
ret i32 %23
}