#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int STDIN_FILENO;
int /*<<< orphan*/ close(int);
int launch_shell(int, int);
int open(char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int int_mode = 1;
  if (argc != 1) {
    int_mode = 0;
    for (int i = 1; i < argc; i++) {
      int script_fd = open(argv[i], 0);
      int status = launch_shell(script_fd, int_mode);
      close(script_fd);
      if (status == EXIT_FAILURE) {
        return EXIT_FAILURE;
      }
    }
    return EXIT_SUCCESS;
  }
  int status = launch_shell(STDIN_FILENO, int_mode);
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11e4 <main+0xb4>
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d3 <main+0xa3>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <launch_shell@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <close@plt>
mov    -0x20(%rbp),%eax
mov    0x2e39(%rip),%rcx
cmp    (%rcx),%eax
jne    11c0 <main+0x90>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fe <main+0xce>
jmp    11c5 <main+0x95>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1165 <main+0x35>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11fe <main+0xce>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
call   1040 <launch_shell@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    1161 <main+0x31>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <launch_shell@plt>
jle    1203 <main+0xd3>
mov    %rsi,%r12
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,%r15d
mov    %eax,%edi
xor    %esi,%esi
call   1040 <launch_shell@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1030 <close@plt>
mov    0x2e4c(%rip),%r13
cmp    0x0(%r13),%ebx
jne    11a2 <main+0x72>
mov    $0x1,%al
test   %al,%al
je     1203 <main+0xd3>
jmp    120c <main+0xdc>
mov    %ebp,%r15d
mov    $0x2,%eax
movl   $0x0,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,%r14
cmp    %rax,%r15
je     11f5 <main+0xc5>
mov    (%r12,%r14,8),%rdi
xor    %esi,%esi
call   1050 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
xor    %esi,%esi
call   1040 <launch_shell@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <close@plt>
lea    0x1(%r14),%rax
cmp    0x0(%r13),%ebp
jne    11c0 <main+0x90>
mov    %ebp,0x4(%rsp)
cmp    %r15,%r14
setb   %al
mov    0x4(%rsp),%ebx
test   %al,%al
jne    120c <main+0xdc>
mov    0x2dce(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %41
13: ; preds = %2
store i32 0, i32* %6
store i32 1, i32* %7
br label %14
14: ; preds = %36, %13
%15 = load i32, i32* %7
%16 = load i32, i32* %4
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load i8**, i8*** %5
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @open(i8* %23, i32 0)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = call i32 @launch_shell(i32 %25, i32 %26)
store i32 %27, i32* %9
%28 = load i32, i32* %8
%29 = call i32 @close(i32 %28)
%30 = load i32, i32* %9
%31 = load i32, i32* @EXIT_FAILURE
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %35
33: ; preds = %18
%34 = load i32, i32* @EXIT_FAILURE
store i32 %34, i32* %3
br label %46
35: ; preds = %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %14
39: ; preds = %14
%40 = load i32, i32* @EXIT_SUCCESS
store i32 %40, i32* %3
br label %46
41: ; preds = %2
%42 = load i32, i32* @STDIN_FILENO
%43 = load i32, i32* %6
%44 = call i32 @launch_shell(i32 %42, i32 %43)
store i32 %44, i32* %10
%45 = load i32, i32* %10
store i32 %45, i32* %3
br label %46
46: ; preds = %41, %39, %33
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@STDIN_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %38, label %4
4: ; preds = %2
%5 = icmp sgt i32 %0, 1
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = load i32, i32* @EXIT_SUCCESS
br label %41
8: ; preds = %4
%9 = zext i32 %0 to i64
%10 = zext i32 %0 to i64
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @open(i8* %12, i32 0)
%14 = tail call i32 @launch_shell(i32 %13, i32 0)
%15 = tail call i32 @close(i32 %13)
%16 = load i32, i32* @EXIT_FAILURE
%17 = icmp eq i32 %14, %16
br i1 %17, label %33, label %18
18: ; preds = %8, %21
%19 = phi i64 [ %29, %21 ], [ 2, %8 ]
%20 = icmp eq i64 %19, %10
br i1 %20, label %30, label %21
21: ; preds = %18
%22 = getelementptr inbounds i8*, i8** %1, i64 %19
%23 = load i8*, i8** %22
%24 = tail call i32 @open(i8* %23, i32 0)
%25 = tail call i32 @launch_shell(i32 %24, i32 0)
%26 = tail call i32 @close(i32 %24)
%27 = load i32, i32* @EXIT_FAILURE
%28 = icmp eq i32 %25, %27
%29 = add nuw nsw i64 %19, 1
br i1 %28, label %30, label %18
30: ; preds = %21, %18
%31 = phi i32 [ 0, %18 ], [ %25, %21 ]
%32 = icmp ult i64 %19, %9
br label %33
33: ; preds = %30, %8
%34 = phi i1 [ true, %8 ], [ %32, %30 ]
%35 = phi i32 [ %14, %8 ], [ %31, %30 ]
%36 = load i32, i32* @EXIT_SUCCESS
%37 = select i1 %34, i32 %35, i32 %36
br label %41
38: ; preds = %2
%39 = load i32, i32* @STDIN_FILENO
%40 = tail call i32 @launch_shell(i32 %39, i32 1)
br label %41
41: ; preds = %33, %6, %38
%42 = phi i32 [ %40, %38 ], [ %7, %6 ], [ %37, %33 ]
ret i32 %42
}