#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__ strchr(char *, char);
char *strtok(char *, char *);
int spec_string_to_integer(char *spec_s) {
  int thousands_int, hundreds_int;
  char *thousands_s, *hundreds_s;
  char *dot = ".";
  if (strchr(spec_s, '.') != 0) {
    thousands_s = strtok(spec_s, dot);
    hundreds_s = strtok(NULL, " ");
    thousands_int = atoi(thousands_s);
    hundreds_int = atoi(hundreds_s);
    return (atoi(thousands_s) * 1000) + atoi(hundreds_s);
  } else
    return atoi(spec_s);
}


x86 assembly (clang, -O0):
<spec_string_to_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11c6 <spec_string_to_integer+0x96>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe87(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <spec_string_to_integer+0xa2>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spec_string_to_integer>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1186 <spec_string_to_integer+0x56>
lea    0xeb3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strtok@plt>
mov    %rax,%r14
lea    0xea3(%rip),%rsi
xor    %edi,%edi
call   1040 <strtok@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <atoi@plt>
imul   $0x3e8,%eax,%ebp
mov    %rbx,%rdi
call   1050 <atoi@plt>
add    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <atoi@plt>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] c" \00"
define i32 @spec_string_to_integer(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i8*, i8** %3
%10 = call i64 @strchr(i8* %9, i8 signext 46)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = load i8*, i8** %8
%15 = call i8* @strtok(i8* %13, i8* %14)
store i8* %15, i8** %6
%16 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %16, i8** %7
%17 = load i8*, i8** %6
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %4
%19 = load i8*, i8** %7
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %5
%21 = load i8*, i8** %6
%22 = call i32 @atoi(i8* %21)
%23 = mul nsw i32 %22, 1000
%24 = load i8*, i8** %7
%25 = call i32 @atoi(i8* %24)
%26 = add nsw i32 %23, %25
store i32 %26, i32* %2
br label %30
27: ; preds = %1
%28 = load i8*, i8** %3
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %12
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
@.str.1 = [2 x i8] c" \00"
define i32 @spec_string_to_integer(i8* %0) {
%2 = tail call i64 @strchr(i8* %0, i8 signext 46)
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @atoi(i8* %5)
%8 = mul nsw i32 %7, 1000
%9 = tail call i32 @atoi(i8* %6)
%10 = add nsw i32 %8, %9
br label %13
11: ; preds = %1
%12 = tail call i32 @atoi(i8* %0)
br label %13
13: ; preds = %11, %4
%14 = phi i32 [ %10, %4 ], [ %12, %11 ]
ret i32 %14
}