#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 */
scalar_t__ EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, ...);
int /*<<< orphan*/ printf(char *, char *, char *);
int main() {
  FILE *fp1, *fp2, *fp3;
  char studName[30], studUsn[10];
  fp1 = fopen("studentname.txt", "r");
  fp2 = fopen("usn.txt", "r");
  fp3 = fopen("output.txt", "w");
  fprintf(fp3, "%20s\t%20s\n", "StudentName", "USN");
  while (fscanf(fp1, "%s", studName) != EOF &&
         fscanf(fp2, "%s", studUsn) != EOF) {
    fprintf(fp3, "%20s\t%20s\n", studName, studUsn);
  }
  fclose(fp3);
  fp3 = fopen("output.txt", "r");
  while (fscanf(fp3, "%s%s", studName, studUsn) != EOF) {
    printf("%20s\t%20s\n", studName, studUsn);
  }
  fclose(fp1);
  fclose(fp2);
  fclose(fp3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
lea    0xe95(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    0xe86(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
lea    0xe7c(%rip),%rdx
lea    0xe81(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    %rax,%rcx
xor    %eax,%eax
mov    0x2e04(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x4b(%rbp)
je     1216 <main+0xc6>
mov    -0x18(%rbp),%rdi
lea    -0x4a(%rbp),%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    0x2ddb(%rip),%rcx
cmp    (%rcx),%rax
setne  %al
mov    %al,-0x4b(%rbp)
mov    -0x4b(%rbp),%al
test   $0x1,%al
jne    1226 <main+0xd6>
jmp    1243 <main+0xf3>
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x4a(%rbp),%rcx
lea    0xdee(%rip),%rsi
call   1060 <fprintf@plt>
jmp    11c2 <main+0x72>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdc7(%rip),%rdi
lea    0xdb6(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x4a(%rbp),%rcx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    0x2d64(%rip),%rcx
cmp    (%rcx),%rax
je     12a6 <main+0x156>
lea    -0x40(%rbp),%rsi
lea    -0x4a(%rbp),%rdx
lea    0xd8b(%rip),%rdi
call   1040 <printf@plt>
jmp    1263 <main+0x113>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xe9b(%rip),%rdi
lea    0xea4(%rip),%rbx
mov    %rbx,%rsi
call   1070 <fopen@plt>
mov    %rax,%rbp
lea    0xe94(%rip),%rdi
mov    %rbx,%rsi
call   1070 <fopen@plt>
mov    %rax,0x8(%rsp)
lea    0xe88(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
lea    0xe7f(%rip),%rsi
lea    0xe83(%rip),%rdx
lea    0xe88(%rip),%rcx
mov    %rax,%rdi
call   1060 <fprintf@plt>
lea    0xe7f(%rip),%rsi
lea    0x20(%rsp),%rdx
mov    %rbp,(%rsp)
mov    %rbp,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x2e09(%rip),%r15
cmp    (%r15),%rax
je     123e <main+0xee>
lea    0xe59(%rip),%r13
lea    0x16(%rsp),%rbx
lea    0xe30(%rip),%rbp
lea    0x20(%rsp),%r14
nopl   0x0(%rax)
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    (%r15),%rax
je     123e <main+0xee>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
call   1060 <fprintf@plt>
mov    (%rsp),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    (%r15),%rax
jne    1200 <main+0xb0>
mov    %r12,%rdi
call   1030 <fclose@plt>
lea    0xdcd(%rip),%rdi
lea    0xdbc(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r12
lea    0xddf(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x16(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    (%r15),%rax
je     12c6 <main+0x176>
lea    0xda4(%rip),%r14
lea    0x20(%rsp),%rbp
lea    0x16(%rsp),%rbx
lea    0xdae(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
xor    %eax,%eax
call   1050 <fscanf@plt>
cmp    (%r15),%rax
jne    12a0 <main+0x150>
mov    (%rsp),%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"studentname.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"usn.txt\00"
@.str.3 = [11 x i8] c"output.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [11 x i8] c"%20s\09%20s\0A\00"
@.str.6 = [12 x i8] c"StudentName\00"
@.str.7 = [4 x i8] c"USN\00"
@.str.8 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.9 = [5 x i8] c"%s%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [30 x i8]
%6 = alloca [10 x i8]
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %2
%8 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %3
%9 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = call i32 @fprintf(i32* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %12
12: ; preds = %26, %0
%13 = load i32*, i32** %2
%14 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%15 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %14)
%16 = load i64, i64* @EOF
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %24
18: ; preds = %12
%19 = load i32*, i32** %3
%20 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%21 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %20)
%22 = load i64, i64* @EOF
%23 = icmp ne i64 %21, %22
br label %24
24: ; preds = %18, %12
%25 = phi i1 [ false, %12 ], [ %23, %18 ]
br i1 %25, label %26, label %31
26: ; preds = %24
%27 = load i32*, i32** %4
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%29 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%30 = call i32 @fprintf(i32* %27, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %28, i8* %29)
br label %12
31: ; preds = %24
%32 = load i32*, i32** %4
%33 = call i32 @fclose(i32* %32)
%34 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %34, i32** %4
br label %35
35: ; preds = %42, %31
%36 = load i32*, i32** %4
%37 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%39 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %37, i8* %38)
%40 = load i64, i64* @EOF
%41 = icmp ne i64 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %35
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %5, i64 0, i64 0
%44 = getelementptr inbounds [10 x i8], [10 x i8]* %6, i64 0, i64 0
%45 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %43, i8* %44)
br label %35
46: ; preds = %35
%47 = load i32*, i32** %2
%48 = call i32 @fclose(i32* %47)
%49 = load i32*, i32** %3
%50 = call i32 @fclose(i32* %49)
%51 = load i32*, i32** %4
%52 = call i32 @fclose(i32* %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"studentname.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"usn.txt\00"
@.str.3 = [11 x i8] c"output.txt\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [11 x i8] c"%20s\09%20s\0A\00"
@.str.6 = [12 x i8] c"StudentName\00"
@.str.7 = [4 x i8] c"USN\00"
@.str.8 = [3 x i8] c"%s\00"
@EOF = global i64 0
@.str.9 = [5 x i8] c"%s%s\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 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 ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%8 = tail call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%9 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%10 = load i64, i64* @EOF
%11 = icmp eq i64 %9, %10
br i1 %11, label %21, label %12
12: ; preds = %0, %16
%13 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %4)
%14 = load i64, i64* @EOF
%15 = icmp eq i64 %13, %14
br i1 %15, label %21, label %16
16: ; preds = %12
%17 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %3, i8* %4)
%18 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* %3)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %12
21: ; preds = %12, %16, %0
%22 = call i32 @fclose(i32* %7)
%23 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %3, i8* %4)
%25 = load i64, i64* @EOF
%26 = icmp eq i64 %24, %25
br i1 %26, label %32, label %27
27: ; preds = %21, %27
%28 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %3, i8* %4)
%29 = call i64 (i32*, i8*, i8*, ...) @fscanf(i32* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i8* %3, i8* %4)
%30 = load i64, i64* @EOF
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %27
32: ; preds = %27, %21
%33 = call i32 @fclose(i32* %5)
%34 = call i32 @fclose(i32* %6)
%35 = call i32 @fclose(i32* %23)
ret i32 0
}