#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__ strcmp(char *, char *);
int strlen(char *);
char *strtok(int /*<<< orphan*/ *, char *);
char *getvaluefromhash(char *key, char *hash) {
  char *value;
  char *lastchar;
  for (; NULL != hash && strcmp(key, hash); hash = strtok(NULL, ":\n"))
    ;
  value = strtok(NULL, ":\n");
  while (*value == ' ')
    ++value;
  for (lastchar = value + strlen(value); *--lastchar == ' '; *lastchar = '\0')
    ;
  return value;
}


x86 assembly (clang, -O0):
<getvaluefromhash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
xor    %ecx,%ecx
cmp    -0x10(%rbp),%rcx
mov    %al,-0x21(%rbp)
je     1168 <getvaluefromhash+0x38>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1178 <getvaluefromhash+0x48>
jmp    1196 <getvaluefromhash+0x66>
jmp    117d <getvaluefromhash+0x4d>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe78(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x10(%rbp)
jmp    1140 <getvaluefromhash+0x10>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5f(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11cb <getvaluefromhash+0x9b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11aa <getvaluefromhash+0x7a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movsbl -0x1(%rax),%eax
cmp    $0x20,%eax
jne    1219 <getvaluefromhash+0xe9>
jmp    120d <getvaluefromhash+0xdd>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
jmp    11ec <getvaluefromhash+0xbc>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getvaluefromhash>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     116f <getvaluefromhash+0x3f>
mov    %rsi,%rax
mov    %rdi,%rbx
lea    0xeba(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116f <getvaluefromhash+0x3f>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
jne    1150 <getvaluefromhash+0x20>
lea    0xe8a(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
mov    %rax,%rbx
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x20,0x1(%rbx)
lea    0x1(%rbx),%rbx
je     1190 <getvaluefromhash+0x60>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0x20,-0x1(%rbx,%rax,1)
jne    11c0 <getvaluefromhash+0x90>
nopl   0x0(%rax,%rax,1)
movb   $0x0,-0x1(%rbx,%rax,1)
cmpb   $0x20,-0x2(%rbx,%rax,1)
lea    -0x1(%rax),%rax
je     11b0 <getvaluefromhash+0x80>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c":\0A\00"
define i8* @getvaluefromhash(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
br label %7
7: ; preds = %18, %2
%8 = load i8*, i8** %4
%9 = icmp ne i8* null, %8
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i64 @strcmp(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %10, %7
%16 = phi i1 [ false, %7 ], [ %14, %10 ]
br i1 %16, label %17, label %20
17: ; preds = %15
br label %18
18: ; preds = %17
%19 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
br label %7
20: ; preds = %15
%21 = call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %21, i8** %5
br label %22
22: ; preds = %27, %20
%23 = load i8*, i8** %5
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
br label %22
30: ; preds = %22
%31 = load i8*, i8** %5
%32 = load i8*, i8** %5
%33 = call i32 @strlen(i8* %32)
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8* %35, i8** %6
br label %36
36: ; preds = %43, %30
%37 = load i8*, i8** %6
%38 = getelementptr inbounds i8, i8* %37, i32 -1
store i8* %38, i8** %6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 32
br i1 %41, label %42, label %45
42: ; preds = %36
br label %43
43: ; preds = %42
%44 = load i8*, i8** %6
store i8 0, i8* %44
br label %36
45: ; preds = %36
%46 = load i8*, i8** %5
ret i8* %46
}

LLVM IR (-O2):
@.str = [3 x i8] c":\0A\00"
define i8* @getvaluefromhash(i8* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %11, label %4
4: ; preds = %2, %8
%5 = phi i8* [ %9, %8 ], [ %1, %2 ]
%6 = tail call i64 @strcmp(i8* %0, i8* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %4
11: ; preds = %4, %8, %2
%12 = tail call i8* @strtok(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %13, %11
%14 = phi i8* [ %12, %11 ], [ %17, %13 ]
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 32
%17 = getelementptr inbounds i8, i8* %14, i64 1
br i1 %16, label %13, label %18
18: ; preds = %13
%19 = tail call i32 @strlen(i8* %14)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %14, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 32
br i1 %24, label %25, label %30
25: ; preds = %18, %25
%26 = phi i8* [ %27, %25 ], [ %22, %18 ]
store i8 0, i8* %26
%27 = getelementptr inbounds i8, i8* %26, i64 -1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 32
br i1 %29, label %25, label %30
30: ; preds = %25, %18
ret i8* %14
}