#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;
int WEXITSTATUS(int);
scalar_t__ WIFSIGNALED(int);
scalar_t__ WTERMSIG(int);
int /*<<< orphan*/ exit(int);
int system(char const *);
int system_checked(const char *cmd) {
  int rc = system(cmd);
  if (WIFSIGNALED(rc) &&
      ((WTERMSIG(rc) == SIGINT) || (WTERMSIG(rc) == SIGQUIT))) {
    exit(1);
  }
  if (rc == -1) {
    return -1;
  }
  return WEXITSTATUS(rc);
}


x86 assembly (clang, -O0):
<system_checked>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <WIFSIGNALED@plt>
cmp    $0x0,%rax
je     11b4 <system_checked+0x64>
mov    -0x14(%rbp),%edi
call   1050 <WTERMSIG@plt>
mov    0x2e5f(%rip),%rcx
cmp    (%rcx),%rax
je     11aa <system_checked+0x5a>
mov    -0x14(%rbp),%edi
call   1050 <WTERMSIG@plt>
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
jne    11b4 <system_checked+0x64>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11ca <system_checked+0x7a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <system_checked+0x85>
mov    -0x14(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<system_checked>:
push   %rbx
call   1030 <system@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <WIFSIGNALED@plt>
test   %rax,%rax
je     118a <system_checked+0x3a>
mov    %ebx,%edi
call   1050 <WTERMSIG@plt>
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%rax
je     119e <system_checked+0x4e>
mov    %ebx,%edi
call   1050 <WTERMSIG@plt>
mov    0x2e5b(%rip),%rcx
cmp    (%rcx),%rax
je     119e <system_checked+0x4e>
cmp    $0xffffffff,%ebx
je     1197 <system_checked+0x47>
mov    %ebx,%edi
pop    %rbx
jmp    1060 <WEXITSTATUS@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i64 0
@SIGQUIT = global i64 0
define i32 @system_checked(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @system(i8* %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = call i64 @WIFSIGNALED(i32 %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %22
10: ; preds = %1
%11 = load i32, i32* %4
%12 = call i64 @WTERMSIG(i32 %11)
%13 = load i64, i64* @SIGINT
%14 = icmp eq i64 %12, %13
br i1 %14, label %20, label %15
15: ; preds = %10
%16 = load i32, i32* %4
%17 = call i64 @WTERMSIG(i32 %16)
%18 = load i64, i64* @SIGQUIT
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %15, %10
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %15, %1
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %26
25: ; preds = %22
store i32 -1, i32* %2
br label %29
26: ; preds = %22
%27 = load i32, i32* %4
%28 = call i32 @WEXITSTATUS(i32 %27)
store i32 %28, i32* %2
br label %29
29: ; preds = %26, %25
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@SIGINT = global i64 0
@SIGQUIT = global i64 0
define i32 @system_checked(i8* nocapture %0) {
%2 = tail call i32 @system(i8* %0)
%3 = tail call i64 @WIFSIGNALED(i32 %2)
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %1
%6 = tail call i64 @WTERMSIG(i32 %2)
%7 = load i64, i64* @SIGINT
%8 = icmp eq i64 %6, %7
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = tail call i64 @WTERMSIG(i32 %2)
%11 = load i64, i64* @SIGQUIT
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9, %5
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %9, %1
%16 = icmp eq i32 %2, -1
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 @WEXITSTATUS(i32 %2)
br label %19
19: ; preds = %15, %17
%20 = phi i32 [ %18, %17 ], [ -1, %15 ]
ret i32 %20
}