#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 EOF;
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int flag = 0, a, b, c, p, k;
  if (argc != 4) {
    printf("Usage: program input_filename output_filename k\n");
    return 1;
  }
  k = atoi(argv[3]);
  FILE *ip = fopen(argv[1], "r");
  FILE *op = fopen(argv[2], "w");
  if (ip) {
    while ((p = fgetc(ip)) != EOF && (p != '\n')) {
      if (p <= 122 && p >= 97) {
        p -= 97;
        flag = 1;
      } else if (p <= 90 && p >= 65)
        p -= 65;
      else {
        printf("input only alphabets\n");
        return 1;
      }
      c = (p + k) % 26;
      fputc((char)(flag == 1 ? c + 97 : c + 65), op);
      flag = 0;
    }
    fclose(ip);
  } else {
    printf("Please check if the input file is available and a and b are "
           "co-prime\n");
  }
  fclose(op);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     119f <main+0x3f>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130a <main+0x1aa>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe73(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12ee <main+0x18e>
jmp    11ef <main+0x8f>
mov    -0x30(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x24(%rbp)
xor    %eax,%eax
mov    0x2de2(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x39(%rbp)
je     121b <main+0xbb>
cmpl   $0xa,-0x24(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    122b <main+0xcb>
jmp    12e0 <main+0x180>
cmpl   $0x7a,-0x24(%rbp)
jg     1254 <main+0xf4>
cmpl   $0x61,-0x24(%rbp)
jl     1254 <main+0xf4>
mov    -0x24(%rbp),%eax
sub    $0x61,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    1293 <main+0x133>
cmpl   $0x5a,-0x24(%rbp)
jg     1276 <main+0x116>
cmpl   $0x41,-0x24(%rbp)
jl     1276 <main+0x116>
mov    -0x24(%rbp),%eax
sub    $0x41,%eax
mov    %eax,-0x24(%rbp)
jmp    128e <main+0x12e>
lea    0xdb8(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    130a <main+0x1aa>
jmp    1293 <main+0x133>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    12bc <main+0x15c>
mov    -0x20(%rbp),%eax
add    $0x61,%eax
mov    %eax,-0x40(%rbp)
jmp    12c5 <main+0x165>
mov    -0x20(%rbp),%eax
add    $0x41,%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x38(%rbp),%rsi
movsbl %al,%edi
call   1060 <fputc@plt>
movl   $0x0,-0x14(%rbp)
jmp    11ef <main+0x8f>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    12fa <main+0x19a>
lea    0xd56(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
cmp    $0x4,%edi
jne    1238 <main+0xd8>
mov    %rsi,%rbx
mov    0x18(%rsi),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
mov    0x10(%rbx),%rdi
lea    0xe65(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rbp,%rbp
je     1255 <main+0xf5>
mov    %rbp,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%eax
je     124b <main+0xeb>
mov    0x2e22(%rip),%r15
jmp    120e <main+0xae>
nopl   0x0(%rax,%rax,1)
add    %r14d,%edx
movslq %edx,%rax
imul   $0x4ec4ec4f,%rax,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x23,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rsi,%rsi,4),%esi
add    %edx,%esi
sub    %esi,%eax
add    %ecx,%eax
movsbl %al,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbp,%rdi
call   1050 <fgetc@plt>
cmp    $0xa,%eax
je     124b <main+0xeb>
cmp    (%r15),%eax
je     124b <main+0xeb>
lea    -0x61(%rax),%edx
mov    $0x61,%ecx
cmp    $0x1a,%edx
jb     11d0 <main+0x70>
add    $0xffffffbf,%eax
mov    $0x41,%ecx
mov    %eax,%edx
cmp    $0x1a,%eax
jb     11d0 <main+0x70>
lea    0xe13(%rip),%rdi
jmp    123f <main+0xdf>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    126b <main+0x10b>
mov    %rbp,%rdi
call   1040 <fclose@plt>
jmp    1261 <main+0x101>
lea    0xda8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Usage: program input_filename output_filename k\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
@.str.3 = [22 x i8] c"input only alphabets\0A\00"
@.str.4 = [70 x i8] c"Please check if the input file is available and a and b are co-prime\0A\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 i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 4
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %91
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %11
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %12
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %30, i32** %13
%31 = load i32*, i32** %12
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %86
33: ; preds = %18
br label %34
34: ; preds = %78, %33
%35 = load i32*, i32** %12
%36 = call i32 @fgetc(i32* %35)
store i32 %36, i32* %10
%37 = load i32, i32* @EOF
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %42
39: ; preds = %34
%40 = load i32, i32* %10
%41 = icmp ne i32 %40, 10
br label %42
42: ; preds = %39, %34
%43 = phi i1 [ false, %34 ], [ %41, %39 ]
br i1 %43, label %44, label %83
44: ; preds = %42
%45 = load i32, i32* %10
%46 = icmp sle i32 %45, 122
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load i32, i32* %10
%49 = icmp sge i32 %48, 97
br i1 %49, label %50, label %53
50: ; preds = %47
%51 = load i32, i32* %10
%52 = sub nsw i32 %51, 97
store i32 %52, i32* %10
store i32 1, i32* %6
br label %65
53: ; preds = %47, %44
%54 = load i32, i32* %10
%55 = icmp sle i32 %54, 90
br i1 %55, label %56, label %62
56: ; preds = %53
%57 = load i32, i32* %10
%58 = icmp sge i32 %57, 65
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32, i32* %10
%61 = sub nsw i32 %60, 65
store i32 %61, i32* %10
br label %64
62: ; preds = %56, %53
%63 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %91
64: ; preds = %59
br label %65
65: ; preds = %64, %50
%66 = load i32, i32* %10
%67 = load i32, i32* %11
%68 = add nsw i32 %66, %67
%69 = srem i32 %68, 26
store i32 %69, i32* %9
%70 = load i32, i32* %6
%71 = icmp eq i32 %70, 1
br i1 %71, label %72, label %75
72: ; preds = %65
%73 = load i32, i32* %9
%74 = add nsw i32 %73, 97
br label %78
75: ; preds = %65
%76 = load i32, i32* %9
%77 = add nsw i32 %76, 65
br label %78
78: ; preds = %75, %72
%79 = phi i32 [ %74, %72 ], [ %77, %75 ]
%80 = trunc i32 %79 to i8
%81 = load i32*, i32** %13
%82 = call i32 @fputc(i8 signext %80, i32* %81)
store i32 0, i32* %6
br label %34
83: ; preds = %42
%84 = load i32*, i32** %12
%85 = call i32 @fclose(i32* %84)
br label %88
86: ; preds = %18
%87 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.4, i64 0, i64 0))
br label %88
88: ; preds = %86, %83
%89 = load i32*, i32** %13
%90 = call i32 @fclose(i32* %89)
store i32 0, i32* %3
br label %91
91: ; preds = %88, %62, %16
%92 = load i32, i32* %3
ret i32 %92
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@EOF = global i32 0
@str = [69 x i8] c"Please check if the input file is available and a and b are co-prime\00"
@str.5 = [21 x i8] c"input only alphabets\00"
@str.6 = [48 x i8] c"Usage: program input_filename output_filename k\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.6, i64 0, i64 0))
br label %51
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 3
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%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 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32* %12, null
br i1 %16, label %47, label %17
17: ; preds = %6
%18 = tail call i32 @fgetc(i32* %12)
%19 = load i32, i32* @EOF
%20 = icmp ne i32 %18, %19
%21 = icmp ne i32 %18, 10
%22 = and i1 %21, %20
br i1 %22, label %23, label %45
23: ; preds = %17, %32
%24 = phi i32 [ %40, %32 ], [ %18, %17 ]
%25 = add i32 %24, -97
%26 = icmp ult i32 %25, 26
br i1 %26, label %32, label %27
27: ; preds = %23
%28 = add i32 %24, -65
%29 = icmp ult i32 %28, 26
br i1 %29, label %32, label %30
30: ; preds = %27
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %51
32: ; preds = %27, %23
%33 = phi i32 [ 97, %23 ], [ 65, %27 ]
%34 = phi i32 [ %25, %23 ], [ %28, %27 ]
%35 = add nsw i32 %34, %9
%36 = srem i32 %35, 26
%37 = add nsw i32 %36, %33
%38 = trunc i32 %37 to i8
%39 = tail call i32 @fputc(i8 signext %38, i32* %15)
%40 = tail call i32 @fgetc(i32* %12)
%41 = load i32, i32* @EOF
%42 = icmp ne i32 %40, %41
%43 = icmp ne i32 %40, 10
%44 = and i1 %43, %42
br i1 %44, label %23, label %45
45: ; preds = %32, %17
%46 = tail call i32 @fclose(i32* %12)
br label %49
47: ; preds = %6
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
%50 = tail call i32 @fclose(i32* %15)
br label %51
51: ; preds = %30, %49, %4
%52 = phi i32 [ 1, %4 ], [ 1, %30 ], [ 0, %49 ]
ret i32 %52
}