#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 str {
  int dummy;
};
struct node {
  int dummy;
};
struct generator {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ restore_string(struct node *, struct str *, struct str *);
int /*<<< orphan*/ str_delete(struct str *);
struct str *str_new();
int /*<<< orphan*/ write_margin(struct generator *);
int /*<<< orphan*/ write_newline(struct generator *);
int /*<<< orphan*/ write_str(struct generator *, struct str *);
void write_restorecursor(struct generator *g, struct node *p,
                         struct str *savevar) {
  struct str *temp = str_new();
  write_margin(g);
  restore_string(p, temp, savevar);
  write_str(g, temp);
  write_newline(g);
  str_delete(temp);
}


x86 assembly (clang, -O0):
<write_restorecursor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <str_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <write_margin@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1080 <restore_string@plt>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <write_str@plt>
mov    -0x8(%rbp),%rdi
call   1070 <write_newline@plt>
mov    -0x20(%rbp),%rdi
call   1050 <str_delete@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_restorecursor>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
xor    %eax,%eax
call   1060 <str_new@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <write_margin@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1080 <restore_string@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <write_str@plt>
mov    %r12,%rdi
call   1070 <write_newline@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <str_delete@plt>

LLVM IR (-O0):
%struct.generator = type { i32 }
%struct.node = type { i32 }
%struct.str = type { i32 }
define void @write_restorecursor(%struct.generator* %0, %struct.node* %1, %struct.str* %2) {
%4 = alloca %struct.generator*
%5 = alloca %struct.node*
%6 = alloca %struct.str*
%7 = alloca %struct.str*
store %struct.generator* %0, %struct.generator** %4
store %struct.node* %1, %struct.node** %5
store %struct.str* %2, %struct.str** %6
%8 = call %struct.str* (...) @str_new()
store %struct.str* %8, %struct.str** %7
%9 = load %struct.generator*, %struct.generator** %4
%10 = call i32 @write_margin(%struct.generator* %9)
%11 = load %struct.node*, %struct.node** %5
%12 = load %struct.str*, %struct.str** %7
%13 = load %struct.str*, %struct.str** %6
%14 = call i32 @restore_string(%struct.node* %11, %struct.str* %12, %struct.str* %13)
%15 = load %struct.generator*, %struct.generator** %4
%16 = load %struct.str*, %struct.str** %7
%17 = call i32 @write_str(%struct.generator* %15, %struct.str* %16)
%18 = load %struct.generator*, %struct.generator** %4
%19 = call i32 @write_newline(%struct.generator* %18)
%20 = load %struct.str*, %struct.str** %7
%21 = call i32 @str_delete(%struct.str* %20)
ret void
}

LLVM IR (-O2):
%struct.generator = type { i32 }
%struct.node = type { i32 }
%struct.str = type { i32 }
define void @write_restorecursor(%struct.generator* %0, %struct.node* %1, %struct.str* %2) {
%4 = tail call %struct.str* (...) @str_new()
%5 = tail call i32 @write_margin(%struct.generator* %0)
%6 = tail call i32 @restore_string(%struct.node* %1, %struct.str* %4, %struct.str* %2)
%7 = tail call i32 @write_str(%struct.generator* %0, %struct.str* %4)
%8 = tail call i32 @write_newline(%struct.generator* %0)
%9 = tail call i32 @str_delete(%struct.str* %4)
ret void
}