#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 token {
  int dummy;
};
struct list {
  int dummy;
};
struct lexer {
  int dummy;
};

/* Variables and functions */
struct lexer *lexer_create_substitution(struct lexer *, struct token *);
int /*<<< orphan*/ lexer_delete(struct lexer *);
struct list *
lexer_expand_substitution(struct lexer *lx, struct token *t,
                          struct list *(*list_reader)(struct lexer *)) {
  struct lexer *lx_s = lexer_create_substitution(lx, t);
  struct list *tokens = list_reader(lx_s);
  lexer_delete(lx_s);
  return tokens;
}


x86 assembly (clang, -O0):
<lexer_expand_substitution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <lexer_create_substitution@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rdi
call   *%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <lexer_delete@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lexer_expand_substitution>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
call   1040 <lexer_create_substitution@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   *%r14
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <lexer_delete@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.list = type { i32 }
%struct.lexer = type { i32 }
%struct.token = type { i32 }
define %struct.list* @lexer_expand_substitution(%struct.lexer* %0, %struct.token* %1, %struct.list* (%struct.lexer*)* %2) {
%4 = alloca %struct.lexer*
%5 = alloca %struct.token*
%6 = alloca %struct.list* (%struct.lexer*)*
%7 = alloca %struct.lexer*
%8 = alloca %struct.list*
store %struct.lexer* %0, %struct.lexer** %4
store %struct.token* %1, %struct.token** %5
store %struct.list* (%struct.lexer*)* %2, %struct.list* (%struct.lexer*)** %6
%9 = load %struct.lexer*, %struct.lexer** %4
%10 = load %struct.token*, %struct.token** %5
%11 = call %struct.lexer* @lexer_create_substitution(%struct.lexer* %9, %struct.token* %10)
store %struct.lexer* %11, %struct.lexer** %7
%12 = load %struct.list* (%struct.lexer*)*, %struct.list* (%struct.lexer*)** %6
%13 = load %struct.lexer*, %struct.lexer** %7
%14 = call %struct.list* %12(%struct.lexer* %13)
store %struct.list* %14, %struct.list** %8
%15 = load %struct.lexer*, %struct.lexer** %7
%16 = call i32 @lexer_delete(%struct.lexer* %15)
%17 = load %struct.list*, %struct.list** %8
ret %struct.list* %17
}

LLVM IR (-O2):
%struct.list = type { i32 }
%struct.lexer = type { i32 }
%struct.token = type { i32 }
define %struct.list* @lexer_expand_substitution(%struct.lexer* %0, %struct.token* %1, %struct.list* (%struct.lexer*)* nocapture %2) {
%4 = tail call %struct.lexer* @lexer_create_substitution(%struct.lexer* %0, %struct.token* %1)
%5 = tail call %struct.list* %2(%struct.lexer* %4)
%6 = tail call i32 @lexer_delete(%struct.lexer* %4)
ret %struct.list* %5
}