#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 toint(char);
int system_code(char fascn[40]) {
  int temp;
  temp = toint(fascn[6]) * 1000;
  temp += toint(fascn[7]) * 100;
  temp += toint(fascn[8]) * 10;
  temp += toint(fascn[9]);
  return (temp);
}


x86 assembly (clang, -O0):
<system_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%edi
call   1030 <toint@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x7(%rax),%edi
call   1030 <toint@plt>
imul   $0x64,%eax,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x8(%rax),%edi
call   1030 <toint@plt>
imul   $0xa,%eax,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x9(%rax),%edi
call   1030 <toint@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<system_code>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
movsbl 0x6(%rdi),%edi
call   1030 <toint@plt>
imul   $0x3e8,%eax,%r14d
movsbl 0x7(%rbx),%edi
call   1030 <toint@plt>
imul   $0x64,%eax,%ebp
add    %r14d,%ebp
movsbl 0x8(%rbx),%edi
call   1030 <toint@plt>
lea    (%rax,%rax,4),%eax
lea    0x0(%rbp,%rax,2),%ebp
movsbl 0x9(%rbx),%edi
call   1030 <toint@plt>
add    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @system_code(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 6
%6 = load i8, i8* %5
%7 = call i32 @toint(i8 signext %6)
%8 = mul nsw i32 %7, 1000
store i32 %8, i32* %3
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 7
%11 = load i8, i8* %10
%12 = call i32 @toint(i8 signext %11)
%13 = mul nsw i32 %12, 100
%14 = load i32, i32* %3
%15 = add nsw i32 %14, %13
store i32 %15, i32* %3
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 8
%18 = load i8, i8* %17
%19 = call i32 @toint(i8 signext %18)
%20 = mul nsw i32 %19, 10
%21 = load i32, i32* %3
%22 = add nsw i32 %21, %20
store i32 %22, i32* %3
%23 = load i8*, i8** %2
%24 = getelementptr inbounds i8, i8* %23, i64 9
%25 = load i8, i8* %24
%26 = call i32 @toint(i8 signext %25)
%27 = load i32, i32* %3
%28 = add nsw i32 %27, %26
store i32 %28, i32* %3
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @system_code(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 6
%3 = load i8, i8* %2
%4 = tail call i32 @toint(i8 signext %3)
%5 = mul nsw i32 %4, 1000
%6 = getelementptr inbounds i8, i8* %0, i64 7
%7 = load i8, i8* %6
%8 = tail call i32 @toint(i8 signext %7)
%9 = mul nsw i32 %8, 100
%10 = add nsw i32 %9, %5
%11 = getelementptr inbounds i8, i8* %0, i64 8
%12 = load i8, i8* %11
%13 = tail call i32 @toint(i8 signext %12)
%14 = mul nsw i32 %13, 10
%15 = add nsw i32 %10, %14
%16 = getelementptr inbounds i8, i8* %0, i64 9
%17 = load i8, i8* %16
%18 = tail call i32 @toint(i8 signext %17)
%19 = add nsw i32 %15, %18
ret i32 %19
}