#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 plot_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ plot_data_destroy(struct plot_data *);
scalar_t__ plot_data_draw(struct plot_data *);
struct plot_data *plot_data_parse_stdin();
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct plot_data *data;
  data = plot_data_parse_stdin();
  if (!data) {
    fprintf(stderr, "failed to read data.\n");
    return 1;
  }
  if (plot_data_draw(data) < 0)
    fprintf(stderr, "failed to print plot.\n");
  plot_data_destroy(data);
  data = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <plot_data_parse_stdin@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118d <main+0x4d>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11cd <main+0x8d>
mov    -0x18(%rbp),%rdi
call   1050 <plot_data_draw@plt>
cmp    $0x0,%rax
jge    11b5 <main+0x75>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <plot_data_destroy@plt>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <plot_data_parse_stdin@plt>
test   %rax,%rax
je     117e <main+0x3e>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <plot_data_draw@plt>
test   %rax,%rax
jns    1172 <main+0x32>
mov    0x2e7c(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
call   1040 <fprintf@plt>
mov    %rbx,%rdi
call   1060 <plot_data_destroy@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe72(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.plot_data = type { i32 }
@stderr = global i32 0
@.str = [22 x i8] c"failed to read data.\0A\00"
@.str.1 = [23 x i8] c"failed to print plot.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.plot_data*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.plot_data* (...) @plot_data_parse_stdin()
store %struct.plot_data* %7, %struct.plot_data** %6
%8 = load %struct.plot_data*, %struct.plot_data** %6
%9 = icmp ne %struct.plot_data* %8, null
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %23
13: ; preds = %2
%14 = load %struct.plot_data*, %struct.plot_data** %6
%15 = call i64 @plot_data_draw(%struct.plot_data* %14)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %17, %13
%21 = load %struct.plot_data*, %struct.plot_data** %6
%22 = call i32 @plot_data_destroy(%struct.plot_data* %21)
store %struct.plot_data* null, %struct.plot_data** %6
store i32 0, i32* %3
br label %23
23: ; preds = %20, %10
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
%struct.plot_data = type { i32 }
@stderr = global i32 0
@.str = [22 x i8] c"failed to read data.\0A\00"
@.str.1 = [23 x i8] c"failed to print plot.\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.plot_data* (...) @plot_data_parse_stdin()
%4 = icmp eq %struct.plot_data* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %16
8: ; preds = %2
%9 = tail call i64 @plot_data_draw(%struct.plot_data* %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %11, %8
%15 = tail call i32 @plot_data_destroy(%struct.plot_data* %3)
br label %16
16: ; preds = %14, %5
%17 = phi i32 [ 0, %14 ], [ 1, %5 ]
ret i32 %17
}