#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__ DesFile(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc == 3) {
    printf("DES encoding ASCII file: %s to %s\n", argv[1], argv[2]);
    if (DesFile(argv[1], argv[2], 1)) {
      printf("error encrypting\n");
    } else {
      char decout[strlen(argv[2]) + 3];
      memset(decout, 0, strlen(argv[2]) + 3);
      strcat(decout, argv[2]);
      strcat(decout, ".d");
      printf("Decoding DES file: %s to %s\n", argv[2], decout);
      if (DesFile(argv[2], decout, 0)) {
        printf("error decrypting\n");
      }
    }
  }
  return 0;
}


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)
cmpl   $0x3,-0x8(%rbp)
jne    1287 <main+0x137>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x1,%edx
call   1060 <DesFile@plt>
cmp    $0x0,%rax
je     11c5 <main+0x75>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1282 <main+0x132>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
add    $0x3,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%edx
add    $0x3,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x28(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %edx,%edx
call   1060 <DesFile@plt>
cmp    $0x0,%rax
je     127b <main+0x12b>
lea    0xde1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    1287 <main+0x137>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    123c <main+0xdc>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
mov    0x10(%rbx),%rdx
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    $0x1,%edx
call   1070 <DesFile@plt>
test   %rax,%rax
je     11b4 <main+0x54>
lea    0xeaa(%rip),%rdi
call   1030 <puts@plt>
jmp    123c <main+0xdc>
mov    0x10(%rbx),%rdi
call   1040 <strlen@plt>
mov    %rsp,%r15
add    $0x3,%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    0x10(%rbx),%rdi
call   1040 <strlen@plt>
lea    0x3(%rax),%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
mov    0x10(%rbx),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
lea    0xe26(%rip),%rsi
mov    %r14,%rdi
call   1080 <strcat@plt>
mov    0x10(%rbx),%rsi
lea    0xe16(%rip),%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1070 <DesFile@plt>
test   %rax,%rax
je     1239 <main+0xd9>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rsp
xor    %eax,%eax
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"DES encoding ASCII file: %s to %s\0A\00"
@.str.1 = [18 x i8] c"error encrypting\0A\00"
@.str.2 = [3 x i8] c".d\00"
@.str.3 = [29 x i8] c"Decoding DES file: %s to %s\0A\00"
@.str.4 = [18 x i8] c"error decrypting\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %62
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @DesFile(i8* %20, i8* %23, i32 1)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %61
28: ; preds = %10
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @strlen(i8* %31)
%33 = add nsw i32 %32, 3
%34 = zext i32 %33 to i64
%35 = call i8* @llvm.stacksave()
store i8* %35, i8** %6
%36 = alloca i8, i64 %34
store i64 %34, i64* %7
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @strlen(i8* %39)
%41 = add nsw i32 %40, 3
%42 = call i32 @memset(i8* %36, i32 0, i32 %41)
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
%46 = call i32 @strcat(i8* %36, i8* %45)
%47 = call i32 @strcat(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 2
%50 = load i8*, i8** %49
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %50, i8* %36)
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 2
%54 = load i8*, i8** %53
%55 = call i64 @DesFile(i8* %54, i8* %36, i32 0)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %28
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %59
59: ; preds = %57, %28
%60 = load i8*, i8** %6
br label %61
61: ; preds = %59, %26
br label %62
62: ; preds = %61, %2
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"DES encoding ASCII file: %s to %s\0A\00"
@.str.2 = [3 x i8] c".d\00"
@.str.3 = [29 x i8] c"Decoding DES file: %s to %s\0A\00"
@str = [17 x i8] c"error decrypting\00"
@str.5 = [17 x i8] c"error encrypting\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %38
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %8)
%10 = load i8*, i8** %5
%11 = load i8*, i8** %7
%12 = tail call i64 @DesFile(i8* %10, i8* %11, i32 1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %4
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
br label %38
16: ; preds = %4
%17 = load i8*, i8** %7
%18 = tail call i32 @strlen(i8* %17)
%19 = add nsw i32 %18, 3
%20 = zext i32 %19 to i64
%21 = tail call i8* @llvm.stacksave()
%22 = alloca i8, i64 %20
%23 = load i8*, i8** %7
%24 = tail call i32 @strlen(i8* %23)
%25 = add nsw i32 %24, 3
%26 = call i32 @memset(i8* %22, i32 0, i32 %25)
%27 = load i8*, i8** %7
%28 = call i32 @strcat(i8* %22, i8* %27)
%29 = call i32 @strcat(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = load i8*, i8** %7
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %22)
%32 = load i8*, i8** %7
%33 = call i64 @DesFile(i8* %32, i8* %22, i32 0)
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %16
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %37
37: ; preds = %35, %16
br label %38
38: ; preds = %14, %37, %2
ret i32 0
}