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

/* Variables and functions */
int /*<<< orphan*/ bail(struct viewer *);
int /*<<< orphan*/ diag(struct viewer *, int, char *, int);
int /*<<< orphan*/ offset_in_object_file(struct object *, int);
void expect_offset_in_object_file(struct viewer *viewer, struct object *object,
                                  int offset) {
  if (!offset_in_object_file(object, offset)) {
    diag(viewer, 0x1,
         "the object file appears to be malformed: an offset (%d) in the "
         "object file points outside the boundaries of the object file",
         offset);
    bail(viewer);
  }
}


x86 assembly (clang, -O0):
<expect_offset_in_object_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <offset_in_object_file@plt>
cmp    $0x0,%eax
jne    1179 <expect_offset_in_object_file+0x49>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    $0x1,%esi
lea    0xe95(%rip),%rdx
call   1030 <diag@plt>
mov    -0x8(%rbp),%rdi
call   1050 <bail@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expect_offset_in_object_file>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %edx,%esi
call   1040 <offset_in_object_file@plt>
test   %eax,%eax
je     114d <expect_offset_in_object_file+0x1d>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xeac(%rip),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%ecx
call   1030 <diag@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <bail@plt>

LLVM IR (-O0):
%struct.viewer = type { i32 }
%struct.object = type { i32 }
@.str = [124 x i8] c"the object file appears to be malformed: an offset (%d) in the object file points outside the boundaries of the object file\00"
define void @expect_offset_in_object_file(%struct.viewer* %0, %struct.object* %1, i32 %2) {
%4 = alloca %struct.viewer*
%5 = alloca %struct.object*
%6 = alloca i32
store %struct.viewer* %0, %struct.viewer** %4
store %struct.object* %1, %struct.object** %5
store i32 %2, i32* %6
%7 = load %struct.object*, %struct.object** %5
%8 = load i32, i32* %6
%9 = call i32 @offset_in_object_file(%struct.object* %7, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = load %struct.viewer*, %struct.viewer** %4
%13 = load i32, i32* %6
%14 = call i32 @diag(%struct.viewer* %12, i32 1, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load %struct.viewer*, %struct.viewer** %4
%16 = call i32 @bail(%struct.viewer* %15)
br label %17
17: ; preds = %11, %3
ret void
}

LLVM IR (-O2):
%struct.viewer = type { i32 }
%struct.object = type { i32 }
@.str = [124 x i8] c"the object file appears to be malformed: an offset (%d) in the object file points outside the boundaries of the object file\00"
define void @expect_offset_in_object_file(%struct.viewer* %0, %struct.object* %1, i32 %2) {
%4 = tail call i32 @offset_in_object_file(%struct.object* %1, i32 %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @diag(%struct.viewer* %0, i32 1, i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str, i64 0, i64 0), i32 %2)
%8 = tail call i32 @bail(%struct.viewer* %0)
br label %9
9: ; preds = %6, %3
ret void
}