#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 system(char *);
int main(void) {
  int status;
  if ((status = system("date")) < 0)
    err_sys("system() error");
  pr_exit(status);
  if ((status = system("nosuchcommand")) < 0)
    err_sys("system() error");
  pr_exit(status);
  if ((status = system("who; exit 44")) < 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    0xeaa(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    1173 <main+0x33>
lea    0xe97(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xe92(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    119f <main+0x5f>
lea    0xe6b(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xe74(%rip),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11cb <main+0x8b>
lea    0xe3f(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1050 <pr_exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    115f <main+0x1f>
lea    0xeab(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xea7(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1184 <main+0x44>
lea    0xe86(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xe90(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11a9 <main+0x69>
lea    0xe61(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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