#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char line[80];
  FILE *ifp, *ofp;
  if (argc != 2) {
    fprintf(stderr, "specify an input file\n");
    return 1;
  }
  int sum_count = 0;
  int sum_point = 0;
  ifp = fopen(argv[1], "r");
  while (fgets(line, sizeof(line), ifp) != NULL) {
    char *count_s, *point_s;
    char *cp = line;
    int len = (int)strlen(line);
    if (cp[len - 1] == '\n') {
      cp[len - 1] = '\0';
    }
    cp = strchr(line, ' ');
    count_s = cp + 1;
    cp = strchr(line, '/');
    point_s = cp + 1;
    cp[0] = '\0';
    sum_count += atoi(count_s);
    sum_point += atoi(point_s);
  }
  fclose(ifp);
  double pi = 4.0 * sum_count / sum_point;
  printf("%f\n", pi);
  ofp = fopen("pi.out", "w");
  fprintf(ofp, "%f\n", pi);
  fclose(ofp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c7 <main+0x47>
mov    0x2e36(%rip),%rax
movslq (%rax),%rdi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1363 <main+0x1e3>
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe3b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    $0x50,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12e3 <main+0x163>
lea    -0x60(%rbp),%rax
mov    %rax,-0x90(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x94(%rbp)
mov    -0x90(%rbp),%rax
mov    -0x94(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    125a <main+0xda>
mov    -0x90(%rbp),%rax
mov    -0x94(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
lea    -0x60(%rbp),%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
mov    -0x90(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x80(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %rax,%rcx
movslq -0x74(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x74(%rbp)
mov    -0x88(%rbp),%rdi
call   10a0 <atoi@plt>
mov    %rax,%rcx
movslq -0x78(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x78(%rbp)
jmp    11ed <main+0x6d>
mov    -0x68(%rbp),%rdi
call   1030 <fclose@plt>
cvtsi2sdl -0x74(%rbp),%xmm1
movsd  0xd07(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x78(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
lea    0xd04(%rip),%rdi
call   1060 <printf@plt>
lea    0xcfc(%rip),%rdi
lea    0xcfc(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
movsd  -0xa0(%rbp),%xmm0
ff
lea    0xcd5(%rip),%rsi
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
cmp    $0x2,%edi
jne    1249 <main+0xb9>
mov    0x8(%rsi),%rdi
lea    0xe6d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r14
lea    0x10(%rsp),%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1282 <main+0xf2>
xor    %ebp,%ebp
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
jmp    122e <main+0x9e>
mov    %r15,%rdi
mov    $0x20,%esi
call   1050 <strchr@plt>
lea    0x1(%rax),%r13
mov    %r15,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
movb   $0x0,(%rax)
lea    0x1(%rax),%r12
mov    %r13,%rdi
call   10a0 <atoi@plt>
add    %eax,%ebp
mov    %r12,%rdi
call   10a0 <atoi@plt>
add    %eax,%ebx
mov    %r15,%rdi
mov    $0x50,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1270 <main+0xe0>
mov    %r15,%rdi
call   1040 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmpb   $0xa,0x10(%rsp,%rax,1)
jne    11e0 <main+0x50>
movb   $0x0,0x10(%rsp,%rax,1)
jmp    11e0 <main+0x50>
mov    0x2d90(%rip),%rax
movslq (%rax),%rcx
lea    0xdae(%rip),%rdi
mov    $0x16,%esi
mov    $0x1,%edx
call   10b0 <fwrite@plt>
mov    $0x1,%eax
jmp    12e4 <main+0x154>
cvtsi2sd %ebp,%xmm1
mulsd  0xd84(%rip),%xmm1
cvtsi2sd %ebx,%xmm0
jmp    128a <main+0xfa>
xorpd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
mov    %r14,%rdi
call   1030 <fclose@plt>
lea    0xd7e(%rip),%r14
mov    %r14,%rdi
movsd  0x8(%rsp),%xmm0
call   1060 <printf@plt>
lea    0xd6d(%rip),%rdi
lea    0xd6d(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1080 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"specify an input file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%f\0A\00"
@.str.3 = [7 x i8] c"pi.out\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [80 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = sext i32 %19 to i64
%21 = inttoptr i64 %20 to i32*
%22 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %92
23: ; preds = %2
store i32 0, i32* %9
store i32 0, i32* %10
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %27, i32** %7
br label %28
28: ; preds = %52, %23
%29 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%30 = load i32*, i32** %7
%31 = call i32* @fgets(i8* %29, i32 80, i32* %30)
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %75
33: ; preds = %28
%34 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
store i8* %34, i8** %13
%35 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%36 = call i64 @strlen(i8* %35)
%37 = trunc i64 %36 to i32
store i32 %37, i32* %14
%38 = load i8*, i8** %13
%39 = load i32, i32* %14
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 10
br i1 %45, label %46, label %52
46: ; preds = %33
%47 = load i8*, i8** %13
%48 = load i32, i32* %14
%49 = sub nsw i32 %48, 1
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8 0, i8* %51
br label %52
52: ; preds = %46, %33
%53 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%54 = call i8* @strchr(i8* %53, i8 signext 32)
store i8* %54, i8** %13
%55 = load i8*, i8** %13
%56 = getelementptr inbounds i8, i8* %55, i64 1
store i8* %56, i8** %11
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %6, i64 0, i64 0
%58 = call i8* @strchr(i8* %57, i8 signext 47)
store i8* %58, i8** %13
%59 = load i8*, i8** %13
%60 = getelementptr inbounds i8, i8* %59, i64 1
store i8* %60, i8** %12
%61 = load i8*, i8** %13
%62 = getelementptr inbounds i8, i8* %61, i64 0
store i8 0, i8* %62
%63 = load i8*, i8** %11
%64 = call i64 @atoi(i8* %63)
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = add nsw i64 %66, %64
%68 = trunc i64 %67 to i32
store i32 %68, i32* %9
%69 = load i8*, i8** %12
%70 = call i64 @atoi(i8* %69)
%71 = load i32, i32* %10
%72 = sext i32 %71 to i64
%73 = add nsw i64 %72, %70
%74 = trunc i64 %73 to i32
store i32 %74, i32* %10
br label %28
75: ; preds = %28
%76 = load i32*, i32** %7
%77 = call i32 @fclose(i32* %76)
%78 = load i32, i32* %9
%79 = sitofp i32 %78 to double
%80 = fmul double 4.000000e+00, %79
%81 = load i32, i32* %10
%82 = sitofp i32 %81 to double
%83 = fdiv double %80, %82
store double %83, double* %15
%84 = load double, double* %15
%85 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %84)
%86 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 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* %86, i32** %8
%87 = load i32*, i32** %8
%88 = load double, double* %15
%89 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %88)
%90 = load i32*, i32** %8
%91 = call i32 @fclose(i32* %90)
store i32 0, i32* %3
br label %92
92: ; preds = %75, %18
%93 = load i32, i32* %3
ret i32 %93
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"specify an input file\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [4 x i8] c"%f\0A\00"
@.str.3 = [7 x i8] c"pi.out\00"
@.str.4 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = tail call i64 @fwrite(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 22, i64 1, i32* %9)
br label %54
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32* @fgets(i8* %4, i32 80, i32* %14)
%16 = icmp eq i32* %15, null
br i1 %16, label %45, label %17
17: ; preds = %11, %28
%18 = phi i32 [ %35, %28 ], [ 0, %11 ]
%19 = phi i32 [ %38, %28 ], [ 0, %11 ]
%20 = call i64 @strlen(i8* %4)
%21 = shl i64 %20, 32
%22 = add i64 %21, -4294967296
%23 = ashr exact i64 %22, 32
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = icmp eq i8 %25, 10
br i1 %26, label %27, label %28
27: ; preds = %17
store i8 0, i8* %24
br label %28
28: ; preds = %27, %17
%29 = call i8* @strchr(i8* %4, i8 signext 32)
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i8* @strchr(i8* %4, i8 signext 47)
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8 0, i8* %31
%33 = call i64 @atoi(i8* %30)
%34 = trunc i64 %33 to i32
%35 = add i32 %18, %34
%36 = call i64 @atoi(i8* %32)
%37 = trunc i64 %36 to i32
%38 = add i32 %19, %37
%39 = call i32* @fgets(i8* %4, i32 80, i32* %14)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %17
41: ; preds = %28
%42 = sitofp i32 %35 to double
%43 = fmul double %42, 4.000000e+00
%44 = sitofp i32 %38 to double
br label %45
45: ; preds = %41, %11
%46 = phi double [ 0.000000e+00, %11 ], [ %44, %41 ]
%47 = phi double [ 0.000000e+00, %11 ], [ %43, %41 ]
%48 = call i32 @fclose(i32* %14)
%49 = fdiv double %47, %46
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %49)
%51 = call i32* @fopen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%52 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %49)
%53 = call i32 @fclose(i32* %51)
br label %54
54: ; preds = %45, %6
%55 = phi i32 [ 1, %6 ], [ 0, %45 ]
ret i32 %55
}