#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*/ fill_ev_action(long, char *);
long get_ev_id(char *);
char *strchr(char *, char);
char *strtok_r(char *, char *, char **);
void fill_ev_table(char *input) {
  char *str1, *token, *value;
  char *saveptr1 = NULL;
  long eid = 0;
  for (str1 = input;; str1 = NULL) {
    token = strtok_r(str1, ";", &saveptr1);
    if (token == NULL)
      break;
    if ((value = strchr(token, '=')))
      *value++ = 0;
    eid = get_ev_id(token);
    if (eid == -1)
      continue;
    fill_ev_action(eid, value);
  }
}


x86 assembly (clang, -O0):
<fill_ev_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe91(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118c <fill_ev_table+0x4c>
jmp    11f1 <fill_ev_table+0xb1>
mov    -0x18(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11ba <fill_ev_table+0x7a>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <get_ev_id@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0xffffffffffffffff,-0x30(%rbp)
jne    11d7 <fill_ev_table+0x97>
jmp    11e4 <fill_ev_table+0xa4>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <fill_ev_action@plt>
movq   $0x0,-0x10(%rbp)
jmp    1164 <fill_ev_table+0x24>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_ev_table>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movq   $0x0,(%rsp)
lea    0xea9(%rip),%rsi
mov    %rsp,%rdx
call   1050 <strtok_r@plt>
test   %rax,%rax
je     11de <fill_ev_table+0x9e>
mov    %rax,%rbx
lea    0xe92(%rip),%r14
mov    %rsp,%r15
jmp    1195 <fill_ev_table+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11de <fill_ev_table+0x9e>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11c0 <fill_ev_table+0x80>
mov    %rax,%r12
add    $0x1,%r12
movb   $0x0,(%rax)
jmp    11c3 <fill_ev_table+0x83>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %r12d,%r12d
mov    %rbx,%rdi
call   1030 <get_ev_id@plt>
cmp    $0xffffffffffffffff,%rax
je     1180 <fill_ev_table+0x40>
mov    %rax,%rdi
mov    %r12,%rsi
call   1060 <fill_ev_action@plt>
jmp    1180 <fill_ev_table+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c";\00"
define void @fill_ev_table(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = call i8* @strtok_r(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %1, %18
%7 = phi i8* [ %19, %18 ], [ %4, %1 ]
%8 = call i8* @strchr(i8* %7, i8 signext 61)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %8, i64 1
store i8 0, i8* %8
br label %12
12: ; preds = %10, %6
%13 = phi i8* [ %11, %10 ], [ null, %6 ]
%14 = call i64 @get_ev_id(i8* %7)
%15 = icmp eq i64 %14, -1
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @fill_ev_action(i64 %14, i8* %13)
br label %18
18: ; preds = %12, %16
%19 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2)
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %6
21: ; preds = %18, %1
ret void
}