#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*/ hash(char *);
int labs(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void split_feature_line(char *line, char delim, long *features, char *idstr,
                        int D) {
  int feati = 1, ci = 0, lni = 0, wi = 0, jump = 1, i, j;
  char buffer[100];
  line[strlen(line) - 1] = 0;
  while (jump) {
    while (line[lni] != delim && line[lni] != 0)
      lni++;
    jump = line[lni] != 0 ? 1 : 0;
    line[lni] = 0;
    if (ci == 0) {
      strcpy(idstr, &line[wi]);
      ci++;
    } else {
      sprintf(buffer, "%i_%s", feati, &line[wi]);
      features[feati++] = labs(hash(buffer)) % D;
    }
    wi = lni += jump;
  }
}


x86 assembly (clang, -O0):
<split_feature_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x38(%rbp)
je     12d9 <split_feature_line+0x189>
jmp    11ca <split_feature_line+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
movsbl -0x9(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0xb9(%rbp)
je     1202 <split_feature_line+0xb2>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0xb9(%rbp)
mov    -0xb9(%rbp),%al
test   $0x1,%al
jne    1215 <split_feature_line+0xc5>
jmp    1223 <split_feature_line+0xd3>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11ca <split_feature_line+0x7a>
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x2c(%rbp)
jne    1277 <split_feature_line+0x127>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x34(%rbp),%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12c8 <split_feature_line+0x178>
lea    -0xb0(%rbp),%rdi
mov    -0x28(%rbp),%edx
mov    -0x8(%rbp),%rcx
movslq -0x34(%rbp),%rax
add    %rax,%rcx
lea    0xd6d(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0xb0(%rbp),%rdi
call   1060 <hash@plt>
mov    %eax,%edi
call   1040 <labs@plt>
cltd
idivl  -0x24(%rbp)
movslq %edx,%rdx
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x28(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    %eax,-0x34(%rbp)
jmp    11bb <split_feature_line+0x6b>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split_feature_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r8d,0xc(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x10(%rsp)
mov    %esi,%ebx
mov    %rdi,%rbp
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbp,1)
mov    $0x1,%al
movl   $0x1,0x8(%rsp)
xor    %r15d,%r15d
jmp    11da <split_feature_line+0x9a>
lea    0x20(%rsp),%rdi
lea    0xe74(%rip),%rsi
mov    0x8(%rsp),%r13d
mov    %dl,0x7(%rsp)
mov    %r13d,%edx
call   1060 <sprintf@plt>
lea    0x20(%rsp),%rdi
call   1050 <hash@plt>
mov    %eax,%ecx
neg    %ecx
cmovns %ecx,%eax
cltd
idivl  0xc(%rsp)
movslq %r13d,%rax
add    $0x1,%r13d
mov    %r13d,0x8(%rsp)
mov    0x10(%rsp),%rcx
mov    %rdx,(%rcx,%rax,8)
mov    0x7(%rsp),%r13b
mov    %r13b,%r15b
add    %r12,%r15
xor    %eax,%eax
test   %r14b,%r14b
je     1230 <split_feature_line+0xf0>
movslq %r15d,%rcx
lea    -0x1(%rcx),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl 0x1(%rbp,%r12,1),%r14d
add    $0x1,%r12
cmp    %bl,%r14b
je     1204 <split_feature_line+0xc4>
test   %r14b,%r14b
jne    11f0 <split_feature_line+0xb0>
xor    %r15d,%r15d
test   %r14b,%r14b
setne  %dl
movb   $0x0,0x0(%rbp,%r12,1)
add    %rbp,%rcx
test   $0x1,%al
je     1180 <split_feature_line+0x40>
mov    0x18(%rsp),%rdi
mov    %rcx,%rsi
mov    %edx,%r13d
call   1030 <strcpy@plt>
jmp    11cd <split_feature_line+0x8d>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%i_%s\00"
define void @split_feature_line(i8* %0, i8 signext %1, i64* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i64*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [100 x i8]
store i8* %0, i8** %6
store i8 %1, i8* %7
store i64* %2, i64** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
store i32 1, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 1, i32* %15
%19 = load i8*, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %19, i64 %23
store i8 0, i8* %24
br label %25
25: ; preds = %96, %5
%26 = load i32, i32* %15
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %100
28: ; preds = %25
br label %29
29: ; preds = %49, %28
%30 = load i8*, i8** %6
%31 = load i32, i32* %13
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i8, i8* %7
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %35, %37
br i1 %38, label %39, label %47
39: ; preds = %29
%40 = load i8*, i8** %6
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 0
br label %47
47: ; preds = %39, %29
%48 = phi i1 [ false, %29 ], [ %46, %39 ]
br i1 %48, label %49, label %52
49: ; preds = %47
%50 = load i32, i32* %13
%51 = add nsw i32 %50, 1
store i32 %51, i32* %13
br label %29
52: ; preds = %47
%53 = load i8*, i8** %6
%54 = load i32, i32* %13
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
%60 = zext i1 %59 to i64
%61 = select i1 %59, i32 1, i32 0
store i32 %61, i32* %15
%62 = load i8*, i8** %6
%63 = load i32, i32* %13
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
store i8 0, i8* %65
%66 = load i32, i32* %12
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %77
68: ; preds = %52
%69 = load i8*, i8** %9
%70 = load i8*, i8** %6
%71 = load i32, i32* %14
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = call i32 @strcpy(i8* %69, i8* %73)
%75 = load i32, i32* %12
%76 = add nsw i32 %75, 1
store i32 %76, i32* %12
br label %96
77: ; preds = %52
%78 = getelementptr inbounds [100 x i8], [100 x i8]* %18, i64 0, i64 0
%79 = load i32, i32* %11
%80 = load i8*, i8** %6
%81 = load i32, i32* %14
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %80, i64 %82
%84 = call i32 @sprintf(i8* %78, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %79, i8* %83)
%85 = getelementptr inbounds [100 x i8], [100 x i8]* %18, i64 0, i64 0
%86 = call i32 @hash(i8* %85)
%87 = call i32 @labs(i32 %86)
%88 = load i32, i32* %10
%89 = srem i32 %87, %88
%90 = sext i32 %89 to i64
%91 = load i64*, i64** %8
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
store i32 %93, i32* %11
%94 = sext i32 %92 to i64
%95 = getelementptr inbounds i64, i64* %91, i64 %94
store i64 %90, i64* %95
br label %96
96: ; preds = %77, %68
%97 = load i32, i32* %15
%98 = load i32, i32* %13
%99 = add nsw i32 %98, %97
store i32 %99, i32* %13
store i32 %99, i32* %14
br label %25
100: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%i_%s\00"
define void @split_feature_line(i8* %0, i8 signext %1, i64* nocapture writeonly %2, i8* %3, i32 %4) {
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
store i8 0, i8* %11
br label %12
12: ; preds = %5, %42
%13 = phi i32 [ 1, %5 ], [ %43, %42 ]
%14 = phi i1 [ true, %5 ], [ false, %42 ]
%15 = phi i64 [ 0, %5 ], [ %44, %42 ]
%16 = shl i64 %15, 32
%17 = ashr exact i64 %16, 32
br label %18
18: ; preds = %18, %12
%19 = phi i64 [ %25, %18 ], [ %17, %12 ]
%20 = getelementptr inbounds i8, i8* %0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, %1
%23 = icmp eq i8 %21, 0
%24 = or i1 %22, %23
%25 = add i64 %19, 1
br i1 %24, label %26, label %18
26: ; preds = %18
%27 = getelementptr inbounds i8, i8* %0, i64 %19
%28 = icmp ne i8 %21, 0
%29 = zext i1 %28 to i64
store i8 0, i8* %27
%30 = getelementptr inbounds i8, i8* %0, i64 %17
br i1 %14, label %31, label %33
31: ; preds = %26
%32 = call i32 @strcpy(i8* %3, i8* %30)
br label %42
33: ; preds = %26
%34 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13, i8* %30)
%35 = call i32 @hash(i8* %7)
%36 = call i32 @llvm.abs.i32(i32 %35, i1 true)
%37 = srem i32 %36, %4
%38 = zext i32 %37 to i64
%39 = add nsw i32 %13, 1
%40 = sext i32 %13 to i64
%41 = getelementptr inbounds i64, i64* %2, i64 %40
store i64 %38, i64* %41
br label %42
42: ; preds = %33, %31
%43 = phi i32 [ %13, %31 ], [ %39, %33 ]
%44 = add i64 %19, %29
br i1 %28, label %12, label %45
45: ; preds = %42
ret void
}