#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 tm {
  int dummy;
};
struct plant_date {
  int dummy;
};
struct date_list {
  int dummy;
};

/* Variables and functions */
struct plant_date *make_calendar_entry(struct tm *, char *, char *);
int /*<<< orphan*/ sort_in_one_date(struct plant_date *, struct date_list **);
int insert_calendar_entry(struct tm *date, char *summary, char *description,
                          struct date_list **head_ptr) {
  struct plant_date *cal_entry;
  cal_entry = make_calendar_entry(date, summary, description);
  if (!cal_entry)
    return 0;
  if (!sort_in_one_date(cal_entry, head_ptr))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<insert_calendar_entry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <make_calendar_entry@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1164 <insert_calendar_entry+0x44>
movl   $0x0,-0x4(%rbp)
jmp    118d <insert_calendar_entry+0x6d>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <sort_in_one_date@plt>
cmp    $0x0,%eax
jne    1186 <insert_calendar_entry+0x66>
movl   $0x0,-0x4(%rbp)
jmp    118d <insert_calendar_entry+0x6d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insert_calendar_entry>:
push   %rbx
mov    %rcx,%rbx
call   1030 <make_calendar_entry@plt>
test   %rax,%rax
je     1144 <insert_calendar_entry+0x24>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <sort_in_one_date@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
setne  %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
%struct.date_list = type { i32 }
%struct.plant_date = type { i32 }
define i32 @insert_calendar_entry(%struct.tm* %0, i8* %1, i8* %2, %struct.date_list** %3) {
%5 = alloca i32
%6 = alloca %struct.tm*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.date_list**
%10 = alloca %struct.plant_date*
store %struct.tm* %0, %struct.tm** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store %struct.date_list** %3, %struct.date_list*** %9
%11 = load %struct.tm*, %struct.tm** %6
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = call %struct.plant_date* @make_calendar_entry(%struct.tm* %11, i8* %12, i8* %13)
store %struct.plant_date* %14, %struct.plant_date** %10
%15 = load %struct.plant_date*, %struct.plant_date** %10
%16 = icmp ne %struct.plant_date* %15, null
br i1 %16, label %18, label %17
17: ; preds = %4
store i32 0, i32* %5
br label %25
18: ; preds = %4
%19 = load %struct.plant_date*, %struct.plant_date** %10
%20 = load %struct.date_list**, %struct.date_list*** %9
%21 = call i32 @sort_in_one_date(%struct.plant_date* %19, %struct.date_list** %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18
store i32 0, i32* %5
br label %25
24: ; preds = %18
store i32 1, i32* %5
br label %25
25: ; preds = %24, %23, %17
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
%struct.tm = type { i32 }
%struct.date_list = type { i32 }
%struct.plant_date = type { i32 }
define i32 @insert_calendar_entry(%struct.tm* %0, i8* %1, i8* %2, %struct.date_list** %3) {
%5 = tail call %struct.plant_date* @make_calendar_entry(%struct.tm* %0, i8* %1, i8* %2)
%6 = icmp eq %struct.plant_date* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @sort_in_one_date(%struct.plant_date* %5, %struct.date_list** %3)
%9 = icmp ne i32 %8, 0
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 0, %4 ], [ %10, %7 ]
ret i32 %12
}