#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__ index(char *, char);
char read_slashed(char **);
char *savestr(char *);
int read_varval(char **strp, char **valp) {
  char buf[100], *bp;
  char *var;
  var = *strp;
  bp = buf;
  while ((*var != 0) && (index(":", *var) == 0)) {
    *bp = read_slashed(&var);
    bp++;
  }
  *bp = 0;
  *valp = savestr(buf);
  *strp = var;
  return (1);
}


x86 assembly (clang, -O0):
<read_varval>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x90(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x91(%rbp)
je     119a <read_varval+0x6a>
mov    -0x90(%rbp),%rax
lea    0xe7b(%rip),%rdi
movsbl (%rax),%esi
call   1030 <index@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x91(%rbp)
mov    -0x91(%rbp),%al
test   $0x1,%al
jne    11ad <read_varval+0x7d>
jmp    11db <read_varval+0xab>
lea    -0x90(%rbp),%rdi
call   1040 <read_slashed@plt>
mov    %al,%cl
mov    -0x88(%rbp),%rax
mov    %cl,(%rax)
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
jmp    115c <read_varval+0x2c>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
call   1050 <savestr@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x90(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    $0x1,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_varval>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdi),%rax
mov    %rax,0x8(%rsp)
mov    (%rax),%al
lea    0x10(%rsp),%rbx
test   %al,%al
je     119a <read_varval+0x6a>
lea    0xea0(%rip),%r13
lea    0x8(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%esi
mov    %r13,%rdi
call   1030 <index@plt>
test   %rax,%rax
jne    119a <read_varval+0x6a>
mov    %r12,%rdi
call   1040 <read_slashed@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
mov    0x8(%rsp),%rax
movzbl (%rax),%eax
test   %al,%al
jne    1170 <read_varval+0x40>
movb   $0x0,(%rbx)
lea    0x10(%rsp),%rdi
call   1050 <savestr@plt>
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define i32 @read_varval(i8** nocapture %0, i8** nocapture writeonly %1) {
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
%7 = load i8*, i8** %0
store i8* %7, i8** %4
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %21, label %10
10: ; preds = %2, %15
%11 = phi i8 [ %19, %15 ], [ %8, %2 ]
%12 = phi i8* [ %17, %15 ], [ %5, %2 ]
%13 = call i64 @index(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8 signext %11)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = call signext i8 @read_slashed(i8** %4)
store i8 %16, i8* %12
%17 = getelementptr inbounds i8, i8* %12, i64 1
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %10
21: ; preds = %10, %15, %2
%22 = phi i8* [ %5, %2 ], [ %17, %15 ], [ %12, %10 ]
store i8 0, i8* %22
%23 = call i8* @savestr(i8* %5)
store i8* %23, i8** %1
%24 = load i8*, i8** %4
store i8* %24, i8** %0
ret i32 1
}