#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*/ err_sys(char *);
int /*<<< orphan*/ pr_exit(int);
int system(char *);
int main(int argc, char **argv) {
  int status;
  if ((status = system("date")) < 0) {
    err_sys("error on system(date)");
  }
  pr_exit(status);
  if ((status = system("nosuchcomd")) < 0) {
    err_sys("error on system(nosuchcmd)");
  }
  pr_exit(status);
  if ((status = system("who; exit 44")) < 0) {
    err_sys("error on system(who; exit 44)");
  }
  pr_exit(status);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    116a <main+0x3a>
lea    0xea0(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x14(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xea2(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1196 <main+0x66>
lea    0xe95(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x14(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xe9c(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11c2 <main+0x92>
lea    0xe91(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x14(%rbp),%edi
call   1050 <pr_exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    114f <main+0x1f>
lea    0xebb(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xebe(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1174 <main+0x44>
lea    0xeb7(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xebf(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1199 <main+0x69>
lea    0xeba(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"date\00"
@.str.1 = [22 x i8] c"error on system(date)\00"
@.str.2 = [11 x i8] c"nosuchcomd\00"
@.str.3 = [27 x i8] c"error on system(nosuchcmd)\00"
@.str.4 = [13 x i8] c"who; exit 44\00"
@.str.5 = [30 x i8] c"error on system(who; exit 44)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %7, i32* %6
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i32, i32* %6
%13 = call i32 @pr_exit(i32 %12)
%14 = call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 %14, i32* %6
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 @err_sys(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %16, %11
%19 = load i32, i32* %6
%20 = call i32 @pr_exit(i32 %19)
%21 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 %21, i32* %6
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 @err_sys(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %23, %18
%26 = load i32, i32* %6
%27 = call i32 @pr_exit(i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"date\00"
@.str.1 = [22 x i8] c"error on system(date)\00"
@.str.2 = [11 x i8] c"nosuchcomd\00"
@.str.3 = [27 x i8] c"error on system(nosuchcmd)\00"
@.str.4 = [13 x i8] c"who; exit 44\00"
@.str.5 = [30 x i8] c"error on system(who; exit 44)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @err_sys(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @pr_exit(i32 %3)
%9 = tail call i32 @system(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = tail call i32 @err_sys(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %7
%14 = tail call i32 @pr_exit(i32 %9)
%15 = tail call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @err_sys(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = tail call i32 @pr_exit(i32 %15)
ret i32 0
}