#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 EXIT_FAILURE;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 4) {
    puts("usage: codepeel <src-file> <code-file> <comment-file>\n");
    exit(EXIT_FAILURE);
  }
  FILE *source, *code, *comment;
  int codepeel(FILE *, FILE *, FILE *, char *);
  if ((source = fopen(argv[1], "r")) == NULL) {
    perror(argv[1]);
    exit(2);
  }
  if ((code = fopen(argv[2], "w")) == NULL) {
    perror(argv[2]);
    exit(3);
  }
  if ((comment = fopen(argv[3], "w")) == NULL) {
    perror(argv[3]);
    exit(4);
  }
  int cdpl_ret = codepeel(source, code, comment, "(//)[/*]{*/}");
  if (cdpl_ret > 0) {
    fprintf(stderr,
            "=======ERROR=======\n[1] Error occured in Codepeel function\n[2] "
            "ERR_CODE := ERR_%d\n",
            cdpl_ret);
    exit(5);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x4(%rbp)
je     1193 <main+0x33>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe95(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11cc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1205 <main+0xa5>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <perror@plt>
mov    $0x3,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe25(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    123e <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <perror@plt>
mov    $0x4,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdea(%rip),%rcx
call   1040 <codepeel@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jle    1285 <main+0x125>
mov    0x2d76(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%edx
lea    0xdd2(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x5,%edi
call   1080 <exit@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x4,%edi
jne    11d3 <main+0x73>
mov    %rsi,%r15
mov    0x8(%rsi),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11ed <main+0x8d>
mov    %rax,%r14
mov    0x10(%r15),%rdi
lea    0xea9(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1200 <main+0xa0>
mov    %rax,%rbx
mov    0x18(%r15),%rdi
lea    0xe91(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1213 <main+0xb3>
lea    0xe82(%rip),%rcx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <codepeel@plt>
test   %eax,%eax
jg     1226 <main+0xc6>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x8(%r15),%rdi
call   1070 <perror@plt>
mov    $0x2,%edi
call   1080 <exit@plt>
mov    0x10(%r15),%rdi
call   1070 <perror@plt>
mov    $0x3,%edi
call   1080 <exit@plt>
mov    0x18(%r15),%rdi
call   1070 <perror@plt>
mov    $0x4,%edi
call   1080 <exit@plt>
mov    0x2db3(%rip),%rcx
mov    (%rcx),%edi
lea    0xe12(%rip),%rsi
mov    %eax,%edx
call   1050 <fprintf@plt>
mov    $0x5,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [55 x i8] c"usage: codepeel <src-file> <code-file> <comment-file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [13 x i8] c"(//)[/*]{*/}\00"
@stderr = global i32 0
@.str.4 = [83 x i8] c"=======ERROR=======\0A[1] Error occured in Codepeel function\0A[2] ERR_CODE := ERR_%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %2
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %5
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %27
21: ; preds = %15
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @perror(i8* %24)
%26 = call i32 @exit(i32 2)
unreachable
27: ; preds = %15
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %31, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i8**, i8*** %4
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i32 @perror(i8* %36)
%38 = call i32 @exit(i32 3)
unreachable
39: ; preds = %27
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 3
%42 = load i8*, i8** %41
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %43, i32** %7
%44 = icmp eq i32* %43, null
br i1 %44, label %45, label %51
45: ; preds = %39
%46 = load i8**, i8*** %4
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @perror(i8* %48)
%50 = call i32 @exit(i32 4)
unreachable
51: ; preds = %39
%52 = load i32*, i32** %5
%53 = load i32*, i32** %6
%54 = load i32*, i32** %7
%55 = call i32 @codepeel(i32* %52, i32* %53, i32* %54, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
store i32 %55, i32* %8
%56 = load i32, i32* %8
%57 = icmp sgt i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %51
%59 = load i32, i32* @stderr
%60 = load i32, i32* %8
%61 = call i32 @fprintf(i32 %59, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %60)
%62 = call i32 @exit(i32 5)
unreachable
63: ; preds = %51
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"usage: codepeel <src-file> <code-file> <comment-file>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [13 x i8] c"(//)[/*]{*/}\00"
@stderr = global i32 0
@.str.4 = [83 x i8] c"=======ERROR=======\0A[1] Error occured in Codepeel function\0A[2] ERR_CODE := ERR_%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @EXIT_FAILURE
%7 = tail call i32 @exit(i32 %6)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i32 @perror(i8* %14)
%16 = tail call i32 @exit(i32 2)
unreachable
17: ; preds = %8
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = load i8*, i8** %18
%24 = tail call i32 @perror(i8* %23)
%25 = tail call i32 @exit(i32 3)
unreachable
26: ; preds = %17
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %31, label %35
31: ; preds = %26
%32 = load i8*, i8** %27
%33 = tail call i32 @perror(i8* %32)
%34 = tail call i32 @exit(i32 4)
unreachable
35: ; preds = %26
%36 = tail call i32 @codepeel(i32* %11, i32* %20, i32* %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%41 = tail call i32 @exit(i32 5)
unreachable
42: ; preds = %35
ret i32 0
}