#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*/ des(char *, char *);
int /*<<< orphan*/ des3key(unsigned char *, int);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ make3key(char *, unsigned char *);
int main(int argc, char **argv) {
  FILE *fp;
  FILE *fp_out;
  char line[8];
  char outline[8];
  char *ret;
  unsigned char key[24];
  make3key(argv[1], key);
  des3key(key, 1);
  fp = fopen(argv[2], "r");
  fp_out = fopen(argv[3], "w+");
  ret = fgets(line, 8, fp);
  while (ret != NULL) {
    des(line, outline);
    fputs(outline, fp_out);
    ret = fgets(line, 8, fp);
  }
  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
mov    0x8(%rax),%rdi
lea    -0x50(%rbp),%rsi
call   1050 <make3key@plt>
lea    -0x50(%rbp),%rdi
mov    $0x1,%esi
call   1070 <des3key@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe46(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     121b <main+0xbb>
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <des@plt>
lea    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <fputs@plt>
lea    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x8,%esi
call   1060 <fgets@plt>
mov    %rax,-0x38(%rbp)
jmp    11db <main+0x7b>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1050 <make3key@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1070 <des3key@plt>
mov    0x10(%rbx),%rdi
lea    0xe69(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xe58(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     11fb <main+0x9b>
mov    %rsp,%r12
lea    0x8(%rsp),%rbx
nop
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <des@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <fputs@plt>
mov    %r12,%rdi
mov    $0x8,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x70>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\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 [8 x i8]
%9 = alloca [8 x i8]
%10 = alloca i8*
%11 = alloca [24 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = getelementptr inbounds [24 x i8], [24 x i8]* %11, i64 0, i64 0
%16 = call i32 @make3key(i8* %14, i8* %15)
%17 = getelementptr inbounds [24 x i8], [24 x i8]* %11, i64 0, i64 0
%18 = call i32 @des3key(i8* %17, i32 1)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %22, i32** %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 3
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %7
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%28 = load i32*, i32** %6
%29 = call i8* @fgets(i8* %27, i32 8, i32* %28)
store i8* %29, i8** %10
br label %30
30: ; preds = %33, %2
%31 = load i8*, i8** %10
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%36 = call i32 @des(i8* %34, i8* %35)
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %9, i64 0, i64 0
%38 = load i32*, i32** %7
%39 = call i32 @fputs(i8* %37, i32* %38)
%40 = getelementptr inbounds [8 x i8], [8 x i8]* %8, i64 0, i64 0
%41 = load i32*, i32** %6
%42 = call i8* @fgets(i8* %40, i32 8, i32* %41)
store i8* %42, i8** %10
br label %30
43: ; preds = %30
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"w+\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i8]
%4 = alloca [8 x i8]
%5 = alloca [24 x i8]
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [24 x i8], [24 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i32 @make3key(i8* %10, i8* %8)
%12 = call i32 @des3key(i8* %8, i32 1)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = call i8* @fgets(i8* %6, i32 8, i32* %15)
%20 = icmp eq i8* %19, null
br i1 %20, label %26, label %21
21: ; preds = %2, %21
%22 = call i32 @des(i8* %6, i8* %7)
%23 = call i32 @fputs(i8* %7, i32* %18)
%24 = call i8* @fgets(i8* %6, i32 8, i32* %15)
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %21
26: ; preds = %21, %2
ret i32 0
}