#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*/ SEEK_CUR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
void write_end(FILE *out1, FILE *out2, bool verb) {
  if (out2 != NULL) {
    fseek(out2, -3, SEEK_CUR);
    fprintf(out2, "];\r\n\r\n");
    fprintf(out2,
            "figure; hold on; grid on;\r\naxis([ "
            "min(min(samples(:,2)),min(samples(:,5))), "
            "max(max(samples(:,2)),max(samples(:,5))), "
            "min(min(samples(:,3)),min(samples(:,6))), "
            "max(max(samples(:,3)),max(samples(:,6))), "
            "min(min(samples(:,4)),min(samples(:,7))), "
            "max(max(samples(:,4)),max(samples(:,7)))+0.01 ]);\r\nfor sample = "
            "transpose(samples)\r\n   plot3(sample(2), sample(3), sample(4), "
            "'rd:');\r\n   plot3(sample(5), sample(6), sample(7), 'bd:');\r\n  "
            " pause(0.01);\r\nend\r\n");
  }
}


x86 assembly (clang, -O0):
<write_end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1175 <write_end+0x55>
mov    -0x10(%rbp),%rdi
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffd,%esi
call   1040 <fseek@plt>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe97(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_end>:
test   %rsi,%rsi
je     1172 <write_end+0x52>
push   %rbx
mov    %rsi,%rbx
mov    0x2eb8(%rip),%rax
mov    (%rax),%edx
mov    %rsi,%rdi
mov    $0xfffffffd,%esi
call   1030 <fseek@plt>
lea    0xeba(%rip),%rdi
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1040 <fwrite@plt>
lea    0xea8(%rip),%rdi
mov    $0x1c4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
pop    %rbx
jmp    1040 <fwrite@plt>
ret

LLVM IR (-O0):
@SEEK_CUR = global i32 0
@.str = [7 x i8] c"];\0D\0A\0D\0A\00"
@.str.1 = [453 x i8] c"figure; hold on; grid on;\0D\0Aaxis([ min(min(samples(:,2)),min(samples(:,5))), max(max(samples(:,2)),max(samples(:,5))), min(min(samples(:,3)),min(samples(:,6))), max(max(samples(:,3)),max(samples(:,6))), min(min(samples(:,4)),min(samples(:,7))), max(max(samples(:,4)),max(samples(:,7)))+0.01 ]);\0D\0Afor sample = transpose(samples)\0D\0A plot3(sample(2), sample(3), sample(4), 'rd:');\0D\0A plot3(sample(5), sample(6), sample(7), 'bd:');\0D\0A pause(0.01);\0D\0Aend\0D\0A\00"
define void @write_end(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = load i32*, i32** %5
%11 = load i32, i32* @SEEK_CUR
%12 = call i32 @fseek(i32* %10, i32 -3, i32 %11)
%13 = load i32*, i32** %5
%14 = call i32 @fprintf(i32* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = load i32*, i32** %5
%16 = call i32 @fprintf(i32* %15, i8* getelementptr inbounds ([453 x i8], [453 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %9, %3
ret void
}

LLVM IR (-O2):
@SEEK_CUR = global i32 0
@.str = [7 x i8] c"];\0D\0A\0D\0A\00"
@.str.1 = [453 x i8] c"figure; hold on; grid on;\0D\0Aaxis([ min(min(samples(:,2)),min(samples(:,5))), max(max(samples(:,2)),max(samples(:,5))), min(min(samples(:,3)),min(samples(:,6))), max(max(samples(:,3)),max(samples(:,6))), min(min(samples(:,4)),min(samples(:,7))), max(max(samples(:,4)),max(samples(:,7)))+0.01 ]);\0D\0Afor sample = transpose(samples)\0D\0A plot3(sample(2), sample(3), sample(4), 'rd:');\0D\0A plot3(sample(5), sample(6), sample(7), 'bd:');\0D\0A pause(0.01);\0D\0Aend\0D\0A\00"
define void @write_end(i32* nocapture readnone %0, i32* %1, i32 %2) {
%4 = icmp eq i32* %1, null
br i1 %4, label %10, label %5
5: ; preds = %3
%6 = load i32, i32* @SEEK_CUR
%7 = tail call i32 @fseek(i32* %1, i32 -3, i32 %6)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 6, i64 1, i32* %1)
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([453 x i8], [453 x i8]* @.str.1, i64 0, i64 0), i64 452, i64 1, i32* %1)
br label %10
10: ; preds = %5, %3
ret void
}