#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 */
int /*<<< orphan*/ printf(char *, int);
scalar_t__ processarCaractere(char);
int /*<<< orphan*/ scanf(char *, char *);
void processarLinha() {
  char linha[128];
  int sum = 0, i = 0;
  scanf("%s", linha);
  while (linha[i] != '\0') {
    sum += processarCaractere(linha[i]);
    i++;
  }
  printf("%d leds\n", sum);
}


x86 assembly (clang, -O0):
<processarLinha>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
lea    -0x80(%rbp),%rsi
lea    0xea6(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x88(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11ac <processarLinha+0x7c>
movslq -0x88(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1030 <processarCaractere@plt>
mov    %rax,%rcx
movslq -0x84(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x84(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    115f <processarLinha+0x2f>
mov    -0x84(%rbp),%esi
lea    0xe4a(%rip),%rdi
call   1040 <printf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processarLinha>:
push   %rbp
push   %rbx
sub    $0x88,%rsp
lea    0xec0(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1177 <processarLinha+0x47>
lea    0x1(%rsp),%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <processarCaractere@plt>
add    %eax,%ebp
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <processarLinha+0x30>
jmp    1179 <processarLinha+0x49>
xor    %ebp,%ebp
lea    0xe83(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
add    $0x88,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [9 x i8] c"%d leds\0A\00"
define void @processarLinha() {
%1 = alloca [128 x i8]
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %3
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %4)
br label %6
6: ; preds = %13, %0
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %6
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = call i64 @processarCaractere(i8 signext %17)
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %6
25: ; preds = %6
%26 = load i32, i32* %2
%27 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %26)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [9 x i8] c"%d leds\0A\00"
define void @processarLinha() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = load i8, i8* %2
%5 = icmp eq i8 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %0, %6
%7 = phi i64 [ %13, %6 ], [ 0, %0 ]
%8 = phi i8 [ %15, %6 ], [ %4, %0 ]
%9 = phi i32 [ %12, %6 ], [ 0, %0 ]
%10 = call i64 @processarCaractere(i8 signext %8)
%11 = trunc i64 %10 to i32
%12 = add i32 %9, %11
%13 = add nuw i64 %7, 1
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %6
17: ; preds = %6, %0
%18 = phi i32 [ 0, %0 ], [ %12, %6 ]
%19 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %18)
ret void
}