#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*/ O_RDONLY;
int /*<<< orphan*/ execline(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  if (argc == 1)
    do {
      write(1, "$ ", 2);
      execline(0);
    } while (1);
  else
    for (size_t i = 1; i < argc; i++) {
      int fd = open(argv[i], O_RDONLY);
      execline(fd);
    }
  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   $0x1,-0x8(%rbp)
jne    1186 <main+0x56>
jmp    1155 <main+0x25>
mov    $0x1,%edi
lea    0xe9f(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1040 <execline@plt>
mov    $0x1,%al
test   $0x1,%al
jne    1155 <main+0x25>
jmp    1181 <main+0x51>
jmp    11da <main+0xaa>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    11d5 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <execline@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    118e <main+0x5e>
jmp    11da <main+0xaa>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
je     119d <main+0x6d>
cmp    $0x1,%edi
jne    116b <main+0x3b>
lea    0xeb8(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <write@plt>
xor    %edi,%edi
call   1040 <execline@plt>
jmp    1150 <main+0x20>
mov    %rsi,%r14
movslq %edi,%r15
mov    $0x1,%ebx
mov    0x2e6b(%rip),%r12
nopl   (%rax)
mov    (%r14,%rbx,8),%rdi
mov    (%r12),%esi
call   1050 <open@plt>
mov    %eax,%edi
call   1040 <execline@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"$ \00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %2
br label %11
11: ; preds = %14, %10
%12 = call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%13 = call i32 @execline(i32 0)
br label %14
14: ; preds = %11
br i1 true, label %11, label %15
15: ; preds = %14
br label %35
16: ; preds = %2
store i64 1, i64* %6
br label %17
17: ; preds = %31, %16
%18 = load i64, i64* %6
%19 = load i32, i32* %4
%20 = sext i32 %19 to i64
%21 = icmp ult i64 %18, %20
br i1 %21, label %22, label %34
22: ; preds = %17
%23 = load i8**, i8*** %5
%24 = load i64, i64* %6
%25 = getelementptr inbounds i8*, i8** %23, i64 %24
%26 = load i8*, i8** %25
%27 = load i32, i32* @O_RDONLY
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = call i32 @execline(i32 %29)
br label %31
31: ; preds = %22
%32 = load i64, i64* %6
%33 = add i64 %32, 1
store i64 %33, i64* %6
br label %17
34: ; preds = %17
br label %35
35: ; preds = %34, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"$ \00"
@O_RDONLY = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %3 [
i32 1, label %5
i32 0, label %8
]
3: ; preds = %2
%4 = sext i32 %0 to i64
br label %9
5: ; preds = %2, %5
%6 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = tail call i32 @execline(i32 0)
br label %5
8: ; preds = %9, %2
ret i32 0
9: ; preds = %3, %9
%10 = phi i64 [ %16, %9 ], [ 1, %3 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = tail call i32 @execline(i32 %14)
%16 = add nuw i64 %10, 1
%17 = icmp eq i64 %16, %4
br i1 %17, label %8, label %9
}