#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*/ strcpy(char *, int /*<<< orphan*/);
int strlen(char *);
int /*<<< orphan*/ strtok(char *, char *);
void UpdateKeyAndValue(char *keyStr, char *valueStr) {
  int i;
  strtok(keyStr, ":");
  strcpy(valueStr, strtok(NULL, ""));
  valueStr[strlen(valueStr) - 1] = '\0';
  keyStr[strlen(keyStr) - 1] = '\0';
  for (i = 0; i < strlen(valueStr); i++) {
    valueStr[i] = valueStr[i + 1];
  }
}


x86 assembly (clang, -O0):
<UpdateKeyAndValue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb5(%rip),%rsi
call   1050 <strtok@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9e(%rip),%rsi
call   1050 <strtok@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1201 <UpdateKeyAndValue+0xd1>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bc <UpdateKeyAndValue+0x8c>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UpdateKeyAndValue>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
lea    0xebe(%rip),%rsi
call   1050 <strtok@plt>
lea    0xeb3(%rip),%rsi
xor    %edi,%edi
call   1050 <strtok@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <strcpy@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r15,1)
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b1 <UpdateKeyAndValue+0x81>
xor    %eax,%eax
nopl   (%rax)
lea    0x1(%rax),%rbx
movzbl 0x1(%r15,%rax,1),%ecx
mov    %cl,(%r15,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
movslq %eax,%rcx
mov    %rbx,%rax
cmp    %rcx,%rbx
jl     1190 <UpdateKeyAndValue+0x60>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
@.str.1 = [1 x i8] zeroinitializer
define void @UpdateKeyAndValue(i8* %0, i8* %1) {
%3 = tail call i32 @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @strtok(i8* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @strcpy(i8* %1, i32 %4)
%6 = tail call i32 @strlen(i8* %1)
%7 = add nsw i32 %6, -1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %1, i64 %8
store i8 0, i8* %9
%10 = tail call i32 @strlen(i8* %0)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 0, i8* %13
%14 = tail call i32 @strlen(i8* %1)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %2, %16
%17 = phi i64 [ %18, %16 ], [ 0, %2 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %1, i64 %17
store i8 %20, i8* %21
%22 = tail call i32 @strlen(i8* %1)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %18, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %2
ret void
}