#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*/ digit_stats(int, long);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, int *, long *);
int main(int argc, const char *argv[]) {
  FILE *file = fopen(argv[1], "r");
  int a;
  long int n;
  while (fscanf(file, "%d %ld\n", &a, &n) != EOF) {
    digit_stats(a, n);
  }
  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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe99(%rip),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <fscanf@plt>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     1197 <main+0x67>
mov    -0x1c(%rbp),%edi
mov    -0x28(%rbp),%rsi
call   1040 <digit_stats@plt>
jmp    115e <main+0x2e>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
lea    0xeb8(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0xeab(%rip),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rax,%rdi
call   1030 <fscanf@plt>
mov    0x2e78(%rip),%r13
cmp    0x0(%r13),%rax
je     11b5 <main+0x85>
lea    0xe85(%rip),%r14
lea    0x4(%rsp),%r15
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%rsi
call   1040 <digit_stats@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <fscanf@plt>
cmp    0x0(%r13),%rax
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"%d %ld\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %6
br label %13
13: ; preds = %18, %2
%14 = load i32*, i32** %6
%15 = call i64 @fscanf(i32* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %7, i64* %8)
%16 = load i64, i64* @EOF
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %7
%20 = load i64, i64* %8
%21 = call i32 @digit_stats(i32 %19, i64 %20)
br label %13
22: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [8 x i8] c"%d %ld\0A\00"
@EOF = global i64 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i64
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = bitcast i32* %3 to i8*
%9 = bitcast i64* %4 to i8*
%10 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %3, i64* %4)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %20, label %13
13: ; preds = %2, %13
%14 = load i32, i32* %3
%15 = load i64, i64* %4
%16 = call i32 @digit_stats(i32 %14, i64 %15)
%17 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32* %3, i64* %4)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %20, label %13
20: ; preds = %13, %2
ret i32 0
}