#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 saxs_document {
  int dummy;
};
struct line {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lines_free(struct line *);
int saxs_writer_columns_write_lines(
    struct saxs_document *doc, struct line **lines,
    int (*write_header)(struct saxs_document *, struct line **),
    int (*write_data)(struct saxs_document *, struct line **),
    int (*write_footer)(struct saxs_document *, struct line **)) {
  int res = 0;
  struct line *l = NULL;
  if (res == 0 && write_header)
    res = write_header(doc, &l);
  if (res == 0 && write_data)
    res = write_data(doc, &l);
  if (res == 0 && write_footer)
    res = write_footer(doc, &l);
  if (res == 0) {
    ;
    *lines = l;
  } else {
    lines_free(l);
  }
  return res;
}


x86 assembly (clang, -O0):
<saxs_writer_columns_write_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1161 <saxs_writer_columns_write_lines+0x51>
cmpq   $0x0,-0x18(%rbp)
je     1161 <saxs_writer_columns_write_lines+0x51>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   *%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1187 <saxs_writer_columns_write_lines+0x77>
cmpq   $0x0,-0x20(%rbp)
je     1187 <saxs_writer_columns_write_lines+0x77>
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   *%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11ad <saxs_writer_columns_write_lines+0x9d>
cmpq   $0x0,-0x28(%rbp)
je     11ad <saxs_writer_columns_write_lines+0x9d>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   *%rax
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    11c7 <saxs_writer_columns_write_lines+0xb7>
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    11d0 <saxs_writer_columns_write_lines+0xc0>
mov    -0x38(%rbp),%rdi
call   1030 <lines_free@plt>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<saxs_writer_columns_write_lines>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r15
mov    %rcx,%rbx
mov    %rsi,%r14
mov    %rdi,%r12
movq   $0x0,0x8(%rsp)
test   %rdx,%rdx
je     1149 <saxs_writer_columns_write_lines+0x39>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   *%rdx
mov    %eax,%ebp
test   %rbx,%rbx
jne    1150 <saxs_writer_columns_write_lines+0x40>
jmp    1160 <saxs_writer_columns_write_lines+0x50>
xor    %ebp,%ebp
test   %rbx,%rbx
je     1160 <saxs_writer_columns_write_lines+0x50>
test   %ebp,%ebp
jne    1160 <saxs_writer_columns_write_lines+0x50>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   *%rbx
mov    %eax,%ebp
test   %r15,%r15
je     1176 <saxs_writer_columns_write_lines+0x66>
test   %ebp,%ebp
jne    1176 <saxs_writer_columns_write_lines+0x66>
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
call   *%r15
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
test   %ebp,%ebp
je     1186 <saxs_writer_columns_write_lines+0x76>
call   1030 <lines_free@plt>
jmp    1189 <saxs_writer_columns_write_lines+0x79>
mov    %rdi,(%r14)
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.saxs_document = type { i32 }
%struct.line = type { i32 }
define i32 @saxs_writer_columns_write_lines(%struct.saxs_document* %0, %struct.line** %1, i32 (%struct.saxs_document*, %struct.line**)* %2, i32 (%struct.saxs_document*, %struct.line**)* %3, i32 (%struct.saxs_document*, %struct.line**)* %4) {
%6 = alloca %struct.saxs_document*
%7 = alloca %struct.line**
%8 = alloca i32 (%struct.saxs_document*, %struct.line**)*
%9 = alloca i32 (%struct.saxs_document*, %struct.line**)*
%10 = alloca i32 (%struct.saxs_document*, %struct.line**)*
%11 = alloca i32
%12 = alloca %struct.line*
store %struct.saxs_document* %0, %struct.saxs_document** %6
store %struct.line** %1, %struct.line*** %7
store i32 (%struct.saxs_document*, %struct.line**)* %2, i32 (%struct.saxs_document*, %struct.line**)** %8
store i32 (%struct.saxs_document*, %struct.line**)* %3, i32 (%struct.saxs_document*, %struct.line**)** %9
store i32 (%struct.saxs_document*, %struct.line**)* %4, i32 (%struct.saxs_document*, %struct.line**)** %10
store i32 0, i32* %11
store %struct.line* null, %struct.line** %12
%13 = load i32, i32* %11
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %22
15: ; preds = %5
%16 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %8
%17 = icmp ne i32 (%struct.saxs_document*, %struct.line**)* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %8
%20 = load %struct.saxs_document*, %struct.saxs_document** %6
%21 = call i32 %19(%struct.saxs_document* %20, %struct.line** %12)
store i32 %21, i32* %11
br label %22
22: ; preds = %18, %15, %5
%23 = load i32, i32* %11
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %9
%27 = icmp ne i32 (%struct.saxs_document*, %struct.line**)* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %9
%30 = load %struct.saxs_document*, %struct.saxs_document** %6
%31 = call i32 %29(%struct.saxs_document* %30, %struct.line** %12)
store i32 %31, i32* %11
br label %32
32: ; preds = %28, %25, %22
%33 = load i32, i32* %11
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %10
%37 = icmp ne i32 (%struct.saxs_document*, %struct.line**)* %36, null
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = load i32 (%struct.saxs_document*, %struct.line**)*, i32 (%struct.saxs_document*, %struct.line**)** %10
%40 = load %struct.saxs_document*, %struct.saxs_document** %6
%41 = call i32 %39(%struct.saxs_document* %40, %struct.line** %12)
store i32 %41, i32* %11
br label %42
42: ; preds = %38, %35, %32
%43 = load i32, i32* %11
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load %struct.line*, %struct.line** %12
%47 = load %struct.line**, %struct.line*** %7
store %struct.line* %46, %struct.line** %47
br label %51
48: ; preds = %42
%49 = load %struct.line*, %struct.line** %12
%50 = call i32 @lines_free(%struct.line* %49)
br label %51
51: ; preds = %48, %45
%52 = load i32, i32* %11
ret i32 %52
}

LLVM IR (-O2):
%struct.saxs_document = type { i32 }
%struct.line = type { i32 }
define i32 @saxs_writer_columns_write_lines(%struct.saxs_document* %0, %struct.line** nocapture writeonly %1, i32 (%struct.saxs_document*, %struct.line**)* %2, i32 (%struct.saxs_document*, %struct.line**)* %3, i32 (%struct.saxs_document*, %struct.line**)* %4) {
%6 = alloca %struct.line*
%7 = bitcast %struct.line** %6 to i8*
store %struct.line* null, %struct.line** %6
%8 = icmp eq i32 (%struct.saxs_document*, %struct.line**)* %2, null
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = call i32 %2(%struct.saxs_document* %0, %struct.line** %6)
br label %11
11: ; preds = %9, %5
%12 = phi i32 [ %10, %9 ], [ 0, %5 ]
%13 = icmp eq i32 %12, 0
%14 = icmp ne i32 (%struct.saxs_document*, %struct.line**)* %3, null
%15 = and i1 %14, %13
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 %3(%struct.saxs_document* %0, %struct.line** %6)
br label %18
18: ; preds = %16, %11
%19 = phi i32 [ %17, %16 ], [ %12, %11 ]
%20 = icmp eq i32 %19, 0
%21 = icmp ne i32 (%struct.saxs_document*, %struct.line**)* %4, null
%22 = and i1 %21, %20
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = call i32 %4(%struct.saxs_document* %0, %struct.line** %6)
br label %25
25: ; preds = %23, %18
%26 = phi i32 [ %24, %23 ], [ %19, %18 ]
%27 = icmp eq i32 %26, 0
%28 = load %struct.line*, %struct.line** %6
br i1 %27, label %29, label %30
29: ; preds = %25
store %struct.line* %28, %struct.line** %1
br label %32
30: ; preds = %25
%31 = call i32 @lines_free(%struct.line* %28)
br label %32
32: ; preds = %30, %29
ret i32 %26
}