#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 */
char *malloc(int /*<<< orphan*/);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
char *GetInputFileName(int paramNumber, char *parameter[]) {
  int i = 0;
  do {
    i++;
  } while (strcmp(parameter[i], "-i"));
  char *inputFileName = malloc(strlen(parameter[i + 1]));
  inputFileName = parameter[i + 1];
  return inputFileName;
}


x86 assembly (clang, -O0):
<GetInputFileName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1146 <GetInputFileName+0x16>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetInputFileName>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    $0x1,%ebx
lea    0xecc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1140 <GetInputFileName+0x20>
mov    %ebx,%ebx
mov    (%r15,%rbx,8),%rdi
call   1030 <strlen@plt>
mov    (%r15,%rbx,8),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"-i\00"
define i8* @GetInputFileName(i32 %0, i8** nocapture %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %5, %3 ], [ 0, %2 ]
%5 = add nuw nsw i64 %4, 1
%6 = getelementptr inbounds i8*, i8** %1, i64 %5
%7 = load i8*, i8** %6
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %3
10: ; preds = %3
%11 = add nuw i64 %4, 2
%12 = and i64 %11, 4294967295
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 @strlen(i8* %14)
%16 = load i8*, i8** %13
ret i8* %16
}