#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*/ check_timing();
int docommand(char *);
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ interactive();
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  check_timing();
  if (argc == 0 || argc == 1) {
    interactive();
  } else if (argc == 3 && !strcmp(argv[1], "-c")) {
    return docommand(argv[2]);
  } else {
    errx(1, "Usage: sh [-c command]");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <check_timing@plt>
cmpl   $0x0,-0x8(%rbp)
je     1181 <main+0x31>
cmpl   $0x1,-0x8(%rbp)
jne    118d <main+0x3d>
mov    $0x0,%al
call   1050 <interactive@plt>
jmp    11df <main+0x8f>
cmpl   $0x3,-0x8(%rbp)
jne    11c9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <docommand@plt>
mov    %eax,-0x4(%rbp)
jmp    11e6 <main+0x96>
mov    $0x1,%edi
lea    0xe2e(%rip),%rsi
call   1030 <errx@plt>
jmp    11df <main+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %eax,%eax
call   1060 <check_timing@plt>
cmp    $0x1,%ebp
ja     116d <main+0x1d>
xor    %eax,%eax
call   1050 <interactive@plt>
jmp    1197 <main+0x47>
cmp    $0x3,%ebp
jne    1186 <main+0x36>
mov    0x8(%rbx),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11a0 <main+0x50>
lea    0xe76(%rip),%rsi
mov    $0x1,%edi
call   1030 <errx@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x10(%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <docommand@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-c\00"
@.str.1 = [23 x i8] c"Usage: sh [-c command]\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @check_timing()
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %9, %2
%13 = call i32 (...) @interactive()
br label %31
14: ; preds = %9
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 3
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @strcmp(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %17
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 @docommand(i8* %26)
store i32 %27, i32* %3
br label %32
28: ; preds = %17, %14
%29 = call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28
br label %31
31: ; preds = %30, %12
store i32 0, i32* %3
br label %32
32: ; preds = %31, %23
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@.str = [3 x i8] c"-c\00"
@.str.1 = [23 x i8] c"Usage: sh [-c command]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @check_timing()
%4 = icmp ult i32 %0, 2
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 (...) @interactive()
br label %20
7: ; preds = %2
%8 = icmp eq i32 %0, 3
br i1 %8, label %9, label %18
9: ; preds = %7
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @strcmp(i8* dereferenceable(1) %11, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @docommand(i8* %16)
br label %20
18: ; preds = %9, %7
%19 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %5, %18, %14
%21 = phi i32 [ %17, %14 ], [ 0, %18 ], [ 0, %5 ]
ret i32 %21
}