#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 */
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
char *getOutput(int ac, char **arg, int *index, char **prefix, char **suffix) {
  int end = 0;
  int i = 0;
  char *res = NULL;
  end = 0;
  i = 0;
  while (!end && i < ac) {
    if (strcmp(arg[i], "-out") == 0) {
      end = 1;
      i++;
      res = arg[i];
    } else {
      i++;
    }
  }
  (*prefix) = strtok(res, ".");
  (*suffix) = strtok(NULL, ".");
  *index = i;
  return res;
}


x86 assembly (clang, -O0):
<getOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x2c(%rbp)
mov    %al,-0x39(%rbp)
jne    117a <getOutput+0x5a>
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    118a <getOutput+0x6a>
jmp    11df <getOutput+0xbf>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe63(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d1 <getOutput+0xb1>
movl   $0x1,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
jmp    11da <getOutput+0xba>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    115f <getOutput+0x3f>
mov    -0x38(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe01(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getOutput>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r13
mov    %rcx,%r12
mov    %rdx,%r15
test   %edi,%edi
jle    1174 <getOutput+0x54>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %r13,(%rsp)
mov    $0x1,%eax
lea    0xeb3(%rip),%r13
nopl   (%rax)
mov    %rax,%r14
mov    -0x8(%rbx,%rax,8),%rdi
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     117b <getOutput+0x5b>
je     1170 <getOutput+0x50>
lea    0x1(%r14),%rax
cmp    %ebp,%r14d
jl     1150 <getOutput+0x30>
xor    %ebx,%ebx
jmp    117f <getOutput+0x5f>
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    1183 <getOutput+0x63>
mov    (%rbx,%r14,8),%rbx
mov    (%rsp),%r13
lea    0xe7b(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <strtok@plt>
mov    %rax,(%r12)
xor    %edi,%edi
mov    %rbp,%rsi
call   1040 <strtok@plt>
mov    %rax,0x0(%r13)
mov    %r14d,(%r15)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"-out\00"
@.str.1 = [2 x i8] c".\00"
define i8* @getOutput(i32 %0, i8** %1, i32* %2, i8** %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32*
%9 = alloca i8**
%10 = alloca i8**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i32* %2, i32** %8
store i8** %3, i8*** %9
store i8** %4, i8*** %10
store i32 0, i32* %11
store i32 0, i32* %12
store i8* null, i8** %13
store i32 0, i32* %11
store i32 0, i32* %12
br label %14
14: ; preds = %42, %5
%15 = load i32, i32* %11
%16 = icmp ne i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i32, i32* %12
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br label %21
21: ; preds = %17, %14
%22 = phi i1 [ false, %14 ], [ %20, %17 ]
br i1 %22, label %23, label %43
23: ; preds = %21
%24 = load i8**, i8*** %7
%25 = load i32, i32* %12
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %39
31: ; preds = %23
store i32 1, i32* %11
%32 = load i32, i32* %12
%33 = add nsw i32 %32, 1
store i32 %33, i32* %12
%34 = load i8**, i8*** %7
%35 = load i32, i32* %12
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
store i8* %38, i8** %13
br label %42
39: ; preds = %23
%40 = load i32, i32* %12
%41 = add nsw i32 %40, 1
store i32 %41, i32* %12
br label %42
42: ; preds = %39, %31
br label %14
43: ; preds = %21
%44 = load i8*, i8** %13
%45 = call i8* @strtok(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%46 = load i8**, i8*** %9
store i8* %45, i8** %46
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%48 = load i8**, i8*** %10
store i8* %47, i8** %48
%49 = load i32, i32* %12
%50 = load i32*, i32** %8
store i32 %49, i32* %50
%51 = load i8*, i8** %13
ret i8* %51
}

LLVM IR (-O2):
@.str = [5 x i8] c"-out\00"
@.str.1 = [2 x i8] c".\00"
define i8* @getOutput(i32 %0, i8** nocapture %1, i32* nocapture writeonly %2, i8** nocapture writeonly %3, i8** nocapture writeonly %4) {
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %23
7: ; preds = %5, %19
%8 = phi i32 [ %14, %19 ], [ 0, %5 ]
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = add nuw nsw i32 %8, 1
br i1 %13, label %15, label %19
15: ; preds = %7
%16 = zext i32 %14 to i64
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
br label %23
19: ; preds = %7
%20 = xor i1 %13, true
%21 = icmp slt i32 %14, %0
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %7, label %23
23: ; preds = %19, %15, %5
%24 = phi i32 [ 0, %5 ], [ %14, %15 ], [ %14, %19 ]
%25 = phi i8* [ null, %5 ], [ %18, %15 ], [ null, %19 ]
%26 = tail call i8* @strtok(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %26, i8** %3
%27 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %27, i8** %4
store i32 %24, i32* %2
ret i8* %25
}