#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*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char *);
char *strstr(char *, char *);
void output_name_generator(const char *input, char *output, char *lang) {
  char tempname[200];
  strcpy(tempname, input);
  if (lang[0] != '\0') {
    strcat(tempname, "_");
    strcat(tempname, lang);
  }
  char *j;
  if ((j = strstr(tempname, ".xml")) || (j = strstr(tempname, ".srt"))) {
    if ((j - tempname) == strlen(tempname) - 4) {
      tempname[j - tempname] = '\0';
    }
  }
  strcat(tempname, ".srt");
  strcpy(output, tempname);
  return;
}


x86 assembly (clang, -O0):
<output_name_generator>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     119a <output_name_generator+0x5a>
lea    -0xe0(%rbp),%rdi
lea    0xe7b(%rip),%rsi
call   1050 <strcat@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcat@plt>
lea    -0xe0(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0xe8(%rbp)
cmp    $0x0,%rax
jne    11e2 <output_name_generator+0xa2>
lea    -0xe0(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1060 <strstr@plt>
mov    %rax,-0xe8(%rbp)
cmp    $0x0,%rax
je     123c <output_name_generator+0xfc>
mov    -0xe8(%rbp),%rax
lea    -0xe0(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0xf0(%rbp)
lea    -0xe0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xf0(%rbp),%rax
sub    $0x4,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jne    1237 <output_name_generator+0xf7>
mov    -0xe8(%rbp),%rax
lea    -0xe0(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
jmp    123c <output_name_generator+0xfc>
lea    -0xe0(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1050 <strcat@plt>
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<output_name_generator>:
push   %r15
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rsi
mov    %rsp,%rdi
call   1030 <strcpy@plt>
cmpb   $0x0,(%rbx)
je     117f <output_name_generator+0x3f>
lea    0xe97(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1050 <strcat@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcat@plt>
lea    0xe7c(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11b0 <output_name_generator+0x70>
lea    0xe67(%rip),%rsi
mov    %rsp,%rdi
call   1060 <strstr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11c9 <output_name_generator+0x89>
sub    %r15,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0xfffffffc,%eax
cltq
cmp    %rax,%rbx
jne    11c9 <output_name_generator+0x89>
movb   $0x0,(%rsp,%rbx,1)
lea    0xe37(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1050 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"_\00"
@.str.1 = [5 x i8] c".xml\00"
@.str.2 = [5 x i8] c".srt\00"
define void @output_name_generator(i8* %0, i8* %1, i8* %2) {
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = load i8, i8* %2
%8 = icmp eq i8 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %3
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @strcat(i8* %5, i8* %2)
br label %12
12: ; preds = %9, %3
%13 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i8* @strstr(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i8* %16, null
br i1 %17, label %29, label %18
18: ; preds = %15, %12
%19 = phi i8* [ %13, %12 ], [ %16, %15 ]
%20 = ptrtoint i8* %19 to i64
%21 = ptrtoint [200 x i8]* %4 to i64
%22 = sub i64 %20, %21
%23 = call i32 @strlen(i8* %5)
%24 = add nsw i32 %23, -4
%25 = sext i32 %24 to i64
%26 = icmp eq i64 %22, %25
br i1 %26, label %27, label %29
27: ; preds = %18
%28 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 %22
store i8 0, i8* %28
br label %29
29: ; preds = %18, %27, %15
%30 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 @strcpy(i8* %1, i8* %5)
ret void
}