#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*/ EXIT_FAILURE;
int /*<<< orphan*/ execlp(char *, char *, char *, ...);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
void execfilepath(int argslen, char *cmd, char **args, char *filepath) {
  switch (argslen) {
  case 0:
    execlp(filepath, cmd, NULL);
    break;
  case 1:
    execlp(filepath, cmd, args[0], NULL);
    break;
  case 2:
    execlp(filepath, cmd, args[0], args[1], NULL);
    break;
  case 3:
    execlp(filepath, cmd, args[0], args[1], args[2], NULL);
    break;
  case 4:
    execlp(filepath, cmd, args[0], args[1], args[2], args[3], NULL);
    break;
  }
  perror("execlp() failed!");
  exit(EXIT_FAILURE);
}


x86 assembly (clang, -O0):
<execfilepath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x28(%rbp)
sub    $0x4,%rax
ja     1233 <execfilepath+0x103>
mov    -0x28(%rbp),%rax
lea    0xe9d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1050 <execlp@plt>
jmp    1233 <execfilepath+0x103>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
xor    %eax,%eax
mov    %eax,%ecx
mov    $0x0,%al
call   1050 <execlp@plt>
jmp    1233 <execfilepath+0x103>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1050 <execlp@plt>
jmp    1233 <execfilepath+0x103>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r8
xor    %eax,%eax
mov    %eax,%r9d
mov    $0x0,%al
call   1050 <execlp@plt>
jmp    1233 <execfilepath+0x103>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%r8
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%r9
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1050 <execlp@plt>
lea    0xdda(%rip),%rdi
call   1030 <perror@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<execfilepath>:
push   %rax
cmp    $0x4,%edi
ja     11c7 <execfilepath+0x97>
mov    %edi,%eax
lea    0xebd(%rip),%rdi
movslq (%rdi,%rax,4),%rax
add    %rdi,%rax
jmp    *%rax
mov    %rcx,%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1050 <execlp@plt>
jmp    11c7 <execfilepath+0x97>
mov    (%rdx),%rdx
mov    %rcx,%rdi
xor    %ecx,%ecx
xor    %eax,%eax
call   1050 <execlp@plt>
jmp    11c7 <execfilepath+0x97>
mov    (%rdx),%rax
mov    0x8(%rdx),%r8
mov    %rcx,%rdi
mov    %rax,%rdx
mov    %r8,%rcx
xor    %r8d,%r8d
xor    %eax,%eax
call   1050 <execlp@plt>
jmp    11c7 <execfilepath+0x97>
mov    (%rdx),%rax
mov    0x8(%rdx),%r9
mov    0x10(%rdx),%r8
mov    %rcx,%rdi
mov    %rax,%rdx
mov    %r9,%rcx
xor    %r9d,%r9d
jmp    11c0 <execfilepath+0x90>
mov    (%rdx),%rax
mov    0x8(%rdx),%r10
mov    0x10(%rdx),%r8
mov    0x18(%rdx),%r9
movq   $0x0,(%rsp)
mov    %rcx,%rdi
mov    %rax,%rdx
mov    %r10,%rcx
xor    %eax,%eax
call   1050 <execlp@plt>
lea    0xe46(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"execlp() failed!\00"
@EXIT_FAILURE = global i32 0
define void @execfilepath(i32 %0, i8* %1, i8** %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i8*
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i8* %3, i8** %8
%9 = load i32, i32* %5
switch i32 %9, label %60 [
i32 0, label %10
i32 1, label %14
i32 2, label %21
i32 3, label %31
i32 4, label %44
]
10: ; preds = %4
%11 = load i8*, i8** %8
%12 = load i8*, i8** %6
%13 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %11, i8* %12, i8* null)
br label %60
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = load i8*, i8** %6
%17 = load i8**, i8*** %7
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %15, i8* %16, i8* %19, i8* null)
br label %60
21: ; preds = %4
%22 = load i8*, i8** %8
%23 = load i8*, i8** %6
%24 = load i8**, i8*** %7
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %7
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %22, i8* %23, i8* %26, i8* %29, i8* null)
br label %60
31: ; preds = %4
%32 = load i8*, i8** %8
%33 = load i8*, i8** %6
%34 = load i8**, i8*** %7
%35 = getelementptr inbounds i8*, i8** %34, i64 0
%36 = load i8*, i8** %35
%37 = load i8**, i8*** %7
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %7
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %32, i8* %33, i8* %36, i8* %39, i8* %42, i8* null)
br label %60
44: ; preds = %4
%45 = load i8*, i8** %8
%46 = load i8*, i8** %6
%47 = load i8**, i8*** %7
%48 = getelementptr inbounds i8*, i8** %47, i64 0
%49 = load i8*, i8** %48
%50 = load i8**, i8*** %7
%51 = getelementptr inbounds i8*, i8** %50, i64 1
%52 = load i8*, i8** %51
%53 = load i8**, i8*** %7
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = load i8**, i8*** %7
%57 = getelementptr inbounds i8*, i8** %56, i64 3
%58 = load i8*, i8** %57
%59 = call i32 (i8*, i8*, i8*, ...) @execlp(i8* %45, i8* %46, i8* %49, i8* %52, i8* %55, i8* %58, i8* null)
br label %60
60: ; preds = %4, %44, %31, %21, %14, %10
%61 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%62 = load i32, i32* @EXIT_FAILURE
%63 = call i32 @exit(i32 %62)
unreachable
}

LLVM IR (-O2):
@.str = [17 x i8] c"execlp() failed!\00"
@EXIT_FAILURE = global i32 0
define void @execfilepath(i32 %0, i8* %1, i8** nocapture %2, i8* %3) {
switch i32 %0, label %31 [
i32 0, label %5
i32 1, label %7
i32 2, label %10
i32 3, label %15
i32 4, label %22
]
5: ; preds = %4
%6 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %3, i8* %1, i8* null)
br label %31
7: ; preds = %4
%8 = load i8*, i8** %2
%9 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %3, i8* %1, i8* %8, i8* null)
br label %31
10: ; preds = %4
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8*, i8** %2, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %3, i8* %1, i8* %11, i8* %13, i8* null)
br label %31
15: ; preds = %4
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8*, i8** %2, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds i8*, i8** %2, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %3, i8* %1, i8* %16, i8* %18, i8* %20, i8* null)
br label %31
22: ; preds = %4
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8*, i8** %2, i64 1
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8*, i8** %2, i64 2
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8*, i8** %2, i64 3
%29 = load i8*, i8** %28
%30 = tail call i32 (i8*, i8*, i8*, ...) @execlp(i8* %3, i8* %1, i8* %23, i8* %25, i8* %27, i8* %29, i8* null)
br label %31
31: ; preds = %4, %22, %15, %10, %7, %5
%32 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = tail call i32 @exit(i32 %33)
unreachable
}