#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(int);
char *malloc(int);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int getArgument(int argc, char *argv[], char **filePrefix) {
  if (argc != 2) {
    printUsage(argv[0]);
    exit(-1);
  }
  if (argv[1][0] == '-') {
    if (argv[1][1] == 'p') {
      printf("fixed\n");
      exit(0);
    } else {
      printUsage(argv[0]);
      exit(-1);
    }
  } else {
    int i = strlen(argv[1]) - 1;
    int pos = 0;
    while (pos == 0) {
      if (argv[1][i] == '.') {
        pos = i;
      }
      i--;
      if (i == 0) {
        printf("%s - Error input file  %s doesn't contain any ., impossible to "
               "extract prefix\n",
               argv[0], argv[1]);
        exit(-1);
      }
    }
    *filePrefix = malloc((pos + 3) * sizeof(char));
    strncpy(*filePrefix, argv[1], pos);
    (*filePrefix)[pos] = '\0';
  }
  return 0;
}


x86 assembly (clang, -O0):
<getArgument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x4(%rbp)
je     1193 <getArgument+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <printUsage@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11e7 <getArgument+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl 0x1(%rax),%eax
cmp    $0x70,%eax
jne    11d1 <getArgument+0x71>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <printUsage@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1269 <getArgument+0x109>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
jne    122a <getArgument+0xca>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1264 <getArgument+0x104>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    1201 <getArgument+0xa1>
mov    -0x20(%rbp),%eax
add    $0x3,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
movslq -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getArgument>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
cmp    $0x2,%edi
jne    1227 <getArgument+0xb7>
mov    0x8(%r15),%rdi
cmpb   $0x2d,(%rdi)
je     120e <getArgument+0x9e>
mov    %rdx,%r14
call   1050 <strlen@plt>
add    $0xffffffff,%eax
mov    0x8(%r15),%rdx
movslq %eax,%rcx
add    %rdx,%rcx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
test   %ebx,%ebx
jne    11e3 <getArgument+0x73>
cmpb   $0x2e,(%rcx)
mov    $0x0,%ebx
cmove  %eax,%ebx
add    $0xffffffffffffffff,%rcx
add    $0xffffffff,%eax
jne    11b0 <getArgument+0x40>
mov    (%r15),%rsi
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    0x3(%rbx),%edi
call   1070 <malloc@plt>
mov    %rax,(%r14)
mov    0x8(%r15),%rsi
mov    %rax,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    (%r14),%rax
movslq %ebx,%rcx
movb   $0x0,(%rax,%rcx,1)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
cmpb   $0x70,0x1(%rdi)
jne    1227 <getArgument+0xb7>
lea    0xe34(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    (%r15),%rdi
call   1080 <printUsage@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"fixed\0A\00"
@.str.1 = [79 x i8] c"%s - Error input file %s doesn't contain any ., impossible to extract prefix\0A\00"
define i32 @getArgument(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8** %2, i8*** %6
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %3
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @printUsage(i8* %14)
%16 = call i32 @exit(i32 -1)
unreachable
17: ; preds = %3
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %42
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 1
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 112
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%35 = call i32 @exit(i32 0)
unreachable
36: ; preds = %25
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @printUsage(i8* %39)
%41 = call i32 @exit(i32 -1)
unreachable
42: ; preds = %17
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @strlen(i8* %45)
%47 = sub nsw i32 %46, 1
store i32 %47, i32* %7
store i32 0, i32* %8
br label %48
48: ; preds = %77, %42
%49 = load i32, i32* %8
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %78
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = load i32, i32* %7
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 46
br i1 %60, label %61, label %63
61: ; preds = %51
%62 = load i32, i32* %7
store i32 %62, i32* %8
br label %63
63: ; preds = %61, %51
%64 = load i32, i32* %7
%65 = add nsw i32 %64, -1
store i32 %65, i32* %7
%66 = load i32, i32* %7
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %77
68: ; preds = %63
%69 = load i8**, i8*** %5
%70 = getelementptr inbounds i8*, i8** %69, i64 0
%71 = load i8*, i8** %70
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 1
%74 = load i8*, i8** %73
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0), i8* %71, i8* %74)
%76 = call i32 @exit(i32 -1)
unreachable
77: ; preds = %63
br label %48
78: ; preds = %48
%79 = load i32, i32* %8
%80 = add nsw i32 %79, 3
%81 = sext i32 %80 to i64
%82 = mul i64 %81, 1
%83 = trunc i64 %82 to i32
%84 = call i8* @malloc(i32 %83)
%85 = load i8**, i8*** %6
store i8* %84, i8** %85
%86 = load i8**, i8*** %6
%87 = load i8*, i8** %86
%88 = load i8**, i8*** %5
%89 = getelementptr inbounds i8*, i8** %88, i64 1
%90 = load i8*, i8** %89
%91 = load i32, i32* %8
%92 = call i32 @strncpy(i8* %87, i8* %90, i32 %91)
%93 = load i8**, i8*** %6
%94 = load i8*, i8** %93
%95 = load i32, i32* %8
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i8, i8* %94, i64 %96
store i8 0, i8* %97
br label %98
98: ; preds = %78
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [79 x i8] c"%s - Error input file %s doesn't contain any ., impossible to extract prefix\0A\00"
@str = [6 x i8] c"fixed\00"
define i32 @getArgument(i32 %0, i8** nocapture %1, i8** nocapture %2) {
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %3
%6 = load i8*, i8** %1
%7 = tail call i32 @printUsage(i8* %6)
%8 = tail call i32 @exit(i32 -1)
unreachable
9: ; preds = %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = getelementptr inbounds i8, i8* %11, i64 1
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 112
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%20 = tail call i32 @exit(i32 0)
unreachable
21: ; preds = %14
%22 = load i8*, i8** %1
%23 = tail call i32 @printUsage(i8* %22)
%24 = tail call i32 @exit(i32 -1)
unreachable
25: ; preds = %9
%26 = tail call i32 @strlen(i8* %11)
%27 = add i32 %26, -1
%28 = load i8*, i8** %10
%29 = sext i32 %27 to i64
br label %30
30: ; preds = %34, %25
%31 = phi i64 [ %40, %34 ], [ %29, %25 ]
%32 = phi i32 [ %39, %34 ], [ 0, %25 ]
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %47
34: ; preds = %30
%35 = getelementptr inbounds i8, i8* %28, i64 %31
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 46
%38 = trunc i64 %31 to i32
%39 = select i1 %37, i32 %38, i32 0
%40 = add nsw i64 %31, -1
%41 = trunc i64 %40 to i32
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %30
43: ; preds = %34
%44 = load i8*, i8** %1
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0), i8* %44, i8* %28)
%46 = tail call i32 @exit(i32 -1)
unreachable
47: ; preds = %30
%48 = add nsw i32 %32, 3
%49 = tail call i8* @malloc(i32 %48)
store i8* %49, i8** %2
%50 = load i8*, i8** %10
%51 = tail call i32 @strncpy(i8* %49, i8* %50, i32 %32)
%52 = load i8*, i8** %2
%53 = sext i32 %32 to i64
%54 = getelementptr inbounds i8, i8* %52, i64 %53
store i8 0, i8* %54
ret i32 0
}