#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 /*<<< orphan*/ LOG_ALERT;
int /*<<< orphan*/ SIGCHLD;
scalar_t__ SIG_DFL;
int /*<<< orphan*/ log_message(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ signal_set(int /*<<< orphan*/, void *, int /*<<< orphan*/ *);
int system(char const *);
int system_call(const char *cmdline) {
  int retval;
  signal_set(SIGCHLD, (void *)SIG_DFL, NULL);
  retval = system(cmdline);
  if (retval == 127) {
    log_message(LOG_ALERT, "Couldn't exec command: %s", cmdline);
  } else if (retval == -1) {
    log_message(LOG_ALERT, "Error exec-ing command: %s", cmdline);
  }
  return retval;
}


x86 assembly (clang, -O0):
<system_call>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1040 <signal_set@plt>
mov    -0x8(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jne    118c <system_call+0x5c>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe7e(%rip),%rsi
call   1050 <log_message@plt>
jmp    11b4 <system_call+0x84>
cmpl   $0xffffffff,-0xc(%rbp)
jne    11af <system_call+0x7f>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe70(%rip),%rsi
call   1050 <log_message@plt>
jmp    11b4 <system_call+0x84>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<system_call>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    0x2e8a(%rip),%rax
mov    (%rax),%rsi
xor    %edx,%edx
call   1040 <signal_set@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
mov    %eax,%ebp
cmp    $0x7f,%eax
je     116d <system_call+0x3d>
cmp    $0xffffffff,%ebp
jne    1185 <system_call+0x55>
lea    0xeaf(%rip),%rsi
jmp    1174 <system_call+0x44>
lea    0xe8c(%rip),%rsi
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rdx
call   1050 <log_message@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SIGCHLD = global i32 0
@SIG_DFL = global i64 0
@LOG_ALERT = global i32 0
@.str = [26 x i8] c"Couldn't exec command: %s\00"
@.str.1 = [27 x i8] c"Error exec-ing command: %s\00"
define i32 @system_call(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i32, i32* @SIGCHLD
%5 = load i64, i64* @SIG_DFL
%6 = inttoptr i64 %5 to i8*
%7 = call i32 @signal_set(i32 %4, i8* %6, i32* null)
%8 = load i8*, i8** %2
%9 = call i32 @system(i8* %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = icmp eq i32 %10, 127
br i1 %11, label %12, label %16
12: ; preds = %1
%13 = load i32, i32* @LOG_ALERT
%14 = load i8*, i8** %2
%15 = call i32 @log_message(i32 %13, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %24
16: ; preds = %1
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @LOG_ALERT
%21 = load i8*, i8** %2
%22 = call i32 @log_message(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %19, %16
br label %24
24: ; preds = %23, %12
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@SIGCHLD = global i32 0
@SIG_DFL = global i64 0
@LOG_ALERT = global i32 0
@.str = [26 x i8] c"Couldn't exec command: %s\00"
@.str.1 = [27 x i8] c"Error exec-ing command: %s\00"
define i32 @system_call(i8* %0) {
%2 = load i32, i32* @SIGCHLD
%3 = load i64, i64* @SIG_DFL
%4 = inttoptr i64 %3 to i8*
%5 = tail call i32 @signal_set(i32 %2, i8* %4, i32* null)
%6 = tail call i32 @system(i8* %0)
switch i32 %6, label %12 [
i32 127, label %8
i32 -1, label %7
]
7: ; preds = %1
br label %8
8: ; preds = %1, %7
%9 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %1 ]
%10 = load i32, i32* @LOG_ALERT
%11 = tail call i32 @log_message(i32 %10, i8* %9, i8* %0)
br label %12
12: ; preds = %8, %1
ret i32 %6
}