#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 */
scalar_t__ check_args(int, char **);
int /*<<< orphan*/ expand(char *);
int /*<<< orphan*/ file_clone(char *, char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *get_new_filename(char const *);
scalar_t__ md5_check_file(char const *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int res;
  if (0 != check_args(argc, argv))
    return 1;
  const char *old_filename = argv[1];
  char *new_filename;
  if (0 == md5_check_file(old_filename, ("e7502f63aac2f2b5f8c5dec1a501e650"))) {
    fprintf(stderr, "ERROR - invalid file checksum.\n");
    res = 1;
    goto clean;
  }
  new_filename = get_new_filename(old_filename);
  file_clone(new_filename, old_filename);
  expand(new_filename);
  res = 0;
clean:
  if (NULL != new_filename)
    free(new_filename);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <check_args@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11ac <main+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    123c <main+0xcc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1080 <md5_check_file@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11f7 <main+0x87>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x14(%rbp)
jmp    1221 <main+0xb1>
mov    -0x20(%rbp),%rdi
call   1040 <get_new_filename@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <file_clone@plt>
mov    -0x28(%rbp),%rdi
call   1090 <expand@plt>
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
je     1236 <main+0xc6>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
call   1050 <check_args@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    11cb <main+0x5b>
mov    0x8(%rbx),%rbx
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <md5_check_file@plt>
test   %rax,%rax
je     11d2 <main+0x62>
mov    %rbx,%rdi
call   1040 <get_new_filename@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   1060 <file_clone@plt>
mov    %r14,%rdi
call   1090 <expand@plt>
xor    %ebp,%ebp
test   %r14,%r14
je     11cb <main+0x5b>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1070 <fprintf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"e7502f63aac2f2b5f8c5dec1a501e650\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"ERROR - invalid file checksum.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i64 @check_args(i32 %9, i8** %10)
%12 = icmp ne i64 0, %11
br i1 %12, label %13, label %14
13: ; preds = %2
store i32 1, i32* %3
br label %40
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = call i64 @md5_check_file(i8* %18, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%20 = icmp eq i64 0, %19
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %32
24: ; preds = %14
%25 = load i8*, i8** %7
%26 = call i8* @get_new_filename(i8* %25)
store i8* %26, i8** %8
%27 = load i8*, i8** %8
%28 = load i8*, i8** %7
%29 = call i32 @file_clone(i8* %27, i8* %28)
%30 = load i8*, i8** %8
%31 = call i32 @expand(i8* %30)
store i32 0, i32* %6
br label %32
32: ; preds = %24, %21
%33 = load i8*, i8** %8
%34 = icmp ne i8* null, %33
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = load i8*, i8** %8
%37 = call i32 @free(i8* %36)
br label %38
38: ; preds = %35, %32
%39 = load i32, i32* %6
store i32 %39, i32* %3
br label %40
40: ; preds = %38, %13
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@.str = [33 x i8] c"e7502f63aac2f2b5f8c5dec1a501e650\00"
@stderr = global i32 0
@.str.1 = [32 x i8] c"ERROR - invalid file checksum.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 @check_args(i32 %0, i8** %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i64 @md5_check_file(i8* %7, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
unreachable
13: ; preds = %5
%14 = tail call i8* @get_new_filename(i8* %7)
%15 = tail call i32 @file_clone(i8* %14, i8* %7)
%16 = tail call i32 @expand(i8* %14)
%17 = icmp eq i8* %14, null
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = tail call i32 @free(i8* %14)
br label %20
20: ; preds = %13, %18, %2
%21 = phi i32 [ 1, %2 ], [ 0, %18 ], [ 0, %13 ]
ret i32 %21
}