#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*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int intrp_copyfile(char *, char *);
int /*<<< orphan*/ parser_get_line(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int main(int argc, char *argv[]) {
  FILE *f = NULL;
  char line[4096];
  if (argc != 4) {
    fprintf(stderr, "Invalid number of arguments: %i\n", argc);
    goto err;
  }
  if ((f = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "%s\n", strerror(errno));
    goto err;
  }
  parser_get_line(f, line);
  if (!line || line[0] != '#' || line[1] != '!') {
    fprintf(stderr, "Invalid script\n");
    goto err;
  }
  parser_get_line(f, line);
  if (!line || strncmp(line, "copy", 4) != 0) {
    fprintf(stderr, "Syntax error: %s\n", line);
    goto err;
  }
  return intrp_copyfile(argv[2], argv[3]);
err:
  fclose(f);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11ba <main+0x4a>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d3 <main+0x163>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1215 <main+0xa5>
mov    0x2dfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1024(%rbp)
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x1024(%rbp),%edi
mov    %rax,%rdx
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d3 <main+0x163>
mov    -0x18(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1040 <parser_get_line@plt>
movsbl -0x1020(%rbp),%eax
cmp    $0x23,%eax
jne    1245 <main+0xd5>
movsbl -0x101f(%rbp),%eax
cmp    $0x21,%eax
je     1261 <main+0xf1>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d3 <main+0x163>
mov    -0x18(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
call   1040 <parser_get_line@plt>
lea    -0x1020(%rbp),%rdi
lea    0xdb4(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     12b6 <main+0x146>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
lea    -0x1020(%rbp),%rdx
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    12d3 <main+0x163>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1070 <intrp_copyfile@plt>
mov    %eax,-0x4(%rbp)
jmp    12e3 <main+0x173>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1000,%rsp
cmp    $0x4,%edi
jne    11ff <main+0x8f>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe93(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     121c <main+0xac>
mov    %rax,%rbx
mov    %rsp,%rsi
mov    %rax,%rdi
call   1040 <parser_get_line@plt>
cmpb   $0x23,(%rsp)
jne    124a <main+0xda>
cmpb   $0x21,0x1(%rsp)
jne    124a <main+0xda>
mov    %rsp,%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1040 <parser_get_line@plt>
lea    0xe5f(%rip),%rsi
mov    %rbp,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     127a <main+0x10a>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
mov    %rsp,%rdx
jmp    1241 <main+0xd1>
mov    %edi,%edx
mov    0x2dd8(%rip),%rax
mov    (%rax),%edi
lea    0xdef(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1261 <main+0xf1>
mov    0x2dbd(%rip),%rax
mov    (%rax),%ebp
mov    0x2dac(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe0c(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    1261 <main+0xf1>
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    $0x1,%eax
add    $0x1000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x10(%r14),%rdi
mov    0x18(%r14),%rsi
call   1070 <intrp_copyfile@plt>
jmp    126e <main+0xfe>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [33 x i8] c"Invalid number of arguments: %i\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.3 = [16 x i8] c"Invalid script\0A\00"
@.str.4 = [5 x i8] c"copy\00"
@.str.5 = [18 x i8] c"Syntax error: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [4096 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 4
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* %4
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %60
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %18, i32** %6
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %23)
br label %60
25: ; preds = %14
%26 = load i32*, i32** %6
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%28 = call i32 @parser_get_line(i32* %26, i8* %27)
%29 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 35
br i1 %32, label %38, label %33
33: ; preds = %25
%34 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 33
br i1 %37, label %38, label %41
38: ; preds = %33, %25
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %60
41: ; preds = %33
%42 = load i32*, i32** %6
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%44 = call i32 @parser_get_line(i32* %42, i8* %43)
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%46 = call i64 @strncmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %41
%49 = load i32, i32* @stderr
%50 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %50)
br label %60
52: ; preds = %41
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 3
%58 = load i8*, i8** %57
%59 = call i32 @intrp_copyfile(i8* %55, i8* %58)
store i32 %59, i32* %3
br label %63
60: ; preds = %48, %38, %20, %10
%61 = load i32*, i32** %6
%62 = call i32 @fclose(i32* %61)
store i32 1, i32* %3
br label %63
63: ; preds = %60, %52
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [33 x i8] c"Invalid number of arguments: %i\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@errno = global i32 0
@.str.3 = [16 x i8] c"Invalid script\0A\00"
@.str.4 = [5 x i8] c"copy\00"
@.str.5 = [18 x i8] c"Syntax error: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 4
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %43
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = load i32, i32* @stderr
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %43
19: ; preds = %9
%20 = call i32 @parser_get_line(i32* %12, i8* %4)
%21 = load i8, i8* %4
%22 = icmp ne i8 %21, 35
%23 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 1
%24 = load i8, i8* %23
%25 = icmp ne i8 %24, 33
%26 = select i1 %22, i1 true, i1 %25
br i1 %26, label %27, label %30
27: ; preds = %19
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %43
30: ; preds = %19
%31 = call i32 @parser_get_line(i32* %12, i8* %4)
%32 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* %4)
br label %43
37: ; preds = %30
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = load i8*, i8** %38
%40 = getelementptr inbounds i8*, i8** %1, i64 3
%41 = load i8*, i8** %40
%42 = call i32 @intrp_copyfile(i8* %39, i8* %41)
br label %46
43: ; preds = %34, %27, %14, %6
%44 = phi i32* [ null, %6 ], [ null, %14 ], [ %12, %27 ], [ %12, %34 ]
%45 = call i32 @fclose(i32* %44)
br label %46
46: ; preds = %43, %37
%47 = phi i32 [ 1, %43 ], [ %42, %37 ]
ret i32 %47
}