#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ pr_exit(int);
int /*<<< orphan*/ stderr;
int system(char *);
int main(int argc, char **argv) {
  int status;
  if ((status = system("date")) < 0)
    fprintf(stderr, "system() error");
  pr_exit(status);
  if ((status = system("nosuchcommand")) < 0)
    fprintf(stderr, "system() error");
  pr_exit(status);
  if ((status = system("who; exit 44")) < 0)
    fprintf(stderr, "system() error");
  pr_exit(status);
  exit(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    0xea3(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1183 <main+0x43>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xe82(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11b8 <main+0x78>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1050 <pr_exit@plt>
lea    0xe5b(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ed <main+0xad>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe1d(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%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   1030 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1168 <main+0x28>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xe9e(%rip),%rdi
call   1030 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    1196 <main+0x56>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%edi
call   1050 <pr_exit@plt>
lea    0xe7e(%rip),%rdi
call   1030 <system@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11c4 <main+0x84>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1040 <fprintf@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"
@stderr = global i32 0
@.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(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 %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %9, %2
%13 = load i32, i32* %6
%14 = call i32 @pr_exit(i32 %13)
%15 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
store i32 %15, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %12
%21 = load i32, i32* %6
%22 = call i32 @pr_exit(i32 %21)
%23 = call i32 @system(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 %23, i32* %6
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %25, %20
%29 = load i32, i32* %6
%30 = call i32 @pr_exit(i32 %29)
%31 = call i32 @exit(i32 0)
unreachable
}

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