#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ sscanf(char const *, char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void attributes_parse(const char *attributes, char *name,
                      unsigned int *curr_pid, unsigned int *cpu,
                      unsigned int *prev_pid, char *prev_state,
                      unsigned long long int *stat_runtime) {
  int done = 0;
  const char *p = attributes;
  char attr[32], val[32];
  while (!done) {
    while ((*p != 0) && (*p != ' '))
      p++;
    if (*p == 0) {
      done = 1;
    } else {
      p++;
      sscanf(p, "%[^=]=%s", attr, val);
      ;
      if ((strcmp(attr, "pid") == 0) || (strcmp(attr, "next_pid") == 0)) {
        *curr_pid = atoi(val);
      }
      if ((strcmp(attr, "comm") == 0) || (strcmp(attr, "next_comm") == 0)) {
        strcpy(name, val);
      }
      if ((strcmp(attr, "target_cpu") == 0)) {
        *cpu = atoi(val);
      }
      if ((strcmp(attr, "prev_pid") == 0)) {
        *prev_pid = atoi(val);
      }
      if ((strcmp(attr, "prev_state") == 0)) {
        *prev_state = val[0];
      }
      if ((strcmp(attr, "runtime") == 0)) {
        *stat_runtime = (long long int)atoi(val) / 1000;
      }
    }
  }
}


x86 assembly (clang, -O0):
<attributes_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x34(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <attributes_parse+0x4c>
jmp    1362 <attributes_parse+0x222>
jmp    1191 <attributes_parse+0x51>
mov    -0x40(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x81(%rbp)
je     11bc <attributes_parse+0x7c>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x81(%rbp)
mov    -0x81(%rbp),%al
test   $0x1,%al
jne    11cf <attributes_parse+0x8f>
jmp    11e0 <attributes_parse+0xa0>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
jmp    1191 <attributes_parse+0x51>
mov    -0x40(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11fc <attributes_parse+0xbc>
movl   $0x1,-0x34(%rbp)
jmp    135d <attributes_parse+0x21d>
mov    -0x40(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    -0x80(%rbp),%rcx
lea    0xde5(%rip),%rsi
call   1050 <sscanf@plt>
lea    -0x60(%rbp),%rdi
lea    0xde3(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1254 <attributes_parse+0x114>
lea    -0x60(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <attributes_parse+0x125>
lea    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x60(%rbp),%rdi
lea    0xda7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1299 <attributes_parse+0x159>
lea    -0x60(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <attributes_parse+0x166>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x60(%rbp),%rdi
lea    0xd6b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12d1 <attributes_parse+0x191>
lea    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x60(%rbp),%rdi
lea    0xd4b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12fc <attributes_parse+0x1bc>
lea    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x60(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    131f <attributes_parse+0x1df>
mov    -0x80(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %cl,(%rax)
lea    -0x60(%rbp),%rdi
lea    0xd11(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1358 <attributes_parse+0x218>
lea    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,%eax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    135d <attributes_parse+0x21d>
jmp    1176 <attributes_parse+0x36>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<attributes_parse>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,0x8(%rsp)
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rbp
lea    0x40(%rsp),%r15
lea    0x20(%rsp),%r12
lea    0xec4(%rip),%r14
nopw   0x0(%rax,%rax,1)
movzbl 0x0(%rbp),%eax
cmp    $0x20,%al
je     11a0 <attributes_parse+0x60>
test   %al,%al
je     12bf <attributes_parse+0x17f>
add    $0x1,%rbp
jmp    1180 <attributes_parse+0x40>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbp
mov    %rbp,%rdi
lea    0xe52(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1050 <sscanf@plt>
mov    %r15,%rdi
lea    0xe4b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e1 <attributes_parse+0xa1>
mov    %r15,%rdi
lea    0xe32(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11ed <attributes_parse+0xad>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,0x0(%r13)
mov    %r15,%rdi
lea    0xe20(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1215 <attributes_parse+0xd5>
mov    %r15,%rdi
lea    0xe07(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1220 <attributes_parse+0xe0>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
lea    0xdf2(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1243 <attributes_parse+0x103>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r15,%rdi
lea    0xdda(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1266 <attributes_parse+0x126>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
mov    %r15,%rdi
lea    0xdc0(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1286 <attributes_parse+0x146>
movzbl 0x20(%rsp),%eax
mov    0x18(%rsp),%rcx
mov    %al,(%rcx)
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1180 <attributes_parse+0x40>
mov    %r12,%rdi
call   1060 <atoi@plt>
mov    %eax,%eax
imul   $0x10624dd3,%rax,%rax
shr    $0x26,%rax
mov    0xa0(%rsp),%rcx
mov    %rax,(%rcx)
jmp    1180 <attributes_parse+0x40>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%[^=]=%s\00"
@.str.1 = [4 x i8] c"pid\00"
@.str.2 = [9 x i8] c"next_pid\00"
@.str.3 = [5 x i8] c"comm\00"
@.str.4 = [10 x i8] c"next_comm\00"
@.str.5 = [11 x i8] c"target_cpu\00"
@.str.6 = [9 x i8] c"prev_pid\00"
@.str.7 = [11 x i8] c"prev_state\00"
@.str.8 = [8 x i8] c"runtime\00"
define void @attributes_parse(i8* %0, i8* %1, i32* %2, i32* %3, i32* %4, i8* %5, i64* %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i64*
%15 = alloca i32
%16 = alloca i8*
%17 = alloca [32 x i8]
%18 = alloca [32 x i8]
store i8* %0, i8** %8
store i8* %1, i8** %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i8* %5, i8** %13
store i64* %6, i64** %14
store i32 0, i32* %15
%19 = load i8*, i8** %8
store i8* %19, i8** %16
br label %20
20: ; preds = %111, %7
%21 = load i32, i32* %15
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %24, label %112
24: ; preds = %20
br label %25
25: ; preds = %37, %24
%26 = load i8*, i8** %16
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = load i8*, i8** %16
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 32
br label %35
35: ; preds = %30, %25
%36 = phi i1 [ false, %25 ], [ %34, %30 ]
br i1 %36, label %37, label %40
37: ; preds = %35
%38 = load i8*, i8** %16
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %16
br label %25
40: ; preds = %35
%41 = load i8*, i8** %16
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %40
store i32 1, i32* %15
br label %111
46: ; preds = %40
%47 = load i8*, i8** %16
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %16
%49 = load i8*, i8** %16
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%51 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%52 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %50, i8* %51)
%53 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %46
%57 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %56, %46
%61 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%62 = call i32 @atoi(i8* %61)
%63 = load i32*, i32** %10
store i32 %62, i32* %63
br label %64
64: ; preds = %60, %56
%65 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %72, label %68
68: ; preds = %64
%69 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%70 = call i64 @strcmp(i8* %69, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%71 = icmp eq i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %68, %64
%73 = load i8*, i8** %9
%74 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%75 = call i32 @strcpy(i8* %73, i8* %74)
br label %76
76: ; preds = %72, %68
%77 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%78 = call i64 @strcmp(i8* %77, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%79 = icmp eq i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %76
%81 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%82 = call i32 @atoi(i8* %81)
%83 = load i32*, i32** %11
store i32 %82, i32* %83
br label %84
84: ; preds = %80, %76
%85 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %92
88: ; preds = %84
%89 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%90 = call i32 @atoi(i8* %89)
%91 = load i32*, i32** %12
store i32 %90, i32* %91
br label %92
92: ; preds = %88, %84
%93 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%94 = call i64 @strcmp(i8* %93, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %100
96: ; preds = %92
%97 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%98 = load i8, i8* %97
%99 = load i8*, i8** %13
store i8 %98, i8* %99
br label %100
100: ; preds = %96, %92
%101 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %110
104: ; preds = %100
%105 = getelementptr inbounds [32 x i8], [32 x i8]* %18, i64 0, i64 0
%106 = call i32 @atoi(i8* %105)
%107 = zext i32 %106 to i64
%108 = sdiv i64 %107, 1000
%109 = load i64*, i64** %14
store i64 %108, i64* %109
br label %110
110: ; preds = %104, %100
br label %111
111: ; preds = %110, %45
br label %20
112: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%[^=]=%s\00"
@.str.1 = [4 x i8] c"pid\00"
@.str.2 = [9 x i8] c"next_pid\00"
@.str.3 = [5 x i8] c"comm\00"
@.str.4 = [10 x i8] c"next_comm\00"
@.str.5 = [11 x i8] c"target_cpu\00"
@.str.6 = [9 x i8] c"prev_pid\00"
@.str.7 = [11 x i8] c"prev_state\00"
@.str.8 = [8 x i8] c"runtime\00"
define void @attributes_parse(i8* nocapture %0, i8* %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i8* nocapture writeonly %5, i64* nocapture writeonly %6) {
%8 = alloca [32 x i8]
%9 = alloca [32 x i8]
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
br label %12
12: ; preds = %17, %7
%13 = phi i8* [ %0, %7 ], [ %18, %17 ]
%14 = load i8, i8* %13
switch i8 %14, label %15 [
i8 0, label %59
i8 32, label %19
]
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %13, i64 1
br label %17
17: ; preds = %15, %52, %55
%18 = phi i8* [ %16, %15 ], [ %20, %52 ], [ %20, %55 ]
br label %12
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %13, i64 1
%21 = call i32 @sscanf(i8* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10, i8* %11)
%22 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24, %19
%28 = call i32 @atoi(i8* %11)
store i32 %28, i32* %2
br label %29
29: ; preds = %27, %24
%30 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %29
%33 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %32, %29
%36 = call i32 @strcpy(i8* %1, i8* %11)
br label %37
37: ; preds = %35, %32
%38 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @atoi(i8* %11)
store i32 %41, i32* %3
br label %42
42: ; preds = %40, %37
%43 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 @atoi(i8* %11)
store i32 %46, i32* %4
br label %47
47: ; preds = %45, %42
%48 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = load i8, i8* %11
store i8 %51, i8* %5
br label %52
52: ; preds = %50, %47
%53 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %17
55: ; preds = %52
%56 = call i32 @atoi(i8* %11)
%57 = udiv i32 %56, 1000
%58 = zext i32 %57 to i64
store i64 %58, i64* %6
br label %17
59: ; preds = %12
ret void
}