#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 */
scalar_t__ SIGINT;
scalar_t__ SIGQUIT;
scalar_t__ WEXITSTATUS(int);
scalar_t__ WIFEXITED(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WTERMSIG(int);
int /*<<< orphan*/ raise(scalar_t__);
int system(char const *);
int xsystem(const char *cmd) {
  int status;
  status = system(cmd);
  if (status != -1) {
    if (WIFSIGNALED(status)) {
      if (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT)
        raise(WTERMSIG(status));
    } else if (WIFEXITED(status)) {
      if (WEXITSTATUS(status) == SIGINT + 128 ||
          WEXITSTATUS(status) == SIGQUIT + 128)
        raise(WEXITSTATUS(status) - 128);
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<xsystem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
je     1255 <xsystem+0xf5>
mov    -0xc(%rbp),%edi
call   1050 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11d9 <xsystem+0x79>
mov    -0xc(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%rax
je     11c4 <xsystem+0x64>
mov    -0xc(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    0x2e25(%rip),%rcx
cmp    (%rcx),%rax
jne    11d4 <xsystem+0x74>
mov    -0xc(%rbp),%edi
call   1060 <WTERMSIG@plt>
mov    %rax,%rdi
call   1030 <raise@plt>
jmp    1250 <xsystem+0xf0>
mov    -0xc(%rbp),%edi
call   1080 <WIFEXITED@plt>
cmp    $0x0,%rax
je     124b <xsystem+0xeb>
mov    -0xc(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    0x2dee(%rip),%rcx
mov    (%rcx),%rcx
add    $0x80,%rcx
cmp    %rcx,%rax
je     122f <xsystem+0xcf>
mov    -0xc(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    0x2dc4(%rip),%rcx
mov    (%rcx),%rcx
add    $0x80,%rcx
cmp    %rcx,%rax
jne    1246 <xsystem+0xe6>
mov    -0xc(%rbp),%edi
call   1070 <WEXITSTATUS@plt>
mov    %rax,%rdi
sub    $0x80,%rdi
call   1030 <raise@plt>
jmp    124b <xsystem+0xeb>
jmp    1250 <xsystem+0xf0>
jmp    1255 <xsystem+0xf5>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xsystem>:
push   %rbx
call   1040 <system@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1200 <xsystem+0xa0>
mov    %ebx,%edi
call   1050 <WIFSIGNALED@plt>
mov    %ebx,%edi
test   %rax,%rax
je     11af <xsystem+0x4f>
call   1060 <WTERMSIG@plt>
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%rax
je     11a3 <xsystem+0x43>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
mov    0x2e42(%rip),%rcx
cmp    (%rcx),%rax
jne    1200 <xsystem+0xa0>
mov    %ebx,%edi
call   1060 <WTERMSIG@plt>
mov    %rax,%rdi
jmp    11fb <xsystem+0x9b>
call   1080 <WIFEXITED@plt>
test   %rax,%rax
je     1200 <xsystem+0xa0>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
mov    0x2e21(%rip),%rcx
mov    (%rcx),%rcx
sub    $0xffffffffffffff80,%rcx
cmp    %rcx,%rax
je     11ed <xsystem+0x8d>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
mov    0x2dff(%rip),%rcx
mov    (%rcx),%rcx
sub    $0xffffffffffffff80,%rcx
cmp    %rcx,%rax
jne    1200 <xsystem+0xa0>
mov    %ebx,%edi
call   1070 <WEXITSTATUS@plt>
mov    %rax,%rdi
add    $0xffffffffffffff80,%rdi
call   1030 <raise@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@SIGINT = global i64 0
@SIGQUIT = global i64 0
define i32 @xsystem(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @system(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, -1
br i1 %7, label %8, label %51
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i64 @WIFSIGNALED(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i64 @WTERMSIG(i32 %13)
%15 = load i64, i64* @SIGINT
%16 = icmp eq i64 %14, %15
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i32, i32* %3
%19 = call i64 @WTERMSIG(i32 %18)
%20 = load i64, i64* @SIGQUIT
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %17, %12
%23 = load i32, i32* %3
%24 = call i64 @WTERMSIG(i32 %23)
%25 = call i32 @raise(i64 %24)
br label %26
26: ; preds = %22, %17
br label %50
27: ; preds = %8
%28 = load i32, i32* %3
%29 = call i64 @WIFEXITED(i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %49
31: ; preds = %27
%32 = load i32, i32* %3
%33 = call i64 @WEXITSTATUS(i32 %32)
%34 = load i64, i64* @SIGINT
%35 = add nsw i64 %34, 128
%36 = icmp eq i64 %33, %35
br i1 %36, label %43, label %37
37: ; preds = %31
%38 = load i32, i32* %3
%39 = call i64 @WEXITSTATUS(i32 %38)
%40 = load i64, i64* @SIGQUIT
%41 = add nsw i64 %40, 128
%42 = icmp eq i64 %39, %41
br i1 %42, label %43, label %48
43: ; preds = %37, %31
%44 = load i32, i32* %3
%45 = call i64 @WEXITSTATUS(i32 %44)
%46 = sub nsw i64 %45, 128
%47 = call i32 @raise(i64 %46)
br label %48
48: ; preds = %43, %37
br label %49
49: ; preds = %48, %27
br label %50
50: ; preds = %49, %26
br label %51
51: ; preds = %50, %1
%52 = load i32, i32* %3
ret i32 %52
}

LLVM IR (-O2):
@SIGINT = global i64 0
@SIGQUIT = global i64 0
define i32 @xsystem(i8* nocapture %0) {
%2 = tail call i32 @system(i8* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %36, label %4
4: ; preds = %1
%5 = tail call i64 @WIFSIGNALED(i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4
%8 = tail call i64 @WTERMSIG(i32 %2)
%9 = load i64, i64* @SIGINT
%10 = icmp eq i64 %8, %9
br i1 %10, label %15, label %11
11: ; preds = %7
%12 = tail call i64 @WTERMSIG(i32 %2)
%13 = load i64, i64* @SIGQUIT
%14 = icmp eq i64 %12, %13
br i1 %14, label %15, label %36
15: ; preds = %11, %7
%16 = tail call i64 @WTERMSIG(i32 %2)
br label %33
17: ; preds = %4
%18 = tail call i64 @WIFEXITED(i32 %2)
%19 = icmp eq i64 %18, 0
br i1 %19, label %36, label %20
20: ; preds = %17
%21 = tail call i64 @WEXITSTATUS(i32 %2)
%22 = load i64, i64* @SIGINT
%23 = add nsw i64 %22, 128
%24 = icmp eq i64 %21, %23
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = tail call i64 @WEXITSTATUS(i32 %2)
%27 = load i64, i64* @SIGQUIT
%28 = add nsw i64 %27, 128
%29 = icmp eq i64 %26, %28
br i1 %29, label %30, label %36
30: ; preds = %25, %20
%31 = tail call i64 @WEXITSTATUS(i32 %2)
%32 = add nsw i64 %31, -128
br label %33
33: ; preds = %30, %15
%34 = phi i64 [ %16, %15 ], [ %32, %30 ]
%35 = tail call i32 @raise(i64 %34)
br label %36
36: ; preds = %33, %11, %25, %17, %1
ret i32 %2
}