#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*/ sprintf(char *, char *, char *);
int reportfilename(char usefile[12], char *preportfile) {
  int y;
  char z[7];
  for (y = 2; y <= 8; y++) {
    if (y == 8) {
      z[y - 2] = '\0';
    } else {
      z[y - 2] = usefile[y];
    }
  }
  sprintf(preportfile, "th%s.tcr", z);
  return 0;
}


x86 assembly (clang, -O0):
<reportfilename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jg     1177 <reportfilename+0x67>
cmpl   $0x8,-0x14(%rbp)
jne    114d <reportfilename+0x3d>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
cltq
movb   $0x0,-0x1b(%rbp,%rax,1)
jmp    1164 <reportfilename+0x54>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
cltq
mov    %cl,-0x1b(%rbp,%rax,1)
jmp    1169 <reportfilename+0x59>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <reportfilename+0x17>
mov    -0x10(%rbp),%rdi
lea    -0x1b(%rbp),%rdx
lea    0xe7a(%rip),%rsi
call   1030 <sprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reportfilename>:
push   %rax
mov    %rsi,%rax
mov    0x2(%rdi),%cl
mov    %cl,0x1(%rsp)
mov    0x3(%rdi),%cl
mov    %cl,0x2(%rsp)
mov    0x4(%rdi),%cl
mov    %cl,0x3(%rsp)
mov    0x5(%rdi),%cl
mov    %cl,0x4(%rsp)
mov    0x6(%rdi),%cl
mov    %cl,0x5(%rsp)
mov    0x7(%rdi),%cl
mov    %cl,0x6(%rsp)
movb   $0x0,0x7(%rsp)
lea    0xeb6(%rip),%rsi
lea    0x1(%rsp),%rdx
mov    %rax,%rdi
call   1030 <sprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"th%s.tcr\00"
define i32 @reportfilename(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 6
%6 = getelementptr inbounds i8, i8* %0, i64 2
%7 = load i8, i8* %6
store i8 %7, i8* %4
%8 = getelementptr inbounds i8, i8* %0, i64 3
%9 = load i8, i8* %8
%10 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %10
%11 = getelementptr inbounds i8, i8* %0, i64 4
%12 = load i8, i8* %11
%13 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 2
store i8 %12, i8* %13
%14 = getelementptr inbounds i8, i8* %0, i64 5
%15 = load i8, i8* %14
%16 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 3
store i8 %15, i8* %16
%17 = getelementptr inbounds i8, i8* %0, i64 6
%18 = load i8, i8* %17
%19 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 4
store i8 %18, i8* %19
%20 = getelementptr inbounds i8, i8* %0, i64 7
%21 = load i8, i8* %20
%22 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 5
store i8 %21, i8* %22
store i8 0, i8* %5
%23 = call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %4)
ret i32 0
}