#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int get_last_struct();
int /*<<< orphan*/ print_struct_des(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ print_struct_ser(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ print_struct_size(int /*<<< orphan*/ *, int);
int print_last_struct(char *filename) {
  FILE *fh;
  int lastii;
  int member_ii;
  fh = fopen(filename, "a");
  fprintf(fh, "\n\n");
  lastii = get_last_struct();
  print_struct_ser(fh, lastii);
  print_struct_size(fh, lastii);
  print_struct_des(fh, lastii);
  fclose(fh);
  return 0;
}


x86 assembly (clang, -O0):
<print_last_struct>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x0,%al
call   1090 <get_last_struct@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <print_struct_ser@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <print_struct_size@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <print_struct_des@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_last_struct>:
push   %rbp
push   %rbx
push   %rax
lea    0xe86(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
lea    0xe79(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
xor    %eax,%eax
call   1090 <get_last_struct@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <print_struct_ser@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <print_struct_size@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <print_struct_des@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define i32 @print_last_struct(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 (...) @get_last_struct()
store i32 %10, i32* %4
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = call i32 @print_struct_ser(i32* %11, i32 %12)
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @print_struct_size(i32* %14, i32 %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = call i32 @print_struct_des(i32* %17, i32 %18)
%20 = load i32*, i32** %3
%21 = call i32 @fclose(i32* %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
@.str.1 = [3 x i8] c"\0A\0A\00"
define i32 @print_last_struct(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 2, i64 1, i32* %2)
%4 = tail call i32 (...) @get_last_struct()
%5 = tail call i32 @print_struct_ser(i32* %2, i32 %4)
%6 = tail call i32 @print_struct_size(i32* %2, i32 %4)
%7 = tail call i32 @print_struct_des(i32* %2, i32 %4)
%8 = tail call i32 @fclose(i32* %2)
ret i32 0
}