#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 */
char encipher(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
scalar_t__ toupper(char);
void encipher_file(char *file_name) {
  FILE *fp;
  char line[80 + 1];
  char *ret_val;
  char c;
  int len;
  int idx;
  fp = fopen(file_name, "r");
  ret_val = fgets(line, 80, fp);
  while (ret_val != NULL) {
    len = strlen(line);
    for (idx = 0; idx < len; idx++) {
      c = line[idx];
      if (isalpha(c)) {
        c = encipher((int)(toupper(c)));
        line[idx] = c;
      }
    }
    printf("%s", line);
    ret_val = fgets(line, 80, fp);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<encipher_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
je     126f <encipher_file+0xef>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x80(%rbp)
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x80(%rbp),%eax
jge    1244 <encipher_file+0xc4>
movslq -0x84(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%al
mov    %al,-0x79(%rbp)
movsbl -0x79(%rbp),%edi
call   1090 <isalpha@plt>
cmp    $0x0,%rax
je     122b <encipher_file+0xab>
movsbl -0x79(%rbp),%edi
call   1030 <toupper@plt>
mov    %eax,%edi
call   1070 <encipher@plt>
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%cl
movslq -0x84(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
jmp    1230 <encipher_file+0xb0>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11da <encipher_file+0x5a>
lea    -0x70(%rbp),%rsi
lea    0xdb3(%rip),%rdi
call   1060 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x50,%esi
call   1080 <fgets@plt>
mov    %rax,-0x78(%rbp)
jmp    11b9 <encipher_file+0x39>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encipher_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xe6b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     122c <encipher_file+0xac>
mov    %rsp,%r12
lea    0xe46(%rip),%r15
jmp    11e0 <encipher_file+0x60>
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     122c <encipher_file+0xac>
mov    %r12,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11c0 <encipher_file+0x40>
mov    %eax,%r13d
xor    %ebx,%ebx
jmp    1209 <encipher_file+0x89>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r13
je     11c0 <encipher_file+0x40>
movsbl (%rsp,%rbx,1),%ebp
mov    %ebp,%edi
call   1090 <isalpha@plt>
test   %rax,%rax
je     1200 <encipher_file+0x80>
mov    %ebp,%edi
call   1030 <toupper@plt>
mov    %eax,%edi
call   1070 <encipher@plt>
mov    %al,(%rsp,%rbx,1)
jmp    1200 <encipher_file+0x80>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
define void @encipher_file(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [81 x i8]
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %3
%11 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i8* @fgets(i8* %11, i32 80, i32* %12)
store i8* %13, i8** %5
br label %14
14: ; preds = %45, %1
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %51
17: ; preds = %14
%18 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %7
store i32 0, i32* %8
br label %20
20: ; preds = %42, %17
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %45
24: ; preds = %20
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 %26
%28 = load i8, i8* %27
store i8 %28, i8* %6
%29 = load i8, i8* %6
%30 = call i64 @isalpha(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %41
32: ; preds = %24
%33 = load i8, i8* %6
%34 = call i64 @toupper(i8 signext %33)
%35 = trunc i64 %34 to i32
%36 = call signext i8 @encipher(i32 %35)
store i8 %36, i8* %6
%37 = load i8, i8* %6
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 %39
store i8 %37, i8* %40
br label %41
41: ; preds = %32, %24
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %20
45: ; preds = %20
%46 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%47 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %46)
%48 = getelementptr inbounds [81 x i8], [81 x i8]* %4, i64 0, i64 0
%49 = load i32*, i32** %3
%50 = call i8* @fgets(i8* %48, i32 80, i32* %49)
store i8* %50, i8** %5
br label %14
51: ; preds = %14
%52 = load i32*, i32** %3
%53 = call i32 @fclose(i32* %52)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
define void @encipher_file(i8* nocapture %0) {
%2 = alloca [81 x i8]
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = call i8* @fgets(i8* %3, i32 80, i32* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %29, label %7
7: ; preds = %1, %25
%8 = call i32 @strlen(i8* %3)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = zext i32 %8 to i64
br label %12
12: ; preds = %10, %22
%13 = phi i64 [ 0, %10 ], [ %23, %22 ]
%14 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = call i64 @isalpha(i8 signext %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %12
%19 = call i64 @toupper(i8 signext %15)
%20 = trunc i64 %19 to i32
%21 = call signext i8 @encipher(i32 %20)
store i8 %21, i8* %14
br label %22
22: ; preds = %12, %18
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, %11
br i1 %24, label %25, label %12
25: ; preds = %22, %7
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%27 = call i8* @fgets(i8* %3, i32 80, i32* %4)
%28 = icmp eq i8* %27, null
br i1 %28, label %29, label %7
29: ; preds = %25, %1
%30 = call i32 @fclose(i32* %4)
ret void
}