#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 */
scalar_t__ calloc(int, int);
unsigned char getc(int /*<<< orphan*/);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *args[]) {
  int res = 0;
  int i = 0;
  int *vetor;
  unsigned char ch;
  printf("Programa de verificacao\n\n");
  while ((ch = getc(stdin)) != '\n') {
    vetor = (int *)calloc(i + 1, sizeof(int));
    vetor[i] = ch;
    printf("==== %c - %i - %c \n", ch, i, vetor[i]);
    if (vetor[i] == '0') {
      printf("Elemento 0 do vetor I=%c\n", ch);
    } else {
      res = res + pow(2, i);
      printf("Elemento 1 do vetor I=%c - %i - %i\n", vetor[i], vetor[i], res);
    }
    i++;
  }
  printf("Valor de Resultado: %i", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
call   1060 <getc@plt>
mov    %al,-0x21(%rbp)
movzbl %al,%eax
cmp    $0xa,%eax
je     124d <main+0x10d>
mov    -0x18(%rbp),%edi
add    $0x1,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
movzbl -0x21(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movzbl -0x21(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpl   $0x30,(%rax,%rcx,4)
jne    11fb <main+0xbb>
movzbl -0x21(%rbp),%esi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123f <main+0xff>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%esi
mov    $0x2,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x14(%rbp),%ecx
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <main+0x32>
mov    -0x14(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e7a(%rip),%r12
mov    (%r12),%edi
call   1070 <getc@plt>
xor    %r13d,%r13d
cmp    $0xa,%al
jne    11a0 <main+0x50>
lea    0xecd(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe59(%rip),%r14
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11e7 <main+0x97>
xchg   %ax,%ax
mov    $0x2,%edi
mov    %ebx,%esi
call   1060 <pow@plt>
add    %eax,%r13d
mov    (%r15,%rbx,4),%edx
lea    0xe64(%rip),%rdi
mov    %edx,%esi
mov    %r13d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edi
call   1070 <getc@plt>
add    $0x1,%rbx
cmp    $0xa,%al
je     117e <main+0x2e>
movzbl %al,%ebp
lea    0x1(%rbx),%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,%r15
mov    %ebp,(%rax,%rbx,4)
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x30,(%r15,%rbx,4)
jne    11b0 <main+0x60>
lea    0xdf9(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d6 <main+0x86>

LLVM IR (-O0):
@.str = [26 x i8] c"Programa de verificacao\0A\0A\00"
@stdin = global i32 0
@.str.1 = [20 x i8] c"==== %c - %i - %c \0A\00"
@.str.2 = [26 x i8] c"Elemento 0 do vetor I=%c\0A\00"
@.str.3 = [36 x i8] c"Elemento 1 do vetor I=%c - %i - %i\0A\00"
@.str.4 = [23 x i8] c"Valor de Resultado: %i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %63, %2
%12 = load i32, i32* @stdin
%13 = call zeroext i8 @getc(i32 %12)
store i8 %13, i8* %9
%14 = zext i8 %13 to i32
%15 = icmp ne i32 %14, 10
br i1 %15, label %16, label %66
16: ; preds = %11
%17 = load i32, i32* %7
%18 = add nsw i32 %17, 1
%19 = call i64 @calloc(i32 %18, i32 4)
%20 = inttoptr i64 %19 to i32*
store i32* %20, i32** %8
%21 = load i8, i8* %9
%22 = zext i8 %21 to i32
%23 = load i32*, i32** %8
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
%27 = load i8, i8* %9
%28 = zext i8 %27 to i32
%29 = load i32, i32* %7
%30 = load i32*, i32** %8
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = load i32, i32* %33
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29, i32 %34)
%36 = load i32*, i32** %8
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %36, i64 %38
%40 = load i32, i32* %39
%41 = icmp eq i32 %40, 48
br i1 %41, label %42, label %46
42: ; preds = %16
%43 = load i8, i8* %9
%44 = zext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %44)
br label %63
46: ; preds = %16
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 @pow(i32 2, i32 %48)
%50 = add nsw i32 %47, %49
store i32 %50, i32* %6
%51 = load i32*, i32** %8
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
%55 = load i32, i32* %54
%56 = load i32*, i32** %8
%57 = load i32, i32* %7
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i32, i32* %56, i64 %58
%60 = load i32, i32* %59
%61 = load i32, i32* %6
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %55, i32 %60, i32 %61)
br label %63
63: ; preds = %46, %42
%64 = load i32, i32* %7
%65 = add nsw i32 %64, 1
store i32 %65, i32* %7
br label %11
66: ; preds = %11
%67 = load i32, i32* %6
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %67)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [20 x i8] c"==== %c - %i - %c \0A\00"
@.str.2 = [26 x i8] c"Elemento 0 do vetor I=%c\0A\00"
@.str.3 = [36 x i8] c"Elemento 1 do vetor I=%c - %i - %i\0A\00"
@.str.4 = [23 x i8] c"Valor de Resultado: %i\00"
@str = [25 x i8] c"Programa de verificacao\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = tail call zeroext i8 @getc(i32 %4)
%6 = icmp eq i8 %5, 10
br i1 %6, label %33, label %7
7: ; preds = %2, %28
%8 = phi i64 [ %12, %28 ], [ 0, %2 ]
%9 = phi i8 [ %31, %28 ], [ %5, %2 ]
%10 = phi i32 [ %29, %28 ], [ 0, %2 ]
%11 = zext i8 %9 to i32
%12 = add nuw i64 %8, 1
%13 = trunc i64 %12 to i32
%14 = tail call i64 @calloc(i32 %13, i32 4)
%15 = inttoptr i64 %14 to i32*
%16 = getelementptr inbounds i32, i32* %15, i64 %8
store i32 %11, i32* %16
%17 = trunc i64 %8 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %17, i32 %11)
%19 = load i32, i32* %16
%20 = icmp eq i32 %19, 48
br i1 %20, label %21, label %23
21: ; preds = %7
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %28
23: ; preds = %7
%24 = tail call i32 @pow(i32 2, i32 %17)
%25 = add nsw i32 %24, %10
%26 = load i32, i32* %16
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %26, i32 %25)
br label %28
28: ; preds = %23, %21
%29 = phi i32 [ %10, %21 ], [ %25, %23 ]
%30 = load i32, i32* @stdin
%31 = tail call zeroext i8 @getc(i32 %30)
%32 = icmp eq i8 %31, 10
br i1 %32, label %33, label %7
33: ; preds = %28, %2
%34 = phi i32 [ 0, %2 ], [ %29, %28 ]
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %34)
ret i32 0
}