#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*/ *openUserFile(char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ wordCounter(int /*<<< orphan*/ *, int *, int *, int *);
int main(int argc, const char *argv[]) {
  FILE *infile = NULL;
  int nLines, nWords, nChars;
  infile = openUserFile("File: ", "r");
  wordCounter(infile, &nLines, &nWords, &nChars);
  printf("Lines:%6d\n", nLines);
  printf("Words:%6d\n", nWords);
  printf("Chars:%6d\n", nChars);
  fclose(infile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe9b(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <openUserFile@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x24(%rbp),%rcx
call   1060 <wordCounter@plt>
mov    -0x1c(%rbp),%esi
lea    0xe75(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <openUserFile@plt>
mov    %rax,%rbx
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rax,%rdi
call   1060 <wordCounter@plt>
mov    0xc(%rsp),%esi
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%esi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"File: \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"Lines:%6d\0A\00"
@.str.3 = [11 x i8] c"Words:%6d\0A\00"
@.str.4 = [11 x i8] c"Chars:%6d\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %6
%10 = call i32* @openUserFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i32*, i32** %6
%12 = call i32 @wordCounter(i32* %11, i32* %7, i32* %8, i32* %9)
%13 = load i32, i32* %7
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %8
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %9
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = load i32*, i32** %6
%20 = call i32 @fclose(i32* %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"File: \00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"Lines:%6d\0A\00"
@.str.3 = [11 x i8] c"Words:%6d\0A\00"
@.str.4 = [11 x i8] c"Chars:%6d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = tail call i32* @openUserFile(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @wordCounter(i32* %9, i32* %3, i32* %4, i32* %5)
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %4
%14 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %5
%16 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 %15)
%17 = call i32 @fclose(i32* %9)
ret i32 0
}