#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*/ aft_treat();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *);
int rsa(int, int, int);
void decode(int d, int n) {
  FILE *fp_result;
  FILE *fp_worked;
  int n_result, c_work;
  fp_result = fopen("result.txt", "r");
  fp_worked = fopen("worked.txt", "w");
  while (fscanf(fp_result, "%d", &n_result) > 0) {
    c_work = rsa(n_result, d, n);
    fprintf(fp_worked, "%d\n", c_work);
  }
  fclose(fp_result);
  fclose(fp_worked);
  fp_result = NULL;
  fp_worked = NULL;
  aft_treat();
}


x86 assembly (clang, -O0):
<decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    0xe8b(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe81(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe73(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <fscanf@plt>
cmp    $0x0,%rax
jle    11e3 <decode+0x83>
mov    -0x1c(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1080 <rsa@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xe44(%rip),%rsi
call   1060 <fprintf@plt>
jmp    119c <decode+0x3c>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1030 <aft_treat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %edi,%r15d
lea    0xe88(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe7f(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
lea    0xe76(%rip),%rsi
lea    0x4(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <fscanf@plt>
test   %rax,%rax
jle    1203 <decode+0xa3>
lea    0xe5d(%rip),%r13
lea    0x4(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%rsp),%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1080 <rsa@plt>
mov    %rbp,%rdi
lea    0xe34(%rip),%rsi
mov    %eax,%edx
call   1060 <fprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   1050 <fscanf@plt>
test   %rax,%rax
jg     11d0 <decode+0x70>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
call   1030 <aft_treat@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"result.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"worked.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @decode(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %9, i32** %5
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %10, i32** %6
br label %11
11: ; preds = %15, %2
%12 = load i32*, i32** %5
%13 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %11
%16 = load i32, i32* %7
%17 = load i32, i32* %3
%18 = load i32, i32* %4
%19 = call i32 @rsa(i32 %16, i32 %17, i32 %18)
store i32 %19, i32* %8
%20 = load i32*, i32** %6
%21 = load i32, i32* %8
%22 = call i32 @fprintf(i32* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %21)
br label %11
23: ; preds = %11
%24 = load i32*, i32** %5
%25 = call i32 @fclose(i32* %24)
%26 = load i32*, i32** %6
%27 = call i32 @fclose(i32* %26)
store i32* null, i32** %5
store i32* null, i32** %6
%28 = call i32 (...) @aft_treat()
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"result.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"worked.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [4 x i8] c"%d\0A\00"
define void @decode(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%7 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %2, %9
%10 = load i32, i32* %3
%11 = call i32 @rsa(i32 %10, i32 %0, i32 %1)
%12 = call i32 @fprintf(i32* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%13 = call i64 @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %9, label %15
15: ; preds = %9, %2
%16 = call i32 @fclose(i32* %5)
%17 = call i32 @fclose(i32* %6)
%18 = call i32 (...) @aft_treat()
ret void
}