#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*/ execvp(char *, char **);
int /*<<< orphan*/ interactive();
int main(int argc, char *argv[]) {
  if (argc > 1) {
    char *args[80 / 2 + 1];
    int real_index, i, offset = 1;
    for (i = 1, real_index = i - offset; i < (argc);
         real_index = ++i - offset) {
      args[real_index] = argv[i];
    }
    args[real_index] = NULL;
    execvp(args[0], args);
  } else
    interactive();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11e1 <main+0xc1>
movl   $0x1,-0x16c(%rbp)
movl   $0x1,-0x168(%rbp)
mov    -0x168(%rbp),%eax
sub    -0x16c(%rbp),%eax
mov    %eax,-0x164(%rbp)
mov    -0x168(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b6 <main+0x96>
mov    -0x10(%rbp),%rax
movslq -0x168(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
movslq -0x164(%rbp),%rax
mov    %rcx,-0x160(%rbp,%rax,8)
ff
mov    -0x168(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x168(%rbp)
sub    -0x16c(%rbp),%eax
mov    %eax,-0x164(%rbp)
jmp    1169 <main+0x49>
movslq -0x164(%rbp),%rax
movq   $0x0,-0x160(%rbp,%rax,8)
mov    -0x160(%rbp),%rdi
lea    -0x160(%rbp),%rsi
call   1040 <execvp@plt>
jmp    11e8 <main+0xc8>
mov    $0x0,%al
call   1030 <interactive@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x148,%rsp
cmp    $0x2,%edi
jl     1171 <main+0x41>
mov    %edi,%ebx
add    $0x8,%rsi
add    $0xffffffff,%ebx
lea    0x0(,%rbx,8),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <memcpy@plt>
movq   $0x0,(%rsp,%rbx,8)
mov    (%rsp),%rdi
mov    %r14,%rsi
call   1050 <execvp@plt>
jmp    1178 <main+0x48>
xor    %eax,%eax
call   1040 <interactive@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [41 x i8*]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %42
12: ; preds = %2
store i32 1, i32* %9
store i32 1, i32* %8
%13 = load i32, i32* %8
%14 = load i32, i32* %9
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %7
br label %16
16: ; preds = %29, %12
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [41 x i8*], [41 x i8*]* %6, i64 0, i64 %27
store i8* %25, i8** %28
br label %29
29: ; preds = %20
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
%32 = load i32, i32* %9
%33 = sub nsw i32 %31, %32
store i32 %33, i32* %7
br label %16
34: ; preds = %16
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [41 x i8*], [41 x i8*]* %6, i64 0, i64 %36
store i8* null, i8** %37
%38 = getelementptr inbounds [41 x i8*], [41 x i8*]* %6, i64 0, i64 0
%39 = load i8*, i8** %38
%40 = getelementptr inbounds [41 x i8*], [41 x i8*]* %6, i64 0, i64 0
%41 = call i32 @execvp(i8* %39, i8** %40)
br label %44
42: ; preds = %2
%43 = call i32 (...) @interactive()
br label %44
44: ; preds = %42, %34
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [41 x i8*]
%4 = bitcast [41 x i8*]* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %18
6: ; preds = %2
%7 = getelementptr i8*, i8** %1, i64 1
%8 = bitcast i8** %7 to i8*
%9 = add nsw i32 %0, -1
%10 = zext i32 %9 to i64
%11 = shl nuw nsw i64 %10, 3
%12 = add nsw i32 %0, -1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [41 x i8*], [41 x i8*]* %3, i64 0, i64 %13
store i8* null, i8** %14
%15 = getelementptr inbounds [41 x i8*], [41 x i8*]* %3, i64 0, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @execvp(i8* %16, i8** %15)
br label %20
18: ; preds = %2
%19 = tail call i32 (...) @interactive()
br label %20
20: ; preds = %18, %6
ret i32 0
}