#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int number_file(char *destfilename) {
  int i = 1, test_mdf = 0;
  int n_mdf;
  char mdf[2], destfilemdf[2354];
  FILE *fsource;
  strcpy(destfilemdf, destfilename);
  strcpy(destfilemdf + strlen(destfilename) - 1, ".0");
  for (i = 0; test_mdf == 0; i++) {
    if ((fsource = fopen(destfilemdf, "rb")) != NULL) {
      printf("\nCheck : ");
      sprintf(mdf, "md%d", i);
      strcpy(destfilemdf + strlen(destfilename) - 3, mdf);
      printf("%s, ", destfilemdf);
      fclose(fsource);
    } else {
      test_mdf = 1;
    }
  }
  printf("\r                                   \n");
  n_mdf = i - 1;
  return n_mdf;
}


x86 assembly (clang, -O0):
<number_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x970,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x950(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x950(%rbp),%rax
mov    %rax,-0x960(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x960(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xffffffffffffffff,%rdi
lea    0xe45(%rip),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1286 <number_file+0x126>
lea    -0x950(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x958(%rbp)
cmp    $0x0,%rax
je     126c <number_file+0x10c>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x16(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdff(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x950(%rbp),%rax
mov    %rax,-0x968(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x968(%rbp),%rdi
cltq
add    %rax,%rdi
add    $0xfffffffffffffffd,%rdi
lea    -0x16(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x950(%rbp),%rsi
lea    0xdc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x958(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1273 <number_file+0x113>
movl   $0x1,-0x10(%rbp)
jmp    1278 <number_file+0x118>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11c7 <number_file+0x67>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x970,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<number_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x948,%rsp
mov    %rdi,%r12
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0xf,%rdi
lea    0xe53(%rip),%rsi
call   1030 <strcpy@plt>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     124a <number_file+0xda>
mov    %rax,%r15
lea    0xe(%rsp),%rbx
lea    0x10(%rsp),%r14
lea    0xe25(%rip),%r13
xor    %ebp,%ebp
lea    0xe1f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
lea    0xe18(%rip),%rsi
mov    %ebp,%edx
call   1090 <sprintf@plt>
mov    %r12,%rdi
call   1060 <strlen@plt>
cltq
lea    (%rsp,%rax,1),%rdi
add    $0xd,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xdf5(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
add    $0x1,%ebp
mov    %r14,%rdi
mov    %r13,%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11e0 <number_file+0x70>
jmp    124c <number_file+0xdc>
xor    %ebp,%ebp
lea    0xdc7(%rip),%rdi
call   1040 <puts@plt>
mov    %ebp,%eax
add    $0x948,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c".0\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [10 x i8] c"\0ACheck : \00"
@.str.3 = [5 x i8] c"md%d\00"
@.str.4 = [5 x i8] c"%s, \00"
@str = [37 x i8] c"\0D \00"
define i32 @number_file(i8* %0) {
%2 = alloca [2 x i8]
%3 = alloca [2354 x i8]
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2354 x i8], [2354 x i8]* %3, i64 0, i64 0
%6 = call i32 @strcpy(i8* %5, i8* %0)
%7 = call i32 @strlen(i8* %0)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [2354 x i8], [2354 x i8]* %3, i64 0, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -1
%11 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %29, label %14
14: ; preds = %1, %14
%15 = phi i32* [ %27, %14 ], [ %12, %1 ]
%16 = phi i32 [ %26, %14 ], [ 0, %1 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%19 = call i32 @strlen(i8* %0)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2354 x i8], [2354 x i8]* %3, i64 0, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -3
%23 = call i32 @strcpy(i8* %22, i8* %4)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%25 = call i32 @fclose(i32* %15)
%26 = add nuw nsw i32 %16, 1
%27 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %14
29: ; preds = %14, %1
%30 = phi i32 [ 0, %1 ], [ %26, %14 ]
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
ret i32 %30
}