#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 my_system(char *);
int /*<<< orphan*/ pr_exit(int);
int main(void) {
  int status = 0;
  if ((status = my_system("top")) < 0) {
    err_sys("my_system error");
  }
  pr_exit(status);
  if ((status = my_system("nosuchcommand")) < 0) {
    err_sys("my_system error");
  }
  pr_exit(status);
  if ((status = my_system("who; exit 44")) < 0) {
    err_sys("my_system error");
  }
  pr_exit(status);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xea3(%rip),%rdi
call   1050 <my_system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    117a <main+0x3a>
lea    0xe8f(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1040 <pr_exit@plt>
lea    0xe8b(%rip),%rdi
call   1050 <my_system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11a6 <main+0x66>
lea    0xe63(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1040 <pr_exit@plt>
lea    0xe6d(%rip),%rdi
call   1050 <my_system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11d2 <main+0x92>
lea    0xe37(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x8(%rbp),%edi
call   1040 <pr_exit@plt>
xor    %edi,%edi
call   1060 <exit@plt>

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

LLVM IR (-O0):
@.str = [4 x i8] c"top\00"
@.str.1 = [16 x i8] c"my_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
store i32 0, i32* %2
%3 = call i32 @my_system(i8* getelementptr inbounds ([4 x i8], [4 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 ([16 x i8], [16 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 @my_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 ([16 x i8], [16 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 @my_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 ([16 x i8], [16 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 = [4 x i8] c"top\00"
@.str.1 = [16 x i8] c"my_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 @my_system(i8* getelementptr inbounds ([4 x i8], [4 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 ([16 x i8], [16 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 @my_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 ([16 x i8], [16 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 @my_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 ([16 x i8], [16 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
}