#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strsep(char **, char *);
void Weighting(char *sense, long long int *weight) {
  char *string_in, *tok;
  int count = 0;
  string_in = sense;
  while ((tok = strsep(&string_in, ":")) != NULL) {
    if (count == 0)
      strcpy(sense, tok);
    else
      *weight = (long long int)atoi(tok) + 1;
    count++;
  }
  free(string_in);
}


x86 assembly (clang, -O0):
<Weighting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1050 <strsep@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11be <Weighting+0x7e>
cmpl   $0x0,-0x24(%rbp)
jne    1199 <Weighting+0x59>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11b0 <Weighting+0x70>
mov    -0x20(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115f <Weighting+0x1f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Weighting>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,0x8(%rsp)
lea    0xea5(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     11bf <Weighting+0x7f>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
lea    0xe84(%rip),%rsi
lea    0x8(%rsp),%rdi
call   1050 <strsep@plt>
test   %rax,%rax
je     11bf <Weighting+0x7f>
lea    0xe6e(%rip),%r14
lea    0x8(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1060 <atoi@plt>
add    $0x1,%rax
mov    %rax,(%rbx)
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <strsep@plt>
test   %rax,%rax
jne    11a0 <Weighting+0x60>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define void @Weighting(i8* %0, i64* nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
%5 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = call i32 @strcpy(i8* %0, i8* %5)
%9 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %17, label %11
11: ; preds = %7, %11
%12 = phi i8* [ %15, %11 ], [ %9, %7 ]
%13 = call i64 @atoi(i8* %12)
%14 = add nsw i64 %13, 1
store i64 %14, i64* %1
%15 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %11
17: ; preds = %11, %7, %2
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
ret void
}