#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 /*<<< orphan*/ sscanf(char const *, char *, long *, ...);
char *strstr(char const *, char *);
int cstr6442pc(const char *in) {
  char *sstr;
  long a;
  long b;
  long c;
  long res;
  char *pos;
  pos = strstr(in, ".");
  if (pos != NULL) {
    sscanf(in, "%ld.%ld.%ld", &a, &b, &c);
    res = a << 8;
    res += b << 4;
    res += c;
    return res;
  }
  pos = strstr(in, "-");
  if (pos != NULL) {
    sscanf(in, "%ld-%ld-%ld", &a, &b, &c);
    res = a << 8;
    res += b << 4;
    res += c;
    return res;
  }
  sscanf(in, "%ld", &res);
  return res;
}


x86 assembly (clang, -O0):
<cstr6442pc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     119d <cstr6442pc+0x7d>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x4,%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    122b <cstr6442pc+0x10b>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     120e <cstr6442pc+0xee>
mov    -0x10(%rbp),%rdi
lea    0xe49(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x4,%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    122b <cstr6442pc+0x10b>
mov    -0x10(%rbp),%rdi
lea    0xdff(%rip),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cstr6442pc>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
mov    $0x2e,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1140 <cstr6442pc+0x20>
lea    0xec2(%rip),%rsi
jmp    1159 <cstr6442pc+0x39>
mov    %rbx,%rdi
mov    $0x2d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1192 <cstr6442pc+0x72>
lea    0xeb3(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%rcx
shl    $0x8,%rcx
mov    0x18(%rsp),%rax
shl    $0x4,%rax
add    %rcx,%rax
add    0x10(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe7b(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0x8(%rsp),%rax
jmp    118c <cstr6442pc+0x6c>

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
@.str.1 = [12 x i8] c"%ld.%ld.%ld\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [12 x i8] c"%ld-%ld-%ld\00"
@.str.4 = [4 x i8] c"%ld\00"
define i32 @cstr6442pc(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %3
%10 = load i8*, i8** %3
%11 = call i8* @strstr(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64* %5, i64* %6, i64* %7)
%17 = load i64, i64* %5
%18 = shl i64 %17, 8
store i64 %18, i64* %8
%19 = load i64, i64* %6
%20 = shl i64 %19, 4
%21 = load i64, i64* %8
%22 = add nsw i64 %21, %20
store i64 %22, i64* %8
%23 = load i64, i64* %7
%24 = load i64, i64* %8
%25 = add nsw i64 %24, %23
store i64 %25, i64* %8
%26 = load i64, i64* %8
%27 = trunc i64 %26 to i32
store i32 %27, i32* %2
br label %52
28: ; preds = %1
%29 = load i8*, i8** %3
%30 = call i8* @strstr(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %47
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %34, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64* %5, i64* %6, i64* %7)
%36 = load i64, i64* %5
%37 = shl i64 %36, 8
store i64 %37, i64* %8
%38 = load i64, i64* %6
%39 = shl i64 %38, 4
%40 = load i64, i64* %8
%41 = add nsw i64 %40, %39
store i64 %41, i64* %8
%42 = load i64, i64* %7
%43 = load i64, i64* %8
%44 = add nsw i64 %43, %42
store i64 %44, i64* %8
%45 = load i64, i64* %8
%46 = trunc i64 %45 to i32
store i32 %46, i32* %2
br label %52
47: ; preds = %28
%48 = load i8*, i8** %3
%49 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %8)
%50 = load i64, i64* %8
%51 = trunc i64 %50 to i32
store i32 %51, i32* %2
br label %52
52: ; preds = %47, %33, %14
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"%ld.%ld.%ld\00"
@.str.3 = [12 x i8] c"%ld-%ld-%ld\00"
@.str.4 = [4 x i8] c"%ld\00"
define i32 @cstr6442pc(i8* %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = bitcast i64* %5 to i8*
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 46)
%11 = icmp eq i8* %10, null
br i1 %11, label %21, label %12
12: ; preds = %1
%13 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%14 = load i64, i64* %2
%15 = shl i64 %14, 8
%16 = load i64, i64* %3
%17 = shl i64 %16, 4
%18 = add nsw i64 %17, %15
%19 = load i64, i64* %4
%20 = add nsw i64 %18, %19
br label %36
21: ; preds = %1
%22 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 45)
%23 = icmp eq i8* %22, null
br i1 %23, label %33, label %24
24: ; preds = %21
%25 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%26 = load i64, i64* %2
%27 = shl i64 %26, 8
%28 = load i64, i64* %3
%29 = shl i64 %28, 4
%30 = add nsw i64 %29, %27
%31 = load i64, i64* %4
%32 = add nsw i64 %30, %31
br label %36
33: ; preds = %21
%34 = call i32 (i8*, i8*, i64*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i64* %5)
%35 = load i64, i64* %5
br label %36
36: ; preds = %33, %24, %12
%37 = phi i64 [ %20, %12 ], [ %32, %24 ], [ %35, %33 ]
%38 = trunc i64 %37 to i32
ret i32 %38
}