#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__ isdigit(unsigned char);
scalar_t__ islower(unsigned char);
int width_of_partial(unsigned char *partial) {
  int i = 0;
  while (*partial) {
    if (isdigit(*partial))
      i += *partial - '0';
    else if (islower(*partial))
      i += *partial - 'a' + 1;
    partial++;
  }
  return i;
}


x86 assembly (clang, -O0):
<width_of_partial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11aa <width_of_partial+0x8a>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     116b <width_of_partial+0x4b>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sub    $0x30,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1199 <width_of_partial+0x79>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1040 <islower@plt>
cmp    $0x0,%rax
je     1194 <width_of_partial+0x74>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
sub    $0x61,%eax
add    $0x1,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1199 <width_of_partial+0x79>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1133 <width_of_partial+0x13>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<width_of_partial>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1179 <width_of_partial+0x59>
mov    %rdi,%rbx
xor    %r14d,%r14d
jmp    1153 <width_of_partial+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %edi,%r14d
add    $0xffffffd0,%r14d
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     117c <width_of_partial+0x5c>
movzbl %al,%edi
call   1030 <isdigit@plt>
movzbl (%rbx),%edi
test   %rax,%rax
jne    1140 <width_of_partial+0x20>
call   1040 <islower@plt>
test   %rax,%rax
je     1147 <width_of_partial+0x27>
movzbl (%rbx),%eax
add    %eax,%r14d
add    $0xffffffa0,%r14d
jmp    1147 <width_of_partial+0x27>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @width_of_partial(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %34, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %37
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = call i64 @isdigit(i8 zeroext %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = sub nsw i32 %16, 48
%18 = load i32, i32* %3
%19 = add nsw i32 %18, %17
store i32 %19, i32* %3
br label %34
20: ; preds = %8
%21 = load i8*, i8** %2
%22 = load i8, i8* %21
%23 = call i64 @islower(i8 zeroext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %20
%26 = load i8*, i8** %2
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = sub nsw i32 %28, 97
%30 = add nsw i32 %29, 1
%31 = load i32, i32* %3
%32 = add nsw i32 %31, %30
store i32 %32, i32* %3
br label %33
33: ; preds = %25, %20
br label %34
34: ; preds = %33, %13
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i32 1
store i8* %36, i8** %2
br label %4
37: ; preds = %4
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
define i32 @width_of_partial(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %1, %23
%5 = phi i8 [ %26, %23 ], [ %2, %1 ]
%6 = phi i32 [ %24, %23 ], [ 0, %1 ]
%7 = phi i8* [ %25, %23 ], [ %0, %1 ]
%8 = tail call i64 @isdigit(i8 zeroext %5)
%9 = icmp eq i64 %8, 0
%10 = load i8, i8* %7
br i1 %9, label %15, label %11
11: ; preds = %4
%12 = zext i8 %10 to i32
%13 = add i32 %6, -48
%14 = add i32 %13, %12
br label %23
15: ; preds = %4
%16 = tail call i64 @islower(i8 zeroext %10)
%17 = icmp eq i64 %16, 0
br i1 %17, label %23, label %18
18: ; preds = %15
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = add i32 %6, -96
%22 = add i32 %21, %20
br label %23
23: ; preds = %15, %18, %11
%24 = phi i32 [ %14, %11 ], [ %22, %18 ], [ %6, %15 ]
%25 = getelementptr inbounds i8, i8* %7, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %4
28: ; preds = %23, %1
%29 = phi i32 [ 0, %1 ], [ %24, %23 ]
ret i32 %29
}