#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 */
struct list_t {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ list_count(struct list_t *);
char *list_remove_at(struct list_t *, int /*<<< orphan*/);
int /*<<< orphan*/ str_free(char *);
char *str_token_list_first(struct list_t *);
char *str_token_list_shift(struct list_t *token_list) {
  char *token;
  if (!list_count(token_list))
    return "";
  token = list_remove_at(token_list, 0);
  str_free(token);
  return str_token_list_first(token_list);
}


x86 assembly (clang, -O0):
<str_token_list_shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <list_count@plt>
cmp    $0x0,%eax
jne    116e <str_token_list_shift+0x2e>
lea    0xe9b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1193 <str_token_list_shift+0x53>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <list_remove_at@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <str_free@plt>
mov    -0x10(%rbp),%rdi
call   1040 <str_token_list_first@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_token_list_shift>:
push   %rbx
mov    %rdi,%rbx
call   1060 <list_count@plt>
test   %eax,%eax
je     1168 <str_token_list_shift+0x28>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <list_remove_at@plt>
mov    %rax,%rdi
call   1050 <str_free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <str_token_list_first@plt>
lea    0xe91(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
%struct.list_t = type { i32 }
@.str = [1 x i8] zeroinitializer
define i8* @str_token_list_shift(%struct.list_t* %0) {
%2 = alloca i8*
%3 = alloca %struct.list_t*
%4 = alloca i8*
store %struct.list_t* %0, %struct.list_t** %3
%5 = load %struct.list_t*, %struct.list_t** %3
%6 = call i32 @list_count(%struct.list_t* %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %16
9: ; preds = %1
%10 = load %struct.list_t*, %struct.list_t** %3
%11 = call i8* @list_remove_at(%struct.list_t* %10, i32 0)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = call i32 @str_free(i8* %12)
%14 = load %struct.list_t*, %struct.list_t** %3
%15 = call i8* @str_token_list_first(%struct.list_t* %14)
store i8* %15, i8** %2
br label %16
16: ; preds = %9, %8
%17 = load i8*, i8** %2
ret i8* %17
}

LLVM IR (-O2):
%struct.list_t = type { i32 }
@.str = [1 x i8] zeroinitializer
define i8* @str_token_list_shift(%struct.list_t* %0) {
%2 = tail call i32 @list_count(%struct.list_t* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i8* @list_remove_at(%struct.list_t* %0, i32 0)
%6 = tail call i32 @str_free(i8* %5)
%7 = tail call i8* @str_token_list_first(%struct.list_t* %0)
br label %8
8: ; preds = %1, %4
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %9
}