#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
main() {
  FILE *fp;
  char hinmei[30];
  int tanka, suryo, sum = 0;
  fp = fopen("uriage.txt", "r");
  if (fp == NULL) {
    printf("ファイルがオープンできません。\n");
    exit(1);
  }
  while (fscanf(fp, "%s %d %d", hinmei, &tanka, &suryo) != EOF) {
    printf("%s %d %d\n", hinmei, tanka, suryo);
    sum += tanka * suryo;
  }
  fclose(fp);
  puts("");
  printf("売り上げ金額は、%d円です。\n", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    0xe83(%rip),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b0 <main+0x50>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11b5 <main+0x55>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe78(%rip),%rsi
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1060 <fscanf@plt>
mov    0x2e10(%rip),%rcx
cmp    (%rcx),%rax
je     120b <main+0xab>
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x34(%rbp),%eax
imul   -0x38(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    11b5 <main+0x55>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe33(%rip),%rdi
call   1030 <puts@plt>
mov    -0x3c(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
lea    0xe7b(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1255 <main+0xe5>
mov    %rax,%r15
lea    0xe69(%rip),%rsi
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rax,%rdi
call   1070 <fscanf@plt>
mov    0x2e26(%rip),%r12
xor    %ebp,%ebp
cmp    (%r12),%rax
je     1222 <main+0xb2>
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r13
lea    0x8(%rsp),%r14
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe27(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%eax
imul   0xc(%rsp),%eax
add    %eax,%ebp
mov    %r15,%rdi
lea    0xdff(%rip),%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r14,%r8
call   1070 <fscanf@plt>
cmp    (%r12),%rax
jne    11e0 <main+0x70>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xde5(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdec(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"uriage.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB\E3\81\8C\E3\82\AA\E3\83\BC\E3\83\97\E3\83\B3\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\E3\80\82\0A\00"
@.str.3 = [9 x i8] c"%s %d %d\00"
@EOF = global i64 0
@.str.4 = [10 x i8] c"%s %d %d\0A\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [40 x i8] c"\E5\A3\B2\E3\82\8A\E4\B8\8A\E3\81\92\E9\87\91\E9\A1\8D\E3\81\AF\E3\80\81%d\E5\86\86\E3\81\A7\E3\81\99\E3\80\82\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [30 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %0
br label %14
14: ; preds = %20, %13
%15 = load i32*, i32** %2
%16 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%17 = call i64 @fscanf(i32* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %16, i32* %4, i32* %5)
%18 = load i64, i64* @EOF
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %21, i32 %22, i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = mul nsw i32 %25, %26
%28 = load i32, i32* %6
%29 = add nsw i32 %28, %27
store i32 %29, i32* %6
br label %14
30: ; preds = %14
%31 = load i32*, i32** %2
%32 = call i32 @fclose(i32* %31)
%33 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0))
%34 = load i32, i32* %6
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [11 x i8] c"uriage.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [9 x i8] c"%s %d %d\00"
@EOF = global i64 0
@.str.4 = [10 x i8] c"%s %d %d\0A\00"
@.str.6 = [40 x i8] c"\E5\A3\B2\E3\82\8A\E4\B8\8A\E3\81\92\E9\87\91\E9\A1\8D\E3\81\AF\E3\80\81%d\E5\86\86\E3\81\A7\E3\81\99\E3\80\82\0A\00"
@str = [46 x i8] c"\E3\83\95\E3\82\A1\E3\82\A4\E3\83\AB\E3\81\8C\E3\82\AA\E3\83\BC\E3\83\97\E3\83\B3\E3\81\A7\E3\81\8D\E3\81\BE\E3\81\9B\E3\82\93\E3\80\82\00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32* %2, i32* %3)
%11 = load i64, i64* @EOF
%12 = icmp eq i64 %10, %11
br i1 %12, label %28, label %16
13: ; preds = %0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %16
%17 = phi i32 [ %24, %16 ], [ 0, %9 ]
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %18, i32 %19)
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = mul nsw i32 %22, %21
%24 = add nsw i32 %23, %17
%25 = call i64 @fscanf(i32* %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %4, i32* %2, i32* %3)
%26 = load i64, i64* @EOF
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %16
28: ; preds = %16, %9
%29 = phi i32 [ 0, %9 ], [ %24, %16 ]
%30 = call i32 @fclose(i32* %7)
%31 = call i32 @putchar(i32 10)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %29)
ret i32 0
}