#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*/ printf(char *, char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ vfio_bind(char *);
void do_bind(char **argv, int beg, int end) {
  for (int i = beg; i < end; i++)
    printf("Binding [%s] -> %s\n", argv[i], strerror(vfio_bind(argv[i])));
}


x86 assembly (clang, -O0):
<do_bind>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    119d <do_bind+0x6d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1050 <vfio_bind@plt>
mov    %eax,%edi
call   1040 <strerror@plt>
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <do_bind+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_bind>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
cmp    %edx,%esi
jge    118a <do_bind+0x5a>
mov    %edx,%r15d
movslq %esi,%rax
lea    (%rdi,%rax,8),%r12
sub    %esi,%r15d
xor    %ebx,%ebx
lea    0xead(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbx,8),%r13
mov    %r13,%rdi
call   1050 <vfio_bind@plt>
mov    %eax,%edi
call   1040 <strerror@plt>
mov    %r14,%rdi
mov    %r13,%rsi
mov    %rax,%rdx
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %ebx,%r15d
jne    1160 <do_bind+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Binding [%s] -> %s\0A\00"
define void @do_bind(i8** %0, i32 %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8** %0, i8*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
store i32 %8, i32* %7
br label %9
9: ; preds = %27, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %6
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %30
13: ; preds = %9
%14 = load i8**, i8*** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = load i8**, i8*** %4
%20 = load i32, i32* %7
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8*, i8** %19, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @vfio_bind(i8* %23)
%25 = call i8* @strerror(i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %25)
br label %27
27: ; preds = %13
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %9
30: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [20 x i8] c"Binding [%s] -> %s\0A\00"
define void @do_bind(i8** nocapture %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %1, %2
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = sext i32 %1 to i64
br label %8
7: ; preds = %8, %3
ret void
8: ; preds = %5, %8
%9 = phi i64 [ %6, %5 ], [ %15, %8 ]
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @vfio_bind(i8* %11)
%13 = tail call i8* @strerror(i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %13)
%15 = add nsw i64 %9, 1
%16 = trunc i64 %15 to i32
%17 = icmp eq i32 %16, %2
br i1 %17, label %7, label %8
}