#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*/ log_message(int /*<<< orphan*/, char *, char *);
int system(char *);
int system_call(char *cmdline) {
  int retval;
  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    -0x8(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x7f,-0xc(%rbp)
jne    1160 <system_call+0x40>
mov    0x2e9f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeaa(%rip),%rsi
call   1040 <log_message@plt>
jmp    1188 <system_call+0x68>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1183 <system_call+0x63>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe9c(%rip),%rsi
call   1040 <log_message@plt>
jmp    1188 <system_call+0x68>
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
call   1030 <system@plt>
mov    %eax,%ebp
cmp    $0x7f,%eax
je     1140 <system_call+0x20>
cmp    $0xffffffff,%ebp
jne    1158 <system_call+0x38>
lea    0xedc(%rip),%rsi
jmp    1147 <system_call+0x27>
lea    0xeb9(%rip),%rsi
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rdx
call   1040 <log_message@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@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 i8*, i8** %2
%5 = call i32 @system(i8* %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 127
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @LOG_ALERT
%10 = load i8*, i8** %2
%11 = call i32 @log_message(i32 %9, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %20
12: ; preds = %1
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* @LOG_ALERT
%17 = load i8*, i8** %2
%18 = call i32 @log_message(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %19
19: ; preds = %15, %12
br label %20
20: ; preds = %19, %8
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@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 = tail call i32 @system(i8* %0)
switch i32 %2, label %8 [
i32 127, label %4
i32 -1, label %3
]
3: ; preds = %1
br label %4
4: ; preds = %1, %3
%5 = phi i8* [ getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), %1 ]
%6 = load i32, i32* @LOG_ALERT
%7 = tail call i32 @log_message(i32 %6, i8* %5, i8* %0)
br label %8
8: ; preds = %4, %1
ret i32 %2
}