#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
void printTotalFile(char *fileName, char *mode, int jdim) {
  char line[jdim + 2];
  FILE *file;
  file = fopen(fileName, mode);
  if (file != NULL) {
    while (fgets(line, jdim + 2, file) != NULL) {
      printf("%s", line);
    }
    printf("@n");
    fclose(file);
  } else {
    printf("Error opening file printTotalFile");
  }
}


x86 assembly (clang, -O0):
<printTotalFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11ed <printTotalFile+0xad>
jmp    119d <printTotalFile+0x5d>
mov    -0x38(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    -0x30(%rbp),%rdx
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11d1 <printTotalFile+0x91>
mov    -0x38(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119d <printTotalFile+0x5d>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11fb <printTotalFile+0xbb>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printTotalFile>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
add    $0x2,%r14d
mov    %rsp,%rbx
lea    0xf(%r14),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
call   1060 <fopen@plt>
test   %rax,%rax
je     11d3 <printTotalFile+0x93>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11b0 <printTotalFile+0x70>
lea    0xe76(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1190 <printTotalFile+0x50>
lea    0xe4c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <fclose@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"@n\00"
@.str.2 = [34 x i8] c"Error opening file printTotalFile\00"
define void @printTotalFile(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %6
%11 = add nsw i32 %10, 2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %7
%14 = alloca i8, i64 %12
store i64 %12, i64* %8
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = call i32* @fopen(i8* %15, i8* %16)
store i32* %17, i32** %9
%18 = load i32*, i32** %9
%19 = icmp ne i32* %18, null
br i1 %19, label %20, label %33
20: ; preds = %3
br label %21
21: ; preds = %27, %20
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 2
%24 = load i32*, i32** %9
%25 = call i32* @fgets(i8* %14, i32 %23, i32* %24)
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %29
27: ; preds = %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %21
29: ; preds = %21
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32*, i32** %9
%32 = call i32 @fclose(i32* %31)
br label %35
33: ; preds = %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
%36 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [3 x i8] c"@n\00"
@.str.2 = [34 x i8] c"Error opening file printTotalFile\00"
define void @printTotalFile(i8* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = add nsw i32 %2, 2
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = tail call i32* @fopen(i8* %0, i8* %1)
%8 = icmp eq i32* %7, null
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = call i32* @fgets(i8* %6, i32 %4, i32* %7)
%11 = icmp eq i32* %10, null
br i1 %11, label %16, label %12
12: ; preds = %9, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%14 = call i32* @fgets(i8* %6, i32 %4, i32* %7)
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %12
16: ; preds = %12, %9
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 @fclose(i32* %7)
br label %21
19: ; preds = %3
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
ret void
}