#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
int strlen(char *);
char *strtok(char *, char *);
char *get_note_date(char *line) {
  char *date = NULL;
  char *tmpline = strdup(line);
  char *datetoken = NULL;
  if (tmpline == NULL)
    return NULL;
  datetoken = strtok(tmpline, "\t");
  datetoken = strtok(NULL, "\t");
  datetoken = strtok(NULL, "\t");
  if (datetoken == NULL) {
    free(tmpline);
    return NULL;
  }
  date = malloc((strlen(datetoken) + 1) * sizeof(char));
  if (date == NULL) {
    free(tmpline);
    return NULL;
  }
  strcpy(date, datetoken);
  free(tmpline);
  return date;
}


x86 assembly (clang, -O0):
<get_note_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11a1 <get_note_date+0x41>
movq   $0x0,-0x8(%rbp)
jmp    125a <get_note_date+0xfa>
mov    -0x20(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe40(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe2c(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11fe <get_note_date+0x9e>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    125a <get_note_date+0xfa>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123c <get_note_date+0xdc>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    125a <get_note_date+0xfa>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_note_date>:
push   %r15
push   %r14
push   %rbx
call   1080 <strdup@plt>
test   %rax,%rax
je     11c7 <get_note_date+0x67>
mov    %rax,%r14
lea    0xe87(%rip),%r15
mov    %rax,%rdi
mov    %r15,%rsi
call   1070 <strtok@plt>
xor    %ebx,%ebx
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11cd <get_note_date+0x6d>
mov    %rax,%r15
mov    %rax,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11cb <get_note_date+0x6b>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
jmp    11cd <get_note_date+0x6d>
xor    %ebx,%ebx
jmp    11d5 <get_note_date+0x75>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\09\00"
define i8* @get_note_date(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%7 = load i8*, i8** %3
%8 = call i8* @strdup(i8* %7)
store i8* %8, i8** %5
store i8* null, i8** %6
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i8* null, i8** %2
br label %42
12: ; preds = %1
%13 = load i8*, i8** %5
%14 = call i8* @strtok(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %14, i8** %6
%15 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** %6
%16 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8*, i8** %5
%21 = call i32 @free(i8* %20)
store i8* null, i8** %2
br label %42
22: ; preds = %12
%23 = load i8*, i8** %6
%24 = call i32 @strlen(i8* %23)
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 1
%28 = trunc i64 %27 to i32
%29 = call i8* @malloc(i32 %28)
store i8* %29, i8** %4
%30 = load i8*, i8** %4
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %22
%33 = load i8*, i8** %5
%34 = call i32 @free(i8* %33)
store i8* null, i8** %2
br label %42
35: ; preds = %22
%36 = load i8*, i8** %4
%37 = load i8*, i8** %6
%38 = call i32 @strcpy(i8* %36, i8* %37)
%39 = load i8*, i8** %5
%40 = call i32 @free(i8* %39)
%41 = load i8*, i8** %4
store i8* %41, i8** %2
br label %42
42: ; preds = %35, %32, %19, %11
%43 = load i8*, i8** %2
ret i8* %43
}

LLVM IR (-O2):
@.str = [2 x i8] c"\09\00"
define i8* @get_note_date(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = icmp eq i8* %2, null
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i8* @strtok(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = tail call i32 @strlen(i8* %7)
%11 = add nsw i32 %10, 1
%12 = tail call i8* @malloc(i32 %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = tail call i32 @strcpy(i8* %12, i8* %7)
br label %16
16: ; preds = %9, %4, %14
%17 = phi i8* [ %12, %14 ], [ null, %4 ], [ null, %9 ]
%18 = tail call i32 @free(i8* %2)
br label %19
19: ; preds = %16, %1
%20 = phi i8* [ null, %1 ], [ %17, %16 ]
ret i8* %20
}