#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *get_line(int /*<<< orphan*/ *);
int str_index(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *next_item(FILE *fp, char *token) {
  int s;
  char *line;
  if ((line = get_line(fp)) == NULL)
    return NULL;
  while ((s = str_index(line, "=")) == -1) {
    free(line);
    if ((line = get_line(fp)) == NULL)
      return NULL;
  }
  strcpy(token, line + s + 1);
  free(line);
  return token;
}


x86 assembly (clang, -O0):
<next_item>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_line@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1174 <next_item+0x34>
movq   $0x0,-0x8(%rbp)
jmp    11f0 <next_item+0xb0>
jmp    1179 <next_item+0x39>
mov    -0x28(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1060 <str_index@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    11c7 <next_item+0x87>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1050 <get_line@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11c2 <next_item+0x82>
movq   $0x0,-0x8(%rbp)
jmp    11f0 <next_item+0xb0>
jmp    1179 <next_item+0x39>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
call   1040 <strcpy@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_item>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <get_line@plt>
test   %rax,%rax
je     1198 <next_item+0x58>
mov    %rax,%rbx
lea    0xe9e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1060 <str_index@plt>
cmp    $0xffffffff,%eax
jne    119d <next_item+0x5d>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1050 <get_line@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1170 <next_item+0x30>
xor    %r14d,%r14d
jmp    11b7 <next_item+0x77>
cltq
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
define i8* @next_item(i32* %0, i8* %1) {
%3 = tail call i8* @get_line(i32* %0)
%4 = icmp eq i8* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2, %9
%6 = phi i8* [ %11, %9 ], [ %3, %2 ]
%7 = tail call i32 @str_index(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %5
%10 = tail call i32 @free(i8* %6)
%11 = tail call i8* @get_line(i32* %0)
%12 = icmp eq i8* %11, null
br i1 %12, label %19, label %5
13: ; preds = %5
%14 = sext i32 %7 to i64
%15 = getelementptr inbounds i8, i8* %6, i64 %14
%16 = getelementptr inbounds i8, i8* %15, i64 1
%17 = tail call i32 @strcpy(i8* %1, i8* %16)
%18 = tail call i32 @free(i8* %6)
br label %19
19: ; preds = %9, %2, %13
%20 = phi i8* [ %1, %13 ], [ null, %2 ], [ null, %9 ]
ret i8* %20
}