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

/* Variables and functions */
int /*<<< orphan*/ diag(struct viewer *, int, char *, char const *, int, int,
                        char *);
void warn_expect_chunk_data(struct viewer *viewer, int data_left, int data_size,
                            const char *data_name) {
  diag(viewer, 0x2,
       "expecting to read %s (%d bytes), but chunk does not have enough data "
       "left (%d byte%s)",
       data_name, data_size, data_left, (data_left == 1) ? "" : "s");
}


x86 assembly (clang, -O0):
<warn_expect_chunk_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0xc(%rbp),%esi
lea    0xf16(%rip),%rax
lea    0xf0e(%rip),%rdx
cmp    $0x1,%esi
cmove  %rdx,%rax
mov    $0x2,%esi
lea    0xea6(%rip),%rdx
mov    %rax,(%rsp)
call   1030 <diag@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<warn_expect_chunk_data>:
push   %rax
mov    %edx,%r8d
mov    %esi,%r9d
cmp    $0x1,%esi
lea    0xf34(%rip),%rax
lea    0xf2e(%rip),%rdx
cmove  %rax,%rdx
mov    %rdx,(%rsp)
lea    0xec9(%rip),%rdx
mov    $0x2,%esi
call   1030 <diag@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.viewer = type { i32 }
@.str = [86 x i8] c"expecting to read %s (%d bytes), but chunk does not have enough data left (%d byte%s)\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
define void @warn_expect_chunk_data(%struct.viewer* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca %struct.viewer*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store %struct.viewer* %0, %struct.viewer** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%9 = load %struct.viewer*, %struct.viewer** %5
%10 = load i8*, i8** %8
%11 = load i32, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i64
%16 = select i1 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%17 = call i32 @diag(%struct.viewer* %9, i32 2, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11, i32 %12, i8* %16)
ret void
}

LLVM IR (-O2):
%struct.viewer = type { i32 }
@.str = [86 x i8] c"expecting to read %s (%d bytes), but chunk does not have enough data left (%d byte%s)\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
define void @warn_expect_chunk_data(%struct.viewer* %0, i32 %1, i32 %2, i8* %3) {
%5 = icmp eq i32 %1, 1
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%7 = tail call i32 @diag(%struct.viewer* %0, i32 2, i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str, i64 0, i64 0), i8* %3, i32 %2, i32 %1, i8* %6)
ret void
}