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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *malloc(int);
int snprintf(char *, int, char *, char *, char *);
char *token_to_string(struct token *);
char *token_info(struct token *expected, struct token *actual) {
  static int max_length = 255;
  char *buffer = malloc(sizeof(char) * max_length);
  char *expected_str = token_to_string(expected);
  char *actual_str = token_to_string(actual);
  int result = snprintf(buffer, max_length,
                        "\n        [expected] %s\n          [actual] %s",
                        expected_str, actual_str);
  if (expected_str)
    free(expected_str);
  if (actual_str)
    free(actual_str);
  if (result >= 0 && result < max_length) {
    return buffer;
  }
  free(buffer);
  return 0;
}


x86 assembly (clang, -O0):
<token_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movslq 0x2ee9(%rip),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <token_to_string@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <token_to_string@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2eb6(%rip),%esi
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
lea    0xe67(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11b5 <token_info+0x75>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpq   $0x0,-0x30(%rbp)
je     11c9 <token_info+0x89>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x34(%rbp)
jl     11ef <token_info+0xaf>
mov    -0x34(%rbp),%eax
cmp    0x2e64(%rip),%eax
jge    11ef <token_info+0xaf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1200 <token_info+0xc0>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<token_info>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    $0xff,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <token_to_string@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1060 <token_to_string@plt>
mov    %rax,%r15
lea    0xe89(%rip),%rdx
mov    %r14,%rdi
mov    $0xff,%esi
mov    %rbx,%rcx
mov    %rax,%r8
call   1040 <snprintf@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     1199 <token_info+0x59>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15,%r15
je     11a6 <token_info+0x66>
mov    %r15,%rdi
call   1030 <free@plt>
cmp    $0xff,%ebp
jb     11b9 <token_info+0x79>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.token = type { i32 }
@token_info.max_length = internal global i32 255
@.str = [45 x i8] c"\0A [expected] %s\0A [actual] %s\00"
define i8* @token_info(%struct.token* %0, %struct.token* %1) {
%3 = alloca i8*
%4 = alloca %struct.token*
%5 = alloca %struct.token*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
store %struct.token* %0, %struct.token** %4
store %struct.token* %1, %struct.token** %5
%10 = load i32, i32* @token_info.max_length
%11 = sext i32 %10 to i64
%12 = mul i64 1, %11
%13 = trunc i64 %12 to i32
%14 = call i8* @malloc(i32 %13)
store i8* %14, i8** %6
%15 = load %struct.token*, %struct.token** %4
%16 = call i8* @token_to_string(%struct.token* %15)
store i8* %16, i8** %7
%17 = load %struct.token*, %struct.token** %5
%18 = call i8* @token_to_string(%struct.token* %17)
store i8* %18, i8** %8
%19 = load i8*, i8** %6
%20 = load i32, i32* @token_info.max_length
%21 = load i8*, i8** %7
%22 = load i8*, i8** %8
%23 = call i32 @snprintf(i8* %19, i32 %20, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %21, i8* %22)
store i32 %23, i32* %9
%24 = load i8*, i8** %7
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i8*, i8** %7
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %26, %2
%30 = load i8*, i8** %8
%31 = icmp ne i8* %30, null
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i8*, i8** %8
%34 = call i32 @free(i8* %33)
br label %35
35: ; preds = %32, %29
%36 = load i32, i32* %9
%37 = icmp sge i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %9
%40 = load i32, i32* @token_info.max_length
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = load i8*, i8** %6
store i8* %43, i8** %3
br label %47
44: ; preds = %38, %35
%45 = load i8*, i8** %6
%46 = call i32 @free(i8* %45)
store i8* null, i8** %3
br label %47
47: ; preds = %44, %42
%48 = load i8*, i8** %3
ret i8* %48
}

LLVM IR (-O2):
%struct.token = type { i32 }
@.str = [45 x i8] c"\0A [expected] %s\0A [actual] %s\00"
define i8* @token_info(%struct.token* %0, %struct.token* %1) {
%3 = tail call dereferenceable_or_null(255) i8* @malloc(i32 255)
%4 = tail call i8* @token_to_string(%struct.token* %0)
%5 = tail call i8* @token_to_string(%struct.token* %1)
%6 = tail call i32 @snprintf(i8* %3, i32 255, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5)
%7 = icmp eq i8* %4, null
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @free(i8* %4)
br label %10
10: ; preds = %8, %2
%11 = icmp eq i8* %5, null
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 @free(i8* %5)
br label %14
14: ; preds = %12, %10
%15 = icmp ult i32 %6, 255
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @free(i8* %3)
br label %18
18: ; preds = %14, %16
%19 = phi i8* [ null, %16 ], [ %3, %14 ]
ret i8* %19
}