#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_quit(char *);
int /*<<< orphan*/ err_sys(char *, char *);
int /*<<< orphan*/ pr_exit(int);
int system(char *);
int main(int argc, char **argv) {
  int status;
  if (argc != 2) {
    err_quit("usage: a.out cmd");
  }
  if ((status = system(*++argv)) < 0) {
    err_sys("error on system(%s)", *argv);
  }
  pr_exit(status);
  return 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)
cmpl   $0x2,-0x8(%rbp)
je     116c <main+0x2c>
lea    0xe99(%rip),%rdi
call   1050 <err_quit@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rdi
call   1040 <system@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11a3 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe73(%rip),%rdi
call   1030 <err_sys@plt>
mov    -0x14(%rbp),%edi
call   1060 <pr_exit@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1157 <main+0x17>
lea    0xeae(%rip),%rdi
call   1050 <err_quit@plt>
mov    0x8(%rbx),%rdi
call   1040 <system@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1176 <main+0x36>
mov    0x8(%rbx),%rsi
lea    0xea0(%rip),%rdi
call   1030 <err_sys@plt>
mov    %ebp,%edi
call   1060 <pr_exit@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"usage: a.out cmd\00"
@.str.1 = [20 x i8] c"error on system(%s)\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 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @err_quit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
%14 = load i8*, i8** %13
%15 = call i32 @system(i8* %14)
store i32 %15, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = load i8*, i8** %18
%20 = call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %11
%22 = load i32, i32* %6
%23 = call i32 @pr_exit(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"usage: a.out cmd\00"
@.str.1 = [20 x i8] c"error on system(%s)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @err_quit(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @system(i8* %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i32 @err_sys(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %6
%15 = tail call i32 @pr_exit(i32 %9)
ret i32 0
}