#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*/ *);
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
int fsize(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char const *);
int main(int argc, char const *argv[]) {
  if (argv[1] == 0) {
    printf("Insira o nome de um arquivo.\n");
    return -1;
  }
  FILE *fPointer;
  FILE *fWrite;
  char *file_name = (char *)malloc(strlen(argv[1]) * sizeof(char));
  int i = 0;
  for (i = 0; i < strlen(argv[1]); i++) {
    file_name[i] = argv[1][i];
  }
  fPointer = fopen(file_name, "r");
  int file_size = fsize(file_name);
  char ch;
  int x = 0, new_file = 0, file_number = 0;
  while (1) {
    ch = fgetc(fPointer);
    if (ch == '/') {
      if (fgetc(fPointer) == '*') {
        file_number++;
        if (file_number < 9) {
          sprintf(file_name, "0%d.c", file_number);
        } else {
          sprintf(file_name, "%d.c", file_number);
        }
        while (1) {
          fWrite = fopen(file_name, "a");
          ch = fgetc(fPointer);
          fprintf(fWrite, "%c", ch);
          printf("%c\n", ch);
          if (ch == '*') {
            if (fgetc(fPointer) == '/') {
              break;
            }
          }
        }
      }
    }
    if (feof(fPointer)) {
      break;
    }
    x++;
  }
  fclose(fPointer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11df <main+0x3f>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13b0 <main+0x210>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    1253 <main+0xb3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    120b <main+0x6b>
mov    -0x28(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   10a0 <fsize@plt>
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x31(%rbp)
movsbl -0x31(%rbp),%eax
cmp    $0x2f,%eax
jne    137a <main+0x1da>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
movsbl %al,%eax
cmp    $0x2a,%eax
jne    1375 <main+0x1d5>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
cmpl   $0x9,-0x40(%rbp)
jge    12e1 <main+0x141>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xd49(%rip),%rsi
call   10c0 <sprintf@plt>
jmp    12f4 <main+0x154>
mov    -0x28(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xd32(%rip),%rsi
call   10c0 <sprintf@plt>
jmp    12f9 <main+0x159>
mov    -0x28(%rbp),%rdi
lea    0xd22(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x31(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd04(%rip),%rsi
movsbl -0x31(%rbp),%edx
call   1070 <fprintf@plt>
movsbl -0x31(%rbp),%esi
lea    0xcf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0x31(%rbp),%eax
cmp    $0x2a,%eax
jne    136b <main+0x1cb>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
movsbl %al,%eax
cmp    $0x2f,%eax
jne    1366 <main+0x1c6>
jmp    1370 <main+0x1d0>
jmp    136b <main+0x1cb>
jmp    12f9 <main+0x159>
jmp    1375 <main+0x1d5>
jmp    137a <main+0x1da>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x0,%rax
je     1392 <main+0x1f2>
jmp    13a0 <main+0x200>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1288 <main+0xe8>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     12eb <main+0x13b>
mov    %rsi,%rbx
call   1050 <strlen@plt>
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    1210 <main+0x60>
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    0x8(%rbx),%rax
movzbl (%rax,%rbp,1),%eax
mov    %al,(%r14,%rbp,1)
add    $0x1,%rbp
mov    0x8(%rbx),%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11f0 <main+0x40>
lea    0xde9(%rip),%rsi
mov    %r14,%rdi
call   10c0 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   10b0 <fsize@plt>
lea    0xdd7(%rip),%r15
lea    0xdd2(%rip),%r12
xor    %ebp,%ebp
jmp    1251 <main+0xa1>
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    12df <main+0x12f>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0x2f,%al
jne    1240 <main+0x90>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0x2a,%al
jne    1240 <main+0x90>
lea    0x1(%rbp),%edx
cmp    $0x8,%ebp
lea    0xd8d(%rip),%rsi
lea    0xd85(%rip),%rax
cmovl  %rax,%rsi
mov    %r14,%rdi
mov    %edx,0x4(%rsp)
call   10d0 <sprintf@plt>
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   10c0 <fopen@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <fgetc@plt>
movsbl %al,%r13d
mov    %r13d,%edi
mov    %rbp,%rsi
call   1080 <fputc@plt>
mov    %r12,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0x2a,%r13b
jne    1290 <main+0xe0>
mov    %rbx,%rdi
call   1070 <fgetc@plt>
cmp    $0x2f,%al
jne    1290 <main+0xe0>
mov    0x4(%rsp),%eax
mov    %eax,%ebp
jmp    1240 <main+0x90>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    12fc <main+0x14c>
lea    0xd1c(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Insira o nome de um arquivo.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"0%d.c\00"
@.str.3 = [5 x i8] c"%d.c\00"
@.str.4 = [2 x i8] c"a\00"
@.str.5 = [3 x i8] c"%c\00"
@.str.6 = [4 x i8] c"%c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %118
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %8
store i32 0, i32* %9
store i32 0, i32* %9
br label %31
31: ; preds = %50, %21
%32 = load i32, i32* %9
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @strlen(i8* %35)
%37 = icmp slt i32 %32, %36
br i1 %37, label %38, label %53
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = load i8*, i8** %8
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %38
%51 = load i32, i32* %9
%52 = add nsw i32 %51, 1
store i32 %52, i32* %9
br label %31
53: ; preds = %31
%54 = load i8*, i8** %8
%55 = call i32* @fopen(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %55, i32** %6
%56 = load i8*, i8** %8
%57 = call i32 @fsize(i8* %56)
store i32 %57, i32* %10
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %58
58: ; preds = %53, %112
%59 = load i32*, i32** %6
%60 = call signext i8 @fgetc(i32* %59)
store i8 %60, i8* %11
%61 = load i8, i8* %11
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, 47
br i1 %63, label %64, label %107
64: ; preds = %58
%65 = load i32*, i32** %6
%66 = call signext i8 @fgetc(i32* %65)
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 42
br i1 %68, label %69, label %106
69: ; preds = %64
%70 = load i32, i32* %14
%71 = add nsw i32 %70, 1
store i32 %71, i32* %14
%72 = load i32, i32* %14
%73 = icmp slt i32 %72, 9
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = load i8*, i8** %8
%76 = load i32, i32* %14
%77 = call i32 @sprintf(i8* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %76)
br label %82
78: ; preds = %69
%79 = load i8*, i8** %8
%80 = load i32, i32* %14
%81 = call i32 @sprintf(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %80)
br label %82
82: ; preds = %78, %74
br label %83
83: ; preds = %82, %104
%84 = load i8*, i8** %8
%85 = call i32* @fopen(i8* %84, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %85, i32** %7
%86 = load i32*, i32** %6
%87 = call signext i8 @fgetc(i32* %86)
store i8 %87, i8* %11
%88 = load i32*, i32** %7
%89 = load i8, i8* %11
%90 = call i32 @fprintf(i32* %88, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8 signext %89)
%91 = load i8, i8* %11
%92 = sext i8 %91 to i32
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %92)
%94 = load i8, i8* %11
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 42
br i1 %96, label %97, label %104
97: ; preds = %83
%98 = load i32*, i32** %6
%99 = call signext i8 @fgetc(i32* %98)
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 47
br i1 %101, label %102, label %103
102: ; preds = %97
br label %105
103: ; preds = %97
br label %104
104: ; preds = %103, %83
br label %83
105: ; preds = %102
br label %106
106: ; preds = %105, %64
br label %107
107: ; preds = %106, %58
%108 = load i32*, i32** %6
%109 = call i64 @feof(i32* %108)
%110 = icmp ne i64 %109, 0
br i1 %110, label %111, label %112
111: ; preds = %107
br label %115
112: ; preds = %107
%113 = load i32, i32* %12
%114 = add nsw i32 %113, 1
store i32 %114, i32* %12
br label %58
115: ; preds = %111
%116 = load i32*, i32** %6
%117 = call i32 @fclose(i32* %116)
store i32 0, i32* %3
br label %118
118: ; preds = %115, %19
%119 = load i32, i32* %3
ret i32 %119
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"0%d.c\00"
@.str.3 = [5 x i8] c"%d.c\00"
@.str.4 = [2 x i8] c"a\00"
@.str.6 = [4 x i8] c"%c\0A\00"
@str = [29 x i8] c"Insira o nome de um arquivo.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %58
8: ; preds = %2
%9 = tail call i32 @strlen(i8* %4)
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to i8*
%12 = load i8*, i8** %3
%13 = tail call i32 @strlen(i8* %12)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %26
15: ; preds = %8, %15
%16 = phi i64 [ %21, %15 ], [ 0, %8 ]
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 %16
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %11, i64 %16
store i8 %19, i8* %20
%21 = add nuw nsw i64 %16, 1
%22 = load i8*, i8** %3
%23 = tail call i32 @strlen(i8* %22)
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %21, %24
br i1 %25, label %15, label %26
26: ; preds = %15, %8
%27 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = tail call i32 @fsize(i8* %11)
br label %29
29: ; preds = %52, %26
%30 = phi i32 [ 0, %26 ], [ %53, %52 ]
%31 = tail call signext i8 @fgetc(i32* %27)
%32 = icmp eq i8 %31, 47
br i1 %32, label %33, label %52
33: ; preds = %29
%34 = tail call signext i8 @fgetc(i32* %27)
%35 = icmp eq i8 %34, 42
br i1 %35, label %36, label %52
36: ; preds = %33
%37 = add nsw i32 %30, 1
%38 = icmp slt i32 %30, 8
%39 = select i1 %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0)
%40 = tail call i32 @sprintf(i8* dereferenceable(1) %11, i8* dereferenceable(1) %39, i32 %37)
br label %41
41: ; preds = %51, %36
%42 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%43 = tail call signext i8 @fgetc(i32* %27)
%44 = sext i8 %43 to i32
%45 = tail call i32 @fputc(i32 %44, i32* %42)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %44)
%47 = icmp eq i8 %43, 42
br i1 %47, label %48, label %51
48: ; preds = %41
%49 = tail call signext i8 @fgetc(i32* %27)
%50 = icmp eq i8 %49, 47
br i1 %50, label %52, label %51
51: ; preds = %48, %41
br label %41
52: ; preds = %48, %33, %29
%53 = phi i32 [ %30, %33 ], [ %30, %29 ], [ %37, %48 ]
%54 = tail call i64 @feof(i32* %27)
%55 = icmp eq i64 %54, 0
br i1 %55, label %29, label %56
56: ; preds = %52
%57 = tail call i32 @fclose(i32* %27)
br label %58
58: ; preds = %56, %6
%59 = phi i32 [ -1, %6 ], [ 0, %56 ]
ret i32 %59
}