#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*/ db_read();
int /*<<< orphan*/ parse_pair(char const *, char *, char *);
int strlen(char *);
int list_getnext(const char *str) {
  int result = 1;
  int i, index;
  const int max_index = 2048 / 2;
  char name[1024], value[1024], s[1024];
  db_read();
  parse_pair(str, name, value);
  for (i = 0; i < strlen(name); i++)
    if (name[i] = '%') {
      name[i] = '\0';
      break;
    }
  return 1;
}


x86 assembly (clang, -O0):
<list_getnext>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x400,-0x18(%rbp)
mov    $0x0,%al
call   1040 <db_read@plt>
mov    -0x8(%rbp),%rdi
lea    -0x420(%rbp),%rsi
lea    -0x820(%rbp),%rdx
call   1050 <parse_pair@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc24(%rbp)
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xc24(%rbp),%eax
cmp    %ecx,%eax
jge    11d6 <list_getnext+0xa6>
movslq -0x10(%rbp),%rax
movb   $0x25,-0x420(%rbp,%rax,1)
25
mov    $0x1,%al
test   $0x1,%al
jne    11b2 <list_getnext+0x82>
jmp    11c3 <list_getnext+0x93>
movslq -0x10(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
jmp    11d6 <list_getnext+0xa6>
jmp    11c8 <list_getnext+0x98>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <list_getnext+0x42>
mov    $0x1,%eax
add    $0xc30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_getnext>:
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1040 <db_read@plt>
lea    0x400(%rsp),%r14
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <parse_pair@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    $0x1,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @list_getnext(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
store i8* %0, i8** %2
store i32 1, i32* %3
store i32 1024, i32* %6
%10 = call i32 (...) @db_read()
%11 = load i8*, i8** %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%14 = call i32 @parse_pair(i8* %11, i8* %12, i8* %13)
store i32 0, i32* %4
br label %15
15: ; preds = %29, %1
%16 = load i32, i32* %4
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %16, %18
br i1 %19, label %20, label %32
20: ; preds = %15
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %22
store i8 37, i8* %23
br i1 true, label %24, label %28
24: ; preds = %20
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %26
store i8 0, i8* %27
br label %32
28: ; preds = %20
br label %29
29: ; preds = %28
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %15
32: ; preds = %24, %15
ret i32 1
}

LLVM IR (-O2):
define i32 @list_getnext(i8* %0) {
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (...) @db_read()
%7 = call i32 @parse_pair(i8* %0, i8* %4, i8* %5)
%8 = call i32 @strlen(i8* %4)
ret i32 1
}