#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 atoi(char *);
scalar_t__ isalpha(char);
int strlen(char *);
int /*<<< orphan*/ strncat(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int roadmap_coord_fraction(const char *image) {
  int length;
  char normalized[16];
  if (image[0] == 0)
    return 0;
  strncpy(normalized, image, 6);
  normalized[6] = 0;
  length = strlen(normalized);
  if (isalpha(normalized[length - 1])) {
    normalized[length - 1] = 0;
  }
  strncat(normalized, "000000", 7);
  normalized[6] = 0;
  return atoi(normalized);
}


x86 assembly (clang, -O0):
<roadmap_coord_fraction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1178 <roadmap_coord_fraction+0x28>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <roadmap_coord_fraction+0x98>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x6,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x2a(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x30(%rbp,%rax,1),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     11c3 <roadmap_coord_fraction+0x73>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rdi
lea    0xe32(%rip),%rsi
mov    $0x7,%edx
call   1050 <strncat@plt>
movb   $0x0,-0x2a(%rbp)
lea    -0x30(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<roadmap_coord_fraction>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmpb   $0x0,(%rdi)
je     11ba <roadmap_coord_fraction+0x6a>
mov    %rdi,%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x6,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x6(%rsp)
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%rbx
movsbl -0x1(%rbx,%r14,1),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1194 <roadmap_coord_fraction+0x44>
movb   $0x0,-0x1(%rsp,%rbx,1)
lea    0xe65(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x7,%edx
call   1050 <strncat@plt>
movb   $0x0,0x6(%rsp)
mov    %rbx,%rdi
call   1070 <atoi@plt>
jmp    11bc <roadmap_coord_fraction+0x6c>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"000000\00"
define i32 @roadmap_coord_fraction(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [16 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %37
12: ; preds = %1
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @strncpy(i8* %13, i8* %14, i32 6)
%16 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 6
store i8 0, i8* %16
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @isalpha(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %12
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %26, %12
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%33 = call i32 @strncat(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 6
store i8 0, i8* %34
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %2
br label %37
37: ; preds = %31, %11
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
@.str = [7 x i8] c"000000\00"
define i32 @roadmap_coord_fraction(i8* %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = call i32 @strncpy(i8* %3, i8* %0, i32 6)
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 6
store i8 0, i8* %8
%9 = call i32 @strlen(i8* %3)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = call i64 @isalpha(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %6
store i8 0, i8* %12
br label %17
17: ; preds = %16, %6
%18 = call i32 @strncat(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
store i8 0, i8* %8
%19 = call i32 @atoi(i8* %3)
br label %20
20: ; preds = %1, %17
%21 = phi i32 [ %19, %17 ], [ 0, %1 ]
ret i32 %21
}