#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 iovec {
  size_t iov_len;
  void *iov_base;
};

/* Variables and functions */
int /*<<< orphan*/ errx(int, char *, void *, char const *);
void *_convert(struct iovec *iov, size_t size, size_t align, const char *name) {
  if (iov->iov_len != size)
    errx(1, "Bad iovec size %zu for %s", iov->iov_len, name);
  if ((unsigned long)iov->iov_base % align != 0)
    errx(1, "Bad alignment %p for %s", iov->iov_base, name);
  return iov->iov_base;
}


x86 assembly (clang, -O0):
<_convert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmp    -0x10(%rbp),%rax
je     1155 <_convert+0x45>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%edi
lea    0xeb0(%rip),%rsi
call   1030 <errx@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
je     118c <_convert+0x7c>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x20(%rbp),%rcx
mov    $0x1,%edi
lea    0xe93(%rip),%rsi
call   1030 <errx@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_convert>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rdi,%r15
mov    (%rdi),%rdx
cmp    %rsi,%rdx
je     113a <_convert+0x2a>
lea    0xed3(%rip),%rsi
mov    $0x1,%edi
mov    %r14,%rcx
call   1030 <errx@plt>
mov    0x8(%r15),%rcx
mov    %rcx,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     117b <_convert+0x6b>
mov    %rcx,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
je     1172 <_convert+0x62>
lea    0xebc(%rip),%rsi
mov    $0x1,%edi
mov    %rcx,%rdx
mov    %r14,%rcx
call   1030 <errx@plt>
mov    0x8(%r15),%rcx
mov    %rcx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %ecx,%eax
xor    %edx,%edx
div    %ebx
test   %rdx,%rdx
jne    1157 <_convert+0x47>
jmp    1172 <_convert+0x62>

LLVM IR (-O0):
%struct.iovec = type { i64, i8* }
@.str = [26 x i8] c"Bad iovec size %zu for %s\00"
@.str.1 = [24 x i8] c"Bad alignment %p for %s\00"
define i8* @_convert(%struct.iovec* %0, i64 %1, i64 %2, i8* %3) {
%5 = alloca %struct.iovec*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
store %struct.iovec* %0, %struct.iovec** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%9 = load %struct.iovec*, %struct.iovec** %5
%10 = getelementptr inbounds %struct.iovec, %struct.iovec* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = load i64, i64* %6
%13 = icmp ne i64 %11, %12
br i1 %13, label %14, label %21
14: ; preds = %4
%15 = load %struct.iovec*, %struct.iovec** %5
%16 = getelementptr inbounds %struct.iovec, %struct.iovec* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = inttoptr i64 %17 to i8*
%19 = load i8*, i8** %8
%20 = call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19)
br label %21
21: ; preds = %14, %4
%22 = load %struct.iovec*, %struct.iovec** %5
%23 = getelementptr inbounds %struct.iovec, %struct.iovec* %22, i32 0, i32 1
%24 = load i8*, i8** %23
%25 = ptrtoint i8* %24 to i64
%26 = load i64, i64* %7
%27 = urem i64 %25, %26
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %35
29: ; preds = %21
%30 = load %struct.iovec*, %struct.iovec** %5
%31 = getelementptr inbounds %struct.iovec, %struct.iovec* %30, i32 0, i32 1
%32 = load i8*, i8** %31
%33 = load i8*, i8** %8
%34 = call i32 @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33)
br label %35
35: ; preds = %29, %21
%36 = load %struct.iovec*, %struct.iovec** %5
%37 = getelementptr inbounds %struct.iovec, %struct.iovec* %36, i32 0, i32 1
%38 = load i8*, i8** %37
ret i8* %38
}

LLVM IR (-O2):
%struct.iovec = type { i64, i8* }
@.str = [26 x i8] c"Bad iovec size %zu for %s\00"
@.str.1 = [24 x i8] c"Bad alignment %p for %s\00"
define i8* @_convert(%struct.iovec* nocapture %0, i64 %1, i64 %2, i8* %3) {
%5 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 0, i32 0
%6 = load i64, i64* %5
%7 = icmp eq i64 %6, %1
br i1 %7, label %11, label %8
8: ; preds = %4
%9 = inttoptr i64 %6 to i8*
%10 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %3)
br label %11
11: ; preds = %8, %4
%12 = getelementptr inbounds %struct.iovec, %struct.iovec* %0, i64 0, i32 1
%13 = load i8*, i8** %12
%14 = ptrtoint i8* %13 to i64
%15 = urem i64 %14, %2
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %13, i8* %3)
%19 = load i8*, i8** %12
br label %20
20: ; preds = %17, %11
%21 = phi i8* [ %19, %17 ], [ %13, %11 ]
ret i8* %21
}