#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int system(char *);
int /*<<< orphan*/ term_stat(int);
int main(void) {
  int stat, i;
  char *command[] = {"uname -a", "ls  /dev  >  devfile.txt",
                     "more  <  /etc/passwd"};
  for (i = 0; i < 3; i++)
    if ((stat = system(command[i])) < 0)
      fprintf(stderr, "system call failed\n");
    else
      term_stat(stat);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2cba(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cb7(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cb4(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    11c0 <main+0x90>
movslq -0xc(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rdi
call   1040 <system@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jge    11a5 <main+0x75>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe9c(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11ad <main+0x7d>
mov    -0x8(%rbp),%edi
call   1030 <term_stat@plt>
jmp    11b2 <main+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <main+0x37>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
js     114a <main+0x1a>
mov    %eax,%edi
call   1030 <term_stat@plt>
jmp    115f <main+0x2f>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
lea    0xedd(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xea3(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
js     1178 <main+0x48>
mov    %eax,%edi
call   1030 <term_stat@plt>
jmp    118d <main+0x5d>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1050 <fprintf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <system@plt>
test   %eax,%eax
js     11a6 <main+0x76>
mov    %eax,%edi
call   1030 <term_stat@plt>
jmp    11bb <main+0x8b>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"uname -a\00"
@.str.1 = [25 x i8] c"ls /dev > devfile.txt\00"
@.str.2 = [21 x i8] c"more < /etc/passwd\00"
@__const.main.command = [3 x i8*] [i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i32 0, i32 0)]
@stderr = global i32 0
@.str.3 = [20 x i8] c"system call failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8*]
store i32 0, i32* %1
%5 = bitcast [3 x i8*]* %4 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %23, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %26
9: ; preds = %6
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [3 x i8*], [3 x i8*]* %4, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @system(i8* %13)
store i32 %14, i32* %2
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %22
19: ; preds = %9
%20 = load i32, i32* %2
%21 = call i32 @term_stat(i32 %20)
br label %22
22: ; preds = %19, %16
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %6
26: ; preds = %6
%27 = load i32, i32* %1
ret i32 %27
}

LLVM IR (-O2):
@.str = [9 x i8] c"uname -a\00"
@.str.1 = [25 x i8] c"ls /dev > devfile.txt\00"
@.str.2 = [21 x i8] c"more < /etc/passwd\00"
@stderr = global i32 0
@.str.3 = [20 x i8] c"system call failed\0A\00"
define i32 @main() {
%1 = tail call i32 @system(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @term_stat(i32 %1)
br label %8
8: ; preds = %3, %6
%9 = tail call i32 @system(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp slt i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @term_stat(i32 %9)
br label %16
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %13, %11
%17 = tail call i32 @system(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp slt i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = tail call i32 @term_stat(i32 %17)
br label %24
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %21, %19
ret i32 0
}