#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 pow(int, int);
int convert(char *buffer) {
  int c = 0, t = 0;
  int i;
  for (i = 7; i >= 0; i--) {
    c += (buffer[7 - i] - '0') * pow(2, i);
  }
  return c;
}


x86 assembly (clang, -O0):
<convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x7,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1180 <convert+0x70>
mov    -0x8(%rbp),%rax
mov    $0x7,%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1030 <pow@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
movsbl %cl,%ecx
imul   %ecx,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <convert+0x21>
mov    -0xc(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movsbl (%rdi),%ebp
add    $0xffffffd0,%ebp
mov    $0x2,%edi
mov    $0x7,%esi
call   1030 <pow@plt>
movsbl %al,%r15d
imul   %ebp,%r15d
movsbl 0x1(%r14),%ebp
add    $0xffffffd0,%ebp
mov    $0x2,%edi
mov    $0x6,%esi
call   1030 <pow@plt>
movsbl %al,%ebx
imul   %ebp,%ebx
add    %r15d,%ebx
movsbl 0x2(%r14),%r15d
add    $0xffffffd0,%r15d
mov    $0x2,%edi
mov    $0x5,%esi
call   1030 <pow@plt>
movsbl %al,%ebp
imul   %r15d,%ebp
add    %ebx,%ebp
movsbl 0x3(%r14),%r15d
add    $0xffffffd0,%r15d
mov    $0x2,%edi
mov    $0x4,%esi
call   1030 <pow@plt>
movsbl %al,%ebx
imul   %r15d,%ebx
add    %ebp,%ebx
movsbl 0x4(%r14),%r15d
add    $0xffffffd0,%r15d
mov    $0x2,%edi
mov    $0x3,%esi
call   1030 <pow@plt>
movsbl %al,%ebp
imul   %r15d,%ebp
add    %ebx,%ebp
movsbl 0x5(%r14),%r15d
add    $0xffffffd0,%r15d
mov    $0x2,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
movsbl %al,%ebx
imul   %r15d,%ebx
add    %ebp,%ebx
movsbl 0x6(%r14),%r15d
add    $0xffffffd0,%r15d
mov    $0x2,%edi
mov    $0x1,%esi
call   1030 <pow@plt>
movsbl %al,%ebp
imul   %r15d,%ebp
add    %ebx,%ebp
movsbl 0x7(%r14),%ebx
add    $0xffffffd0,%ebx
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <pow@plt>
movsbl %al,%eax
imul   %ebx,%eax
add    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @convert(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 7, i32* %5
br label %6
6: ; preds = %24, %1
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %27
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %5
%12 = sub nsw i32 7, %11
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = sub nsw i32 %16, 48
%18 = load i32, i32* %5
%19 = call signext i8 @pow(i32 2, i32 %18)
%20 = sext i8 %19 to i32
%21 = mul nsw i32 %17, %20
%22 = load i32, i32* %3
%23 = add nsw i32 %22, %21
store i32 %23, i32* %3
br label %24
24: ; preds = %9
%25 = load i32, i32* %5
%26 = add nsw i32 %25, -1
store i32 %26, i32* %5
br label %6
27: ; preds = %6
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
define i32 @convert(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
%4 = add nsw i32 %3, -48
%5 = tail call signext i8 @pow(i32 2, i32 7)
%6 = sext i8 %5 to i32
%7 = mul nsw i32 %4, %6
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = add nsw i32 %10, -48
%12 = tail call signext i8 @pow(i32 2, i32 6)
%13 = sext i8 %12 to i32
%14 = mul nsw i32 %11, %13
%15 = add nsw i32 %14, %7
%16 = getelementptr inbounds i8, i8* %0, i64 2
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = add nsw i32 %18, -48
%20 = tail call signext i8 @pow(i32 2, i32 5)
%21 = sext i8 %20 to i32
%22 = mul nsw i32 %19, %21
%23 = add nsw i32 %22, %15
%24 = getelementptr inbounds i8, i8* %0, i64 3
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = add nsw i32 %26, -48
%28 = tail call signext i8 @pow(i32 2, i32 4)
%29 = sext i8 %28 to i32
%30 = mul nsw i32 %27, %29
%31 = add nsw i32 %30, %23
%32 = getelementptr inbounds i8, i8* %0, i64 4
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = add nsw i32 %34, -48
%36 = tail call signext i8 @pow(i32 2, i32 3)
%37 = sext i8 %36 to i32
%38 = mul nsw i32 %35, %37
%39 = add nsw i32 %38, %31
%40 = getelementptr inbounds i8, i8* %0, i64 5
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = add nsw i32 %42, -48
%44 = tail call signext i8 @pow(i32 2, i32 2)
%45 = sext i8 %44 to i32
%46 = mul nsw i32 %43, %45
%47 = add nsw i32 %46, %39
%48 = getelementptr inbounds i8, i8* %0, i64 6
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = add nsw i32 %50, -48
%52 = tail call signext i8 @pow(i32 2, i32 1)
%53 = sext i8 %52 to i32
%54 = mul nsw i32 %51, %53
%55 = add nsw i32 %54, %47
%56 = getelementptr inbounds i8, i8* %0, i64 7
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = add nsw i32 %58, -48
%60 = tail call signext i8 @pow(i32 2, i32 0)
%61 = sext i8 %60 to i32
%62 = mul nsw i32 %59, %61
%63 = add nsw i32 %62, %55
ret i32 %63
}