#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);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, ...);
char *remove_ext(char *, char, char);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void analyse_param_convert(int argc, char *argv[], char *input, char *output,
                           char *type) {
  char *tmp_file;
  if (argc == 2) {
    strcpy(input, argv[1]);
    tmp_file = remove_ext(input, '.', '/');
    strcpy(output, tmp_file);
    strcat(output, ".");
    strcat(output, type);
    free(tmp_file);
  } else if (argc != 3) {
    printf("ERROR: commmand line format incorrect.\n\n"
           "HELP: %s input_file [output_file]\n",
           argv[0]);
    exit(1);
  } else {
    strcpy(input, argv[1]);
    strcpy(output, argv[2]);
  }
  printf("Summary of the options:\n\n"
         "        -input file      %s\n"
         "        -output file     %s\n",
         input, output);
}


x86 assembly (clang, -O0):
<analyse_param_convert>:
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    %r8,-0x28(%rbp)
cmpl   $0x2,-0x4(%rbp)
jne    11e5 <analyse_param_convert+0x85>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1050 <remove_ext@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
jmp    1235 <analyse_param_convert+0xd5>
cmpl   $0x3,-0x4(%rbp)
je     120e <analyse_param_convert+0xae>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1040 <strcpy@plt>
jmp    1235 <analyse_param_convert+0xd5>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<analyse_param_convert>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
cmp    $0x3,%edi
je     11d2 <analyse_param_convert+0x72>
cmp    $0x2,%edi
jne    1209 <analyse_param_convert+0xa9>
mov    %r8,%r15
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
mov    $0x2e,%esi
mov    $0x2f,%edx
call   1050 <remove_ext@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe4b(%rip),%rsi
mov    %r12,%rdi
call   1070 <strcat@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1070 <strcat@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11ea <analyse_param_convert+0x8a>
mov    0x8(%rbx),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    0x10(%rbx),%rsi
mov    %r12,%rdi
call   1040 <strcpy@plt>
lea    0xe5c(%rip),%rdi
mov    %r14,%rsi
mov    %r12,%rdx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <printf@plt>
mov    (%rbx),%rsi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [75 x i8] c"ERROR: commmand line format incorrect.\0A\0AHELP: %s input_file [output_file]\0A\00"
@.str.2 = [82 x i8] c"Summary of the options:\0A\0A -input file %s\0A -output file %s\0A\00"
define void @analyse_param_convert(i32 %0, i8** %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 %0, i32* %6
store i8** %1, i8*** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 2
br i1 %13, label %14, label %32
14: ; preds = %5
%15 = load i8*, i8** %8
%16 = load i8**, i8*** %7
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcpy(i8* %15, i8* %18)
%20 = load i8*, i8** %8
%21 = call i8* @remove_ext(i8* %20, i8 signext 46, i8 signext 47)
store i8* %21, i8** %11
%22 = load i8*, i8** %9
%23 = load i8*, i8** %11
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = load i8*, i8** %9
%26 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%27 = load i8*, i8** %9
%28 = load i8*, i8** %10
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %11
%31 = call i32 @free(i8* %30)
br label %53
32: ; preds = %5
%33 = load i32, i32* %6
%34 = icmp ne i32 %33, 3
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load i8**, i8*** %7
%37 = getelementptr inbounds i8*, i8** %36, i64 0
%38 = load i8*, i8** %37
%39 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %32
%42 = load i8*, i8** %8
%43 = load i8**, i8*** %7
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @strcpy(i8* %42, i8* %45)
%47 = load i8*, i8** %9
%48 = load i8**, i8*** %7
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 @strcpy(i8* %47, i8* %50)
br label %52
52: ; preds = %41
br label %53
53: ; preds = %52, %14
%54 = load i8*, i8** %8
%55 = load i8*, i8** %9
%56 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %54, i8* %55)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [75 x i8] c"ERROR: commmand line format incorrect.\0A\0AHELP: %s input_file [output_file]\0A\00"
@.str.2 = [82 x i8] c"Summary of the options:\0A\0A -input file %s\0A -output file %s\0A\00"
define void @analyse_param_convert(i32 %0, i8** nocapture %1, i8* %2, i8* %3, i8* %4) {
switch i32 %0, label %15 [
i32 2, label %6
i32 3, label %19
]
6: ; preds = %5
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strcpy(i8* %2, i8* %8)
%10 = tail call i8* @remove_ext(i8* %2, i8 signext 46, i8 signext 47)
%11 = tail call i32 @strcpy(i8* %3, i8* %10)
%12 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %3, i8* %4)
%14 = tail call i32 @free(i8* %10)
br label %26
15: ; preds = %5
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %5
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @strcpy(i8* %2, i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = tail call i32 @strcpy(i8* %3, i8* %24)
br label %26
26: ; preds = %19, %6
%27 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i8* %2, i8* %3)
ret void
}