#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 */

/* Variables and functions */
char *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ gritou(char *);
scalar_t__ obterValor(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdin;
int main(void) {
  char str[16], *str_ptr;
  int numeros[3] = {0, 0, 0}, ultimoIndice = 0, i;
  while (str_ptr = fgets(str, 16, stdin), str_ptr) {
    if (gritou(str)) {
      ultimoIndice++;
    } else {
      numeros[ultimoIndice] += obterValor(str);
    }
  }
  for (i = 0; i < 3; i++) {
    printf("%d\n", numeros[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x34(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
movl   $0x0,-0x38(%rbp)
lea    -0x20(%rbp),%rdi
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1070 <fgets@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11de <main+0x8e>
lea    -0x20(%rbp),%rdi
call   1030 <gritou@plt>
cmp    $0x0,%rax
je     11bd <main+0x6d>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11d9 <main+0x89>
lea    -0x20(%rbp),%rdi
call   1040 <obterValor@plt>
mov    %rax,%rdx
movslq -0x38(%rbp),%rax
movslq -0x34(%rbp,%rax,4),%rcx
add    %rdx,%rcx
mov    %ecx,-0x34(%rbp,%rax,4)
jmp    1176 <main+0x26>
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x3c(%rbp)
jge    1211 <main+0xc1>
movslq -0x3c(%rbp),%rax
mov    -0x34(%rbp,%rax,4),%esi
lea    0xe02(%rip),%rdi
call   1050 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e5 <main+0x95>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
mov    0x2e89(%rip),%r14
mov    (%r14),%edx
lea    0x10(%rsp),%rdi
mov    $0x10,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11c3 <main+0x83>
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
jmp    11a3 <main+0x63>
nop
mov    %rbx,%rdi
call   1040 <obterValor@plt>
movslq %ebp,%rcx
add    %eax,(%rsp,%rcx,4)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x10,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11b5 <main+0x75>
mov    %rbx,%rdi
call   1030 <gritou@plt>
test   %rax,%rax
je     1180 <main+0x40>
add    $0x1,%ebp
jmp    118e <main+0x4e>
mov    (%rsp),%esi
mov    0x4(%rsp),%ebp
mov    0x8(%rsp),%r14d
jmp    11ca <main+0x8a>
xor    %r14d,%r14d
xor    %ebp,%ebp
xor    %esi,%esi
lea    0xe2f(%rip),%rbx
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [16 x i8]
%3 = alloca i8*
%4 = alloca [3 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [3 x i32]* %4 to i8*
store i32 0, i32* %5
br label %8
8: ; preds = %31, %0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i8* @fgets(i8* %9, i32 16, i32 %10)
store i8* %11, i8** %3
%12 = load i8*, i8** %3
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %32
14: ; preds = %8
%15 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%16 = call i64 @gritou(i8* %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %31
21: ; preds = %14
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%23 = call i64 @obterValor(i8* %22)
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = sext i32 %27 to i64
%29 = add nsw i64 %28, %23
%30 = trunc i64 %29 to i32
store i32 %30, i32* %26
br label %31
31: ; preds = %21, %18
br label %8
32: ; preds = %8
store i32 0, i32* %6
br label %33
33: ; preds = %42, %32
%34 = load i32, i32* %6
%35 = icmp slt i32 %34, 3
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i32, i32* %6
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %36
%43 = load i32, i32* %6
%44 = add nsw i32 %43, 1
store i32 %44, i32* %6
br label %33
45: ; preds = %33
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = alloca [3 x i32]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%4 = bitcast [3 x i32]* %2 to i8*
%5 = load i32, i32* @stdin
%6 = call i8* @fgets(i8* %3, i32 16, i32 %5)
%7 = icmp eq i8* %6, null
br i1 %7, label %15, label %22
8: ; preds = %35
%9 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%14 = load i32, i32* %13
br label %15
15: ; preds = %8, %0
%16 = phi i32 [ %14, %8 ], [ 0, %0 ]
%17 = phi i32 [ %12, %8 ], [ 0, %0 ]
%18 = phi i32 [ %10, %8 ], [ 0, %0 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %17)
%21 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
ret i32 0
22: ; preds = %0, %35
%23 = phi i32 [ %36, %35 ], [ 0, %0 ]
%24 = call i64 @gritou(i8* %3)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = add nsw i32 %23, 1
br label %35
28: ; preds = %22
%29 = call i64 @obterValor(i8* %3)
%30 = sext i32 %23 to i64
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = trunc i64 %29 to i32
%34 = add i32 %32, %33
store i32 %34, i32* %31
br label %35
35: ; preds = %28, %26
%36 = phi i32 [ %27, %26 ], [ %23, %28 ]
%37 = load i32, i32* @stdin
%38 = call i8* @fgets(i8* %3, i32 16, i32 %37)
%39 = icmp eq i8* %38, null
br i1 %39, label %8, label %22
}