#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 **);
scalar_t__ strcmp(char *, char *);
scalar_t__ strncmp(char *, char *, int);
char *strtok(char *, char *);
void create_custom(char *cmd, const char *infile, const char *outfile) {
  char *args[128];
  char *tok;
  char **next = args;
  tok = strtok(cmd, " ");
  while (tok) {
    if (strcmp(tok, "%i") == 0)
      *next++ = (char *)infile;
    else if (strncmp(tok, "%o", 2) == 0)
      *next++ = (char *)outfile;
    else
      *next++ = tok;
    tok = strtok(NULL, " ");
  }
  *next = (char *)NULL;
  execvp(args[0], args);
}


x86 assembly (clang, -O0):
<create_custom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
je     124b <create_custom+0x10b>
mov    -0x428(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11c8 <create_custom+0x88>
mov    -0x10(%rbp),%rcx
mov    -0x430(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x430(%rbp)
mov    %rcx,(%rax)
jmp    122f <create_custom+0xef>
mov    -0x428(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    120b <create_custom+0xcb>
mov    -0x18(%rbp),%rcx
mov    -0x430(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x430(%rbp)
mov    %rcx,(%rax)
jmp    122a <create_custom+0xea>
mov    -0x428(%rbp),%rcx
mov    -0x430(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x430(%rbp)
mov    %rcx,(%rax)
jmp    122f <create_custom+0xef>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc6(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x428(%rbp)
jmp    117c <create_custom+0x3c>
mov    -0x430(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x420(%rbp),%rdi
lea    -0x420(%rbp),%rsi
call   1060 <execvp@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_custom>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xea2(%rip),%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     11cd <create_custom+0x8d>
mov    %rax,%rbp
mov    %rsp,%r13
lea    0xe8d(%rip),%r15
lea    0xe84(%rip),%r12
jmp    119a <create_custom+0x5a>
xchg   %ax,%ax
mov    %rcx,0x0(%r13)
add    $0x8,%r13
xor    %edi,%edi
mov    %r12,%rsi
call   1050 <strtok@plt>
mov    %rax,%rbp
test   %rax,%rax
je     11d0 <create_custom+0x90>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcmp@plt>
mov    %rbx,%rcx
test   %rax,%rax
je     1180 <create_custom+0x40>
mov    %rbp,%rdi
lea    0xe4e(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
cmove  %r14,%rbp
mov    %rbp,%rcx
jmp    1180 <create_custom+0x40>
mov    %rsp,%r13
movq   $0x0,0x0(%r13)
mov    (%rsp),%rdi
mov    %rsp,%rsi
call   1060 <execvp@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [3 x i8] c"%o\00"
define void @create_custom(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [128 x i8*]
%8 = alloca i8*
%9 = alloca i8**
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = getelementptr inbounds [128 x i8*], [128 x i8*]* %7, i64 0, i64 0
store i8** %10, i8*** %9
%11 = load i8*, i8** %4
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %8
br label %13
13: ; preds = %37, %3
%14 = load i8*, i8** %8
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %39
16: ; preds = %13
%17 = load i8*, i8** %8
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8**, i8*** %9
%23 = getelementptr inbounds i8*, i8** %22, i32 1
store i8** %23, i8*** %9
store i8* %21, i8** %22
br label %37
24: ; preds = %16
%25 = load i8*, i8** %8
%26 = call i64 @strncmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8*, i8** %6
%30 = load i8**, i8*** %9
%31 = getelementptr inbounds i8*, i8** %30, i32 1
store i8** %31, i8*** %9
store i8* %29, i8** %30
br label %36
32: ; preds = %24
%33 = load i8*, i8** %8
%34 = load i8**, i8*** %9
%35 = getelementptr inbounds i8*, i8** %34, i32 1
store i8** %35, i8*** %9
store i8* %33, i8** %34
br label %36
36: ; preds = %32, %28
br label %37
37: ; preds = %36, %20
%38 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %38, i8** %8
br label %13
39: ; preds = %13
%40 = load i8**, i8*** %9
store i8* null, i8** %40
%41 = getelementptr inbounds [128 x i8*], [128 x i8*]* %7, i64 0, i64 0
%42 = load i8*, i8** %41
%43 = getelementptr inbounds [128 x i8*], [128 x i8*]* %7, i64 0, i64 0
%44 = call i32 @execvp(i8* %42, i8** %43)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [3 x i8] c"%o\00"
define void @create_custom(i8* %0, i8* %1, i8* %2) {
%4 = alloca [128 x i8*]
%5 = bitcast [128 x i8*]* %4 to i8*
%6 = getelementptr inbounds [128 x i8*], [128 x i8*]* %4, i64 0, i64 0
%7 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %23, label %9
9: ; preds = %3, %18
%10 = phi i8** [ %20, %18 ], [ %6, %3 ]
%11 = phi i8* [ %21, %18 ], [ %7, %3 ]
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = tail call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i8* %2, i8* %11
br label %18
18: ; preds = %14, %9
%19 = phi i8* [ %1, %9 ], [ %17, %14 ]
store i8* %19, i8** %10
%20 = getelementptr inbounds i8*, i8** %10, i64 1
%21 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %9
23: ; preds = %18, %3
%24 = phi i8** [ %6, %3 ], [ %20, %18 ]
store i8* null, i8** %24
%25 = load i8*, i8** %6
%26 = call i32 @execvp(i8* %25, i8** %6)
ret void
}