// File: /workspace/github_c_makefile_star2_O3/X1319RAY[P]fileIO/getline.cpp
// Function: main
int main(int argc, char* argv[]){
	using namespace std;
	
	// コマンドライン引数のチェック
	if(argc != 2){
		cerr << "引数の数が間違っています．" << endl;
		cerr << "./getline input.txt" << endl;
		return 1;
	}
	
	// C++のファイル入力のための準備
	ifstream ifs(argv[1], ios::in);
	// ファイルを開くのに失敗したときの処理
	if(!ifs){
		cerr << "Error: file not opened." << endl;
		return 1;
	}
	
	string tmp;
	string str;
	int num;
	int sum = 0;
	// getline()で1行ずつ読み込む
	while(getline(ifs, tmp)){
		// ここでtmpを煮るなり焼くなりする
		cout << tmp << endl; // そのまま出力
		stringstream ss;
		ss << tmp;
		ss >> str >> num; // str == "name:"; num == number;
		sum += num; // 値をsumに加算
	}
	
	cout << "\nsum: " << sum << endl;
	
	// ファイルを閉じる
	ifs.close();
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
cmpl $0x2, %edi
jne 0x1322
movq 0x8(%rsi), %rsi
leaq -0x400(%rbp), %r14
movq %r14, %rdi
movl $0x8, %edx
callq 0x1130
movq (%r14), %rax
movq -0x18(%rax), %rcx
testb $0x5, -0x3e0(%rbp,%rcx)
je 0x13a9
movq 0x2d17(%rip), %rbx      # 0x3ff0
leaq 0xd60(%rip), %rsi       # 0x2040
movl $0x17, %edx
movq %rbx, %rdi
callq 0x10e0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq 0x2ce5(%rip), %rdi      # 0x3ff0
callq 0x1030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x1080
jmp 0x152f
movq 0x2cc7(%rip), %rbx      # 0x3ff0
leaq 0xcd4(%rip), %rsi       # 0x2004
movl $0x27, %edx
movq %rbx, %rdi
callq 0x10e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
leaq 0xcc1(%rip), %rsi       # 0x202c
movl $0x13, %edx
movq %rbx, %rdi
callq 0x10e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
movl $0x1, %ebx
jmp 0x153b
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
xorl %ebx, %ebx
movq %rbx, -0x8(%rcx)
movb %bl, (%rcx)
leaq -0x60(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rbx, -0x8(%rcx)
movb %bl, (%rcx)
leaq -0x50(%rbp), %r13
leaq -0x1f8(%rbp), %r12
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %edx
movq %r14, %rdi
movq %r13, %rsi
callq 0x1140
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x149f
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq 0x2bbe(%rip), %rdi      # 0x3fd0
callq 0x10e0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %r15, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
movq %r12, %rdi
callq 0x1090
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
leaq -0x1e8(%rbp), %rdi
callq 0x10e0
movq %r12, %rdi
leaq -0x70(%rbp), %rsi
callq 0x10f0
movq %rax, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x1070
addl -0x2c(%rbp), %ebx
movq %r12, %rdi
movq 0x2b36(%rip), %rsi      # 0x3fb8
callq 0x10a0
leaq -0x178(%rbp), %rdi
callq 0x1060
movq -0x400(%rbp), %rax
jmp 0x13d2
movq 0x2b2a(%rip), %rdi      # 0x3fd0
leaq 0xbab(%rip), %rsi       # 0x2058
movl $0x6, %edx
callq 0x10e0
movq 0x2b12(%rip), %rdi      # 0x3fd0
movl %ebx, %esi
callq 0x1110
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x10c0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x1030
movq %rax, %rdi
callq 0x1080
leaq -0x400(%rbp), %rdi
callq 0x1040
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x1514
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x152d
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10d0
xorl %ebx, %ebx
leaq -0x400(%rbp), %rdi
callq 0x1050
movl %ebx, %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x157c
movq %rax, %rbx
jmp 0x15b1
jmp 0x157c
movq %rax, %rbx
movq 0x2a56(%rip), %rsi      # 0x3fb8
leaq -0x1f8(%rbp), %rdi
callq 0x10a0
leaq -0x178(%rbp), %rdi
callq 0x1060
jmp 0x157f
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x1598
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x10d0
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x15b1
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x10d0
leaq -0x400(%rbp), %rdi
callq 0x1050
movq %rbx, %rdi
callq 0x1120