#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) {
  char *thousands_s, *hundreds_s;
  char *dot = ".";
  if (strchr(spec_s, '.') != 0) {
    thousands_s = strtok(spec_s, dot);
    hundreds_s = strtok(NULL, " ");
    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    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xebd(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strchr@plt>
cmp    $0x0,%rax
je     11ae <spec_string_to_integer+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe87(%rip),%rsi
call   1040 <strtok@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <atoi@plt>
imul   $0x3e8,%eax,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    11ba <spec_string_to_integer+0x8a>
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%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 i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
%7 = load i8*, i8** %3
%8 = call i64 @strchr(i8* %7, i8 signext 46)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = load i8*, i8** %6
%13 = call i8* @strtok(i8* %11, i8* %12)
store i8* %13, i8** %4
%14 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %14, i8** %5
%15 = load i8*, i8** %4
%16 = call i32 @atoi(i8* %15)
%17 = mul nsw i32 %16, 1000
%18 = load i8*, i8** %5
%19 = call i32 @atoi(i8* %18)
%20 = add nsw i32 %17, %19
store i32 %20, i32* %2
br label %24
21: ; preds = %1
%22 = load i8*, i8** %3
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %2
br label %24
24: ; preds = %21, %10
%25 = load i32, i32* %2
ret i32 %25
}

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
}