#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ pr_exit(int);
int /*<<< orphan*/ printf(char *);
int system(char *);
int main(void) {
  int status;
  if ((status = system("date")) < 0)
    err_sys("system() error");
  pr_exit(status);
  printf("\n");
  if ((status = system("nosuchcommand")) < 0) {
    err_sys("system() error");
  }
  pr_exit(status);
  printf("\n");
  if ((status = system("who; exit -1")) < 0) {
    err_sys("system() error");
  }
  pr_exit(status);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1183 <main+0x33>
lea    0xe87(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1060 <pr_exit@plt>
lea    0xe82(%rip),%rdi
call   1050 <printf@plt>
lea    0xe78(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11bb <main+0x6b>
lea    0xe4f(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1060 <pr_exit@plt>
lea    0xe4a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11f3 <main+0xa3>
lea    0xe17(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1060 <pr_exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1050 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    116f <main+0x1f>
lea    0xe9b(%rip),%rdi
call   1040 <err_sys@plt>
mov    %ebx,%edi
call   1060 <pr_exit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe8d(%rip),%rdi
call   1050 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    119e <main+0x4e>
lea    0xe6c(%rip),%rdi
call   1040 <err_sys@plt>
mov    %ebx,%edi
call   1060 <pr_exit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe6c(%rip),%rdi
call   1050 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11cd <main+0x7d>
lea    0xe3d(%rip),%rdi
call   1040 <err_sys@plt>
mov    %ebx,%edi
call   1060 <pr_exit@plt>
xor    %edi,%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@.str = [5 x i8] c"date\00"
@.str.1 = [15 x i8] c"system() error\00"
@.str.3 = [14 x i8] c"nosuchcommand\00"
@.str.4 = [13 x i8] c"who; exit -1\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @pr_exit(i32 %1)
%7 = tail call i32 @putchar(i32 10)
%8 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = tail call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
%13 = tail call i32 @pr_exit(i32 %8)
%14 = tail call i32 @putchar(i32 10)
%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 = %12
%18 = tail call i32 @err_sys(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %12
%20 = tail call i32 @pr_exit(i32 %15)
%21 = tail call i32 @exit(i32 0)
unreachable
}