#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*/ execv_dashed_external(char const **);
int /*<<< orphan*/ handle_alias(int *, char const ***);
int /*<<< orphan*/ handle_internal_command(int, char const **);
int run_argv(int *argcp, const char ***argv) {
  int done_alias = 0;
  while (1) {
    handle_internal_command(*argcp, *argv);
    execv_dashed_external(*argv);
    if (done_alias || !handle_alias(argcp, argv))
      break;
    done_alias = 1;
  }
  return done_alias;
}


x86 assembly (clang, -O0):
<run_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1040 <handle_internal_command@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <execv_dashed_external@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1185 <run_argv+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <handle_alias@plt>
cmp    $0x0,%eax
jne    118a <run_argv+0x5a>
jmp    1196 <run_argv+0x66>
movl   $0x1,-0x14(%rbp)
jmp    1147 <run_argv+0x17>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_argv>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%edi
mov    (%rsi),%rsi
call   1040 <handle_internal_command@plt>
mov    (%rbx),%rdi
call   1030 <execv_dashed_external@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <handle_alias@plt>
test   %eax,%eax
je     1175 <run_argv+0x45>
mov    (%r14),%edi
mov    (%rbx),%rsi
call   1040 <handle_internal_command@plt>
mov    (%rbx),%rdi
call   1030 <execv_dashed_external@plt>
mov    $0x1,%eax
jmp    1177 <run_argv+0x47>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @run_argv(i32* %0, i8*** %1) {
%3 = alloca i32*
%4 = alloca i8***
%5 = alloca i32
store i32* %0, i32** %3
store i8*** %1, i8**** %4
store i32 0, i32* %5
br label %6
6: ; preds = %2, %23
%7 = load i32*, i32** %3
%8 = load i32, i32* %7
%9 = load i8***, i8**** %4
%10 = load i8**, i8*** %9
%11 = call i32 @handle_internal_command(i32 %8, i8** %10)
%12 = load i8***, i8**** %4
%13 = load i8**, i8*** %12
%14 = call i32 @execv_dashed_external(i8** %13)
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %6
%18 = load i32*, i32** %3
%19 = load i8***, i8**** %4
%20 = call i32 @handle_alias(i32* %18, i8*** %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %17, %6
br label %24
23: ; preds = %17
store i32 1, i32* %5
br label %6
24: ; preds = %22
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
define i32 @run_argv(i32* %0, i8*** %1) {
%3 = load i32, i32* %0
%4 = load i8**, i8*** %1
%5 = tail call i32 @handle_internal_command(i32 %3, i8** %4)
%6 = load i8**, i8*** %1
%7 = tail call i32 @execv_dashed_external(i8** %6)
%8 = tail call i32 @handle_alias(i32* %0, i8*** %1)
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* %0
%12 = load i8**, i8*** %1
%13 = tail call i32 @handle_internal_command(i32 %11, i8** %12)
%14 = load i8**, i8*** %1
%15 = tail call i32 @execv_dashed_external(i8** %14)
br label %16
16: ; preds = %10, %2
%17 = phi i32 [ 1, %10 ], [ 0, %2 ]
ret i32 %17
}